Кондиция 29.
[cswow.git] / include / report_generator.php
blobee3271931b09720032d1a5b698af69f4218c3418
1 <?php
2 include_once("functions.php");
4 // Report generator class (класс генератора отчётов)
5 class ReportGenerator{
6 var $mark = ''; // Report uniquie id
7 var $disable_mark = false;// Disable mark check/add (single report on page)
8 var $ajax_mode = 0; // Report mode direct render / ajax load
9 var $fields = 0; // Columns array
10 var $page = 1; // Report page
11 var $size_limit = 0; // Report row limit
12 var $total_data = 0; // Total rows
13 var $sort_method= 0; // Sort
14 var $sort_default = ''; // Default sort
15 var $r_link = ''; // Base page link
16 var $rowCallback = ''; // Callback function for row render
18 var $column_conf=0; // Report config array
19 // NPC report generator config array, contain elements:
20 // 'field_name' =>array(
21 // 'class'=>'', - cell class (width, align)
22 // 'sort'=>'sort', - column sort type
23 // 'text'=>'text', - column header text
24 // 'draw'=>'r_drawFunc', - cell draw function name
25 // 'sort_str'=>'`name`', - sort require string
26 // 'fields'=>'`name`'); - fields require for draw cell
27 var $db=0; // DB class for get data (filled in
28 var $table = ''; // DB tables
29 var $db_fields = '*'; // DB fields
30 var $query_args = 0; // Helper for expand query placeholders
31 var $data_array = 0; // Report data stored here
32 // Init data for report (return false if no need create it)
33 function Init(&$fields, $link, $report_mark, $limit, $def_sort)
35 global $ajaxmode;
36 // Init data if need directly create report or upload in ajax mode
37 if ($ajaxmode == 0 || $this->disable_mark || $report_mark==@$_REQUEST['mark'])
39 // echo $report_mark."<br />";
40 $this->ajax_mode = $ajaxmode;
41 $this->mark = $report_mark; // This report mark
42 $this->fields =& $fields; // Columns array
43 $this->sort_default = $def_sort; // Default sort
44 $this->size_limit = $limit; // Size limit (max row count)
45 $this->total_data = -1; // Total exist data
46 $this->r_link = $link; // Base page link
47 $this->data_array = 0;
48 // In url exist page, sort for this report store it
49 if ($this->disable_mark || $report_mark==@$_REQUEST['mark'])
51 $this->page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; // Store page
52 $this->sort_method = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : $def_sort; // Store sort method
53 if ($this->page < 1) $this->page = 1;
54 return true;
56 // No data for this report - set default
57 $this->page = 1;
58 $this->offset = 0;
59 $this->sort_method = $def_sort;
60 return true;
62 return false;
64 // Add custom column config
65 function addColumnConfig($name, $conf) {$this->column_conf[$name]=$conf;}
66 // Get total data count in result
67 function getTotalDataCount() {return $this->total_data;}
68 // Disable report mark in link (single report on page)
69 function disableMark() {$this->disable_mark = true;}
70 // Report link generator (for pages, headers)
71 function createLink($page, $sort)
73 $link = $this->r_link;
74 if ($page > 1) $link.='&page='.$page;
75 if ($sort!=$this->sort_default)
76 $link.='&sort='.$sort;
78 if (!$this->disable_mark) $link.='&mark='.$this->mark;
79 return $link;
81 // Create reference to report
82 function createHref($page, $sort, $text)
84 return '<a href="'.$this->createLink($page, $sort).'" onClick="return uploadFromHref(this, \''.$this->mark.'\');">'.$text.'</a>';
86 // Generate report
87 function createReport($header)
89 global $bw_icon_mode;
90 if (!$this->data_array || !$this->total_data || !$this->column_conf) return;
91 $this->slicePage();
92 $columns = count($this->fields);
93 if ($this->ajax_mode==0)
94 echo '<div class=reportContainer id="'.$this->mark.'">';
96 echo '<table class=report width=500>';
97 echo '<thead>';
98 echo '<tr class=head><td colspan='.$columns.'>'.$header.'</td></tr>';
99 echo '<tr>';
100 foreach ($this->fields as $field)
102 $f =& $this->column_conf[$field];
103 echo '<th>';
104 if ($f['sort'] && $this->total_data > 1)
105 echo $this->createHref($this->page, $f['sort'], $f['text']);
106 else
107 echo $f['text'];
108 echo '</th>';
110 echo '</tr>';
111 echo '</thead>';
112 echo '<tbody>';
113 foreach ($this->data_array as &$data)
115 $cb = $this->rowCallback;
116 $class = $cb ? $cb($data) : 0;
117 $row_class = $class ? ' class='.$class : '';
118 echo '<tr'.$row_class.'>';
119 foreach ($this->fields as $field)
121 $f =& $this->column_conf[$field];
122 echo $f['class']?'<td class='.$f['class'].'>' : '<td>';
123 $f['draw']($data);
124 echo '</td>';
126 echo '</tr>';
127 unsetBwIconMode();
129 if ($this->size_limit && $this->total_data > $this->size_limit)
131 $totalPage = floor($this->total_data/$this->size_limit+0.9999);
132 $page = $this->page;
133 echo '<tr><td colspan='.$columns.' class=page>';
134 for ($i=1;$i<=$totalPage;$i++)
136 if ($i!=$page) echo $this->createHref($i, $this->sort_method, $i).' ';
137 else echo '<b><i>'.$i.' </i></b>';
139 echo "</td></tr>";
141 echo '</tbody></table>';
142 if ($this->ajax_mode==0)
144 echo '</div>';
145 // Cache data
146 $link = $this->createLink($this->page, $this->sort_method);
147 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
148 $tabName = $this->total_data > 1 ? $header.' ('.$this->total_data.')' : $header;
149 if (!$this->disable_mark) addTab($tabName, $this->mark);
152 // Remove column if all data zero
153 function removeIfAllZero($fname, $field)
155 $set = 0;
156 foreach($this->data_array as &$v) if (!isset($v[$fname]) OR $v[$fname]) {$set = 1;break;}
157 if (!$set) $this->removeField($field);
159 // Remove field
160 function removeField($name)
162 if ($id = array_search($name, $this->fields))
163 unset($this->fields[$id]);
165 // Expand placeholders func
166 function expandPlaceholdersCallback($m)
168 if (!empty($m[2]))
170 $value = array_pop($this->query_args);
171 switch ($m[3]) {
172 case 'a': return join(', ', $value);
173 case 'd': return intval($value);
174 case 'u': return sprintf('%u',$value);
175 case 'f': return str_replace(',', '.', floatval($value));
177 return $value;
179 if (isset($m[1]) && strlen($block=$m[1]))
181 if (current($this->query_args) === DBSIMPLE_SKIP)
183 array_pop($this->query_args);
184 return '';
186 return $this->_doPlaceholders($block);
188 return $m[0];
190 function _doPlaceholders($query)
192 $re = '{(?>\{( (?> (?>[^{}]+) | (?R) )* )\}) | (?>(\?) ( [duaf]? ))}sx';
193 return preg_replace_callback($re, array(&$this,'expandPlaceholdersCallback'), $query);
195 function expandPlaceholders($data)
197 $this->query_args = array_reverse($data);
198 return $this->_doPlaceholders(array_pop($this->query_args));
200 // Database depend requirest generator
201 function doRequirest($where)
203 global $config;
204 $locale = $config['locales_lang'];
205 $where_filter = $this->expandPlaceholders(func_get_args());
206 $tables = $this->table;
207 $fields = $this->getFieldsRequirest();
208 $sort_str= $this->getSortRequirest();
209 if ($locale)
210 $this->localiseRequirest($locale, $tables, $fields, $sort_str);
211 $reqString = 'SELECT '.$fields.' FROM '.$tables.' WHERE '.$where_filter.$sort_str.$this->getLimitRequirest();
212 // echo "<br />".$reqString."<br />";
213 if ($this->size_limit > 0)
214 $this->data_array = $this->db->selectPage($this->total_data, $reqString);
215 else
217 $this->data_array = $this->db->select($reqString);
218 $this->total_data = count($this->data_array);
221 // Manually slice on page
222 function setManualPagenateMode() {if ($this->size_limit >=0) $this->size_limit =-$this->size_limit;}
223 function slicePage()
225 if ($this->size_limit >=0) return;
226 $this->total_data = count($this->data_array);
227 $this->size_limit = -$this->size_limit;
228 $this->data_array = array_slice($this->data_array,($this->page-1)*$this->size_limit, $this->size_limit);
230 // Localise fields requirement and sort
231 function localiseRequirest($locale, &$fields, &$sort){return;}
232 // Build fields list depend from config
233 function getFieldsRequirest()
235 if ($this->db_fields=='*')
236 return '*';
237 $r = $this->db_fields;
238 foreach($this->fields as $f)
239 if ($data = $this->column_conf[$f]['fields'])
240 $r.=', '.$data;
241 return join(',', array_unique(explode(',', $r)));
243 function addFieldsRequirest($f)
245 if ($this->db_fields=='*')
246 return;
247 $this->db_fields.=', '.$f;
249 // Get sort requirest depend from config
250 function getSortRequirest()
252 if ($this->sort_method)
253 foreach($this->column_conf as $c)
254 if ($this->sort_method==$c['sort'])
255 return ' ORDER BY '.$c['sort_str'];
256 return '';
258 // Get limit requirest depend from page and page size
259 function getLimitRequirest()
261 if ($this->size_limit > 0)
262 return ' LIMIT '.(($this->page-1)*$this->size_limit).', '.$this->size_limit;
263 return '';
267 //==============================================================================
268 // Tabbed report functions
269 //==============================================================================
270 $tab_mode = 2; // disabled
271 function createReportTab()
273 global $tab_mode, $config, $ajaxmode;
274 if(!$config['use_tab_mode'] || $ajaxmode)
275 return;
276 echo '<script type="text/javascript">report_hideHeaders()</script>';
277 echo '<br><ul class=my_tabs id="report_tabs"></ul>';
278 $tab_mode = 1; // First page select
280 function addTab($header, $mark)
282 global $tab_mode;
283 if ($tab_mode > 1) return;
284 if (isset($_REQUEST['mark']))
285 $selected = $mark==$_REQUEST['mark'] ? 1 : 0;
286 else
287 $selected = $tab_mode?1:0;
288 echo '<script type="text/javascript">report_addTab("'.$header.'", "'.$mark.'", '.$selected.');</script>';
289 $tab_mode = 0; // disable select page
292 // Get some data
293 function getRefrenceItemLoot($entry)
295 global $dDB;
296 // Получаем рефренс лут
297 return $dDB->select('-- CACHE: 1h
298 SELECT `entry` AS ARRAY_KEY, `ChanceOrQuestChance`, `groupid`, `mincountOrRef`, `maxcount`, `lootcondition`, `condition_value1`, `condition_value2` FROM `reference_loot_template` WHERE `item`=?d', $entry);
300 function getFactionTemplates($entry)
302 global $wDB;
303 return $wDB->selectCol('-- CACHE: 1h
304 SELECT `id` FROM `wowd_faction_template` WHERE `faction` = ?d', $entry);
306 function getPlayerSpells($guid)
308 global $cDB;
309 return $cDB->select('-- CACHE: 1h
310 SELECT `spell` AS ARRAY_KEY FROM `character_spell` WHERE `guid` = ?d AND `disabled` = 0', $guid);
313 $gheroic = 0;
314 function getHeroicList()
316 global $dDB, $gheroic;
317 if (!$gheroic)
318 $gheroic = $dDB->selectCol('-- CACHE: 1h
319 SELECT `difficulty_entry_1` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_1` <> 0');
320 return $gheroic;
323 $gheroic1 = 0;
324 function getHeroicList1()
326 global $dDB, $gheroic1;
327 if (!$gheroic1)
328 $gheroic1 = $dDB->selectCol('-- CACHE: 1h
329 SELECT `difficulty_entry_2` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_2` <> 0');
330 return $gheroic1;
333 $gheroic2 = 0;
334 function getHeroicList2()
336 global $dDB, $gheroic2;
337 if (!$gheroic2)
338 $gheroic2 = $dDB->selectCol('-- CACHE: 1h
339 SELECT `difficulty_entry_3` AS ARRAY_KEY, `entry` FROM `creature_template` WHERE `difficulty_entry_3` <> 0');
340 return $gheroic2;
342 //==============================================================================
343 // Callback functions
344 //==============================================================================
345 function playerSpellCallback($data)
347 $spells = getPlayerSpells($_REQUEST['guid']);
348 if (isset($spells[$data['id']]))
349 return 0;
350 setBwIconMode();
351 return 'notknow';
354 //==============================================================================
355 // Loot
356 //==============================================================================
357 function r_lootChance($data)
359 if ($data['mincountOrRef'] < 0)
361 echo 'R'.($data['ChanceOrQuestChance']).'%';
363 else if ($data['ChanceOrQuestChance'] < 0)
364 echo 'Q'.(-$data['ChanceOrQuestChance']).'%';
365 else
366 echo $data['ChanceOrQuestChance'].'%';
368 function r_lootRequire($data)
370 global $lang;
371 switch ($data['lootcondition']){
372 case 1: // CONDITION_AURA - spell_id, effindex
373 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
374 echo $lang['condition1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
375 break;
376 case 2: // CONDITION_ITEM - item_id, count
377 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
378 echo $lang['condition2'].text_show_item($item['entry'], $item['displayid'], 'quest');
379 if ($data['condition_value2'] > 1) echo 'x'.$data['condition_value2'];
380 break;
381 case 3: // CONDITION_ITEM_EQUIPPED - item_id, 0
382 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
383 echo $lang['condition3'].text_show_item($item['entry'], $item['displayid'], 'quest');
384 break;
385 case 4: // CONDITION_AREAID - area_id 0, 1 (0: in (sub)area, 1: not in (sub)area)
386 if ($data['condition_value2'] > 0 ) echo $lang['condition4_1'].getAreaName($data['condition_value1']);
387 if ($data['condition_value2'] == 0) echo getAreaName($data['condition_value1']);
388 break;
389 case 5: // CONDITION_REPUTATION_RANK - faction_id, min_rank
390 echo getFactionName($data['condition_value1']).'('.getReputationRankName($data['condition_value2']).')';
391 break;
392 case 6: // CONDITION_TEAM player_team, 0 (469 - Alliance 67 - Horde)
393 echo getFactionName($data['condition_value1']);
394 break;
395 case 7: // CONDITION_SKILL skill_id, skill_value
396 echo $lang['condition7'].getSkillName($data['condition_value1']);
397 if ($data['condition_value2'] > 1) echo ' ('.$data['condition_value2'].')';
398 break;
399 case 8: // CONDITION_QUESTREWARDED quest_id, 0
400 echo $lang['condition8'].getQuestName($data['condition_value1']);
401 break;
402 case 9: // CONDITION_QUESTTAKEN quest_id 0, for condition true while quest active.
403 echo $lang['condition9'].getQuestName($data['condition_value1']);
404 break;
405 case 10: // CONDITION_AD_COMMISSION_AURA 0, 0 for condition true while one from AD сommission aura active
406 echo $lang['condition10'];
407 break;
408 case 11: // CONDITION_NO_AURA spell_id, effindex
409 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
410 echo $lang['condition11']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');
411 break;
412 case 12: // CONDITION_ACTIVE_GAME_EVENT event_id
413 echo $lang['condition12'].getGameEventName($data['condition_value1']);
414 break;
415 case 13: // CONDITION_AREA_FLAG area_flag area_flag_not
416 if ($data['condition_value1'] > 0) echo $lang['condition13_1'].$data['condition_value1'];
417 if ($data['condition_value2'] > 0) echo $lang['condition13_2'].$data['condition_value2'];
418 break;
419 case 14: // CONDITION_RACE_CLASS race_mask class_mask
420 if ($data['condition_value1'] > 0) echo getAllowableRace($data['condition_value1']).'<br>';
421 if ($data['condition_value2'] > 0) echo getAllowableClass($data['condition_value2']);
422 break;
423 case 15: // CONDITION_LEVEL player_level 0, 1 or 2
424 if ($data['condition_value1'] > 0) echo $data['condition_value1'];
425 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 0)) echo $lang['condition15_1'];
426 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 1)) echo $lang['condition15_2'];
427 if (($data['condition_value1'] > 0) && ($data['condition_value2'] == 2)) echo $lang['condition15_3'];
428 break;
429 case 16: // CONDITION_NOITEM item_id count
430 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
431 echo $lang['condition16'].text_show_item($item['entry'], $item['displayid'], 'quest');
432 if ($data['condition_value1'] > 1) echo 'x'.$data['condition_value2'];
433 break;
434 case 17: // CONDITION_SPELL spell_id 0, 1 (0: has spell, 1: hasn't spell)
435 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
436 if ($data['condition_value2'] > 0) { echo $lang['condition17_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
437 else { echo $lang['condition17_2']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
438 break;
439 case 20: // CONDITION_ACHIEVEMENT ach_id 0, 1 (0: has achievement, 1: hasn't achievement) for player
440 if ($data['condition_value2'] > 0) echo $lang['condition20_1'].$data['condition_value1'];
441 else echo $lang['condition20_2'].$data['condition_value1'];
442 break;
443 case 22: // CONDITION_QUEST_NONE quest_id
444 if ($data['condition_value1'] > 0) echo $lang['condition22'].getQuestName($data['condition_value1']);
445 break;
446 case 23: // CONDITION_ITEM_WITH_BANK- item_id, count
447 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
448 echo $lang['condition23'].text_show_item($item['entry'], $item['displayid'], 'quest');
449 if ($data['condition_value2'] > 1) echo 'x'.$data['condition_value2'];
450 break;
451 case 24: // NOITEM_WITH_BANK item_id count
452 $item = getItem($data['condition_value1'], '`entry`, `displayid`');
453 echo $lang['condition24'].text_show_item($item['entry'], $item['displayid'], 'quest');
454 if ($data['condition_value1'] > 1) echo 'x'.$data['condition_value2'];
455 break;
456 case 25: // CONDITION_NOT_ACTIVE_GAME_EVENT event_id
457 echo $lang['condition25'].getGameEventName($data['condition_value1']);
458 break;
459 case 26: // CONDITION_ACTIVE_HOLIDAY holiday_id
460 echo $lang['condition26'].getGameHolidayName($data['condition_value1']);
461 break;
462 case 27: // CONDITION_NOT_ACTIVE_HOLIDAY holiday_id
463 echo $lang['condition27'].getGameHolidayName($data['condition_value1']);
464 break;
465 case 28: // CONDITION_LEARNABLE_ABILITY spell_id 0 or item_id
466 $spell = getSpell($data['condition_value1'], '`id`, `SpellIconID`');
467 if ($data['condition_value2'] > 0) { $item = getItem($data['condition_value2'], '`entry`, `displayid`'); echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest'); echo $lang['condition28_2'].text_show_item($item['entry'], $item['displayid'], 'quest');}
468 else {echo $lang['condition28_1']; show_spell($spell['id'], $spell['SpellIconID'], 'quest');}
469 break;
470 case 29: // CONDITION_SKILL_BELOW skill_id, skill_value
471 echo $lang['condition29'].getSkillName($data['condition_value1']);
472 if ($data['condition_value2'] > 1) echo ' ('.$data['condition_value2'].')';
473 break;
477 class LootReportGenerator extends ReportGenerator{
478 function LootReportGenerator($type='')
480 global $dDB;
481 $this->db = &$dDB;
482 $this->db_fields = '*';
483 switch ($type){
484 default: $this->table = '`creature_loot_template`'; break;
487 function loadSubList($lootId, $table)
489 $fields= $this->db_fields;
490 $rows = $this->db->select("SELECT $fields FROM $table
491 WHERE `entry` = ?d
492 GROUP BY IF (`mincountOrRef` < 0, `mincountOrRef`, `item`)
493 ORDER BY `groupid`, `ChanceOrQuestChance`>0, ABS(`ChanceOrQuestChance`) DESC", $lootId);
494 if (!$rows)
495 return 0;
496 foreach($rows as &$loot)
498 // Group chance
499 if ($loot['ChanceOrQuestChance'] == 0)
501 $group = $loot['groupid'];
502 $chance = 0; $n = 0;
503 foreach($rows as &$g)
504 if ($g['groupid'] == $group)
506 if ($g['ChanceOrQuestChance']>0) $chance+=$g['ChanceOrQuestChance'];
507 else $n++;
509 $chance = round((100 - $chance) / $n, 3);
510 foreach($rows as &$g)
511 if ($g['groupid'] == $group && $g['ChanceOrQuestChance']==0)
512 $g['ChanceOrQuestChance'] =$chance;
514 if ($loot['mincountOrRef'] < 0)
516 // Получаем список
517 $loot['item'] = $this->loadSubList(-$loot['mincountOrRef'], 'reference_loot_template');
518 $loot['maxcount'] = $this->db->selectCell("SELECT count(*) FROM $table WHERE `entry` = ?d AND `mincountOrRef` = ?d", $lootId, $loot['mincountOrRef']);
521 return $rows;
523 function getLootList($lootId)
525 $this->total_data = 0;
526 $this->data_array = $this->loadSubList($lootId, $this->table);
528 function renderSubList($lootList)
530 global $Quality, $lang;
531 if (!$lootList)
532 return;
533 $curloot = -1;
534 foreach ($lootList as $loot)
536 $gtext = "";
537 if ($loot['groupid']!=$curloot)
539 echo "<tr><th colspan = 4>$lang[kill_kredit_group]&nbsp;$loot[groupid]</th></tr>";
540 $curloot = $loot['groupid'];
542 echo "<tr>";
543 if ($loot['mincountOrRef'] > 0)
545 if ($item = getItem($loot['item'],"`entry`, `Quality`, `name`, `displayid`"))
547 echo '<td class=i_ico>';r_itemIcon($item);echo '</td>';
548 echo '<td class=left>';r_itemName($item);echo '</td>';
550 else
551 echo "<td>-</td><td>$lang[item_not_found]&nbsp;$loot[item]</td>";
553 else // Используется список вещей (падает только одна вещь из списка)
555 echo "<td>".$loot['maxcount']."x</td>";
556 echo "<td class=forsub>$gtext<table class=sublist><tbody>";
557 $this->renderSubList($loot['item']);
558 echo "</tbody></table></td>";
560 if ($loot['lootcondition']){echo '<td>'; r_lootRequire($loot); echo '</td>';}
561 else echo '<td></td>';
562 if ($loot['ChanceOrQuestChance'] < 0) echo "<td align=center>Q".(-$loot['ChanceOrQuestChance'])."%</td>";
563 else if ($loot['ChanceOrQuestChance'] > 0) echo "<td align=center>".$loot['ChanceOrQuestChance']."%</td>";
564 echo "</tr>";
567 function createReport($header)
569 global $lang;
570 if (!$this->data_array)
571 return;
572 if ($this->ajax_mode==0)
573 echo '<div id="'.$this->mark.'">';
574 echo '<table class=report width=500>';
575 echo '<tbody>';
576 echo '<tr><td colspan=4 class=head>'.$header.'</td></tr>';
577 echo '<tr><th width=1%></th><th>'.$lang['item_name'].'</th><th></th><th>'.$lang['drop'].'%</th></tr>';
578 $this->renderSubList($this->data_array);
579 echo '</tbody></table>';
580 if ($this->ajax_mode==0)
582 echo '</div>';
583 // Cache data
584 $link = $this->createLink($this->page, $this->sort_method);
585 echo "<script type=\"text/javascript\">ajaxCacheHtmlId('$this->mark','$link');</script>";
590 //=================================================================
591 // Item report functions and methods
592 //=================================================================
593 function r_itemIcon($data) {echo text_show_item($data['entry'], $data['displayid']);}
594 function r_itemName($data)
596 global $Quality;
597 echo '<a class="'.$Quality[$data['Quality']].'" href="?item='.$data['entry'].'">'.(@$data['name_loc']?$data['name_loc']:$data['name']).'</a>';
599 function r_itemLevel($data) {echo $data['ItemLevel'];}
600 function r_itemReqLevel($data){echo $data['RequiredLevel'];}
601 function r_itemGemProp($data) {echo ($data['GemProperties']?getGemProperties($data['GemProperties']):'n/a');}
602 function r_itemArmor($data) {echo $data['armor'];}
603 function r_itemBlock($data) {echo $data['block'];}
604 function r_itemDPS($data) {echo $data['dps'] != 0 ? number_format($data['dps'], 2, '.', ''):'n/a';}
605 function r_itemAmmoDPS($data) {echo $data['adps'] != 0 ? number_format($data['adps'], 2, '.', ''):'n/a';}
606 function r_itemSpeed($data) {echo number_format($data['delay']/1000.00, 2, '.', '');}
607 function r_itemSlots($data) {echo $data['ContainerSlots'].' slot';}
608 function r_itemDesc($data) {echo (@$data['description_loc']?$data['description_loc']:$data['description']);}
609 function r_itemSClass($data) {echo getSubclassName($data['class'], $data['subclass'], 0);}
610 function r_itemInvType($data) {echo getInventoryType($data['InventoryType'], 0);}
611 function r_itemRecipe($data) {$ritem = getRecipeItem($data); echo ($ritem ? text_show_item($ritem['entry'], $ritem['displayid']):'-');}
612 function r_itemSpells($data)
614 global $UseorEquip;
615 for ($i=1;$i<=5;$i++)
617 if ($id = $data['spellid_'.$i])
618 if ($desc = get_spell_details($id))
619 echo '<a href="?spell='.$id.'">'.$UseorEquip[$data['spelltrigger_'.$i]].' '.$desc.'</a><br>';
622 function r_itemRepRank($data) {echo $data['RequiredReputationFaction']?getReputationRankName($data['RequiredReputationRank']):'n/a';}
623 function r_itemFlag($data) {echo dechex($data['Flags']);}
625 // Vendor
626 function r_vendorCost($data)
628 $flags2 = getItemFlags2($data['entry']);
629 if ($data['ExtendedCost']>0)
631 $cost = getExtendCost($data['ExtendedCost']);
632 if ($flags2&ITEM_FLAGS2_EXT_COST_REQUIRES_GOLD)
633 echo money($data['BuyPrice']).''.r_excostCost($cost);
634 else
635 r_excostCost($cost);
637 else
638 echo money($data['BuyPrice']);
640 function r_vendorCount($data) {echo $data['sold_count']?$data['sold_count']:'∞';}
641 function r_vendorTime($data) {echo $data['incrtime']?getTimeText($data['incrtime']):'';}
643 // NPC report generator config
644 $item_report = array(
645 'ITEM_REPORT_ICON' =>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemIcon', 'sort_str'=>'', 'fields'=>'`displayid`' ),
646 'ITEM_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['item_name'], 'draw'=>'r_itemName', 'sort_str'=>'`name`', 'fields'=>'`Quality`, `name`'),
647 'ITEM_REPORT_LEVEL' =>array('class'=>'small','sort'=>'i_level', 'text'=>$lang['item_level'], 'draw'=>'r_itemLevel', 'sort_str'=>'`ItemLevel` DESC, `name`', 'fields'=>'`ItemLevel`' ),
648 'ITEM_REPORT_REQLEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['item_req_level'], 'draw'=>'r_itemReqLevel', 'sort_str'=>'`RequiredLevel` DESC, `name`', 'fields'=>'`RequiredLevel`' ),
649 'ITEM_REPORT_GEMPROPETY' =>array('class'=>'left', 'sort'=>'gem_prop','text'=>$lang['item_gem_details'],'draw'=>'r_itemGemProp', 'sort_str'=>'`GemProperties`', 'fields'=>'`GemProperties`'),
650 'ITEM_REPORT_ARMOR' =>array('class'=>'', 'sort'=>'armor', 'text'=>$lang['item_armor'], 'draw'=>'r_itemArmor', 'sort_str'=>'`armor` DESC', 'fields'=>'`armor`'),
651 'ITEM_REPORT_BLOCK' =>array('class'=>'', 'sort'=>'block', 'text'=>$lang['item_block'], 'draw'=>'r_itemBlock', 'sort_str'=>'`block` DESC', 'fields'=>'`block`'),
652 '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`'),
653 '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`'),
654 'ITEM_REPORT_SPEED' =>array('class'=>'', 'sort'=>'speed', 'text'=>$lang['item_speed'], 'draw'=>'r_itemSpeed', 'sort_str'=>'`delay` DESC', 'fields'=>'`delay`'),
655 'ITEM_REPORT_NUM_SLOTS' =>array('class'=>'', 'sort'=>'bag_slot','text'=>$lang['item_slot_num'], 'draw'=>'r_itemSlots', 'sort_str'=>'`ContainerSlots` DESC', 'fields'=>'`ContainerSlots`'),
656 'ITEM_REPORT_DESCRIPTION'=>array('class'=>'left', 'sort'=>'desc', 'text'=>$lang['item_desc'], 'draw'=>'r_itemDesc', 'sort_str'=>'`description` DESC', 'fields'=>'`description`'),
657 'ITEM_REPORT_SUBCLASS' =>array('class'=>'', 'sort'=>'subclass','text'=>$lang['item_type'], 'draw'=>'r_itemSClass', 'sort_str'=>'`subclass` DESC', 'fields'=>'`class`, `subclass`'),
658 'ITEM_REPORT_SLOTTYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['item_slot'], 'draw'=>'r_itemInvType', 'sort_str'=>'`InventoryType` DESC', 'fields'=>'`InventoryType`'),
659 'ITEM_REPORT_RECIPE_ITEM'=>array('class'=>'i_ico','sort'=>'', 'text'=>'', 'draw'=>'r_itemRecipe', 'sort_str'=>'', 'fields'=>'`spellid_1`, `spellid_2`, `class`'),
660 '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`'),
661 'ITEM_REPORT_REQREP_RANK'=>array('class'=>'', 'sort'=>'rep_rank','text'=>$lang['item_faction_rank'],'draw'=>'r_itemRepRank', 'sort_str'=>'`RequiredReputationRank` DESC', 'fields'=>'`RequiredReputationFaction`, `RequiredReputationRank`'),
662 'ITEM_REPORT_FLAGS' =>array('class'=>'', 'sort'=>'', 'text'=>'flag', 'draw'=>'r_itemFlag', 'sort_str'=>'', 'fields'=>'`Flags`'),
663 // If set vendor class type
664 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `BuyPrice`', 'fields'=>'`ExtendedCost`, `BuyPrice`'),
665 '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`'),
666 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
667 // If set loot class type
668 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
669 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
672 // Item localisation flags (for allow disable some fields localisation if need)
673 define('ITEM_LOCALE_NAME', 0x01);
674 define('ITEM_LOCALE_DESCRIPTION', 0x02);
675 define('ITEM_LOCALE_ALL', ITEM_LOCALE_NAME | ITEM_LOCALE_DESCRIPTION);
677 // Item report class
678 class ItemReportGenerator extends ReportGenerator{
679 var $dolocale = ITEM_LOCALE_ALL;
680 function ItemReportGenerator($type='')
682 global $item_report, $dDB;
683 $this->db = &$dDB;
684 $this->column_conf =&$item_report;
685 $this->db_fields = '`item_template`.`entry`';
686 switch ($type){
687 case 'vendor' : $this->table = '(`item_template` join `npc_vendor` ON `item_template`.`entry` = `npc_vendor`.`item`)'; break;
688 case 'loot': $this->table = '(`item_loot_template` right join `item_template` ON `item_template`.`entry` = `item_loot_template`.`entry`)'; break;
689 case 'disenchant':$this->table = '(`disenchant_loot_template` right join `item_template` ON `item_template`.`DisenchantID` = `disenchant_loot_template`.`entry`)'; break;
690 case 'milling': $this->table = '(`milling_loot_template` right join `item_template` ON `item_template`.`entry` = `milling_loot_template`.`entry`)'; break;
691 case 'prospect': $this->table = '(`prospecting_loot_template` right join `item_template` ON `item_template`.`entry` = `prospecting_loot_template`.`entry`)'; break;
692 default: $this->table = '`item_template`'; break;
695 function disableNameLocalisation() {$this->dolocale &= ~ITEM_LOCALE_NAME;}
696 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
698 $tables .= ' LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry`';
699 if ($this->dolocale & ITEM_LOCALE_NAME)
701 $fields = str_replace('`name`','`name`, `locales_item`.`name_loc'.$locale.'` AS `name_loc`', $fields);
702 $sort_str = str_replace('`name`', '`name_loc`, `name`', $sort_str);
704 if ($this->dolocale & ITEM_LOCALE_DESCRIPTION)
706 $fields = str_replace('`description`','`description`, `locales_item`.`description_loc'.$locale."` AS `description_loc`", $fields);
707 $sort_str = str_replace('`description` DESC', '`description_loc` DESC, `name` DESC', $sort_str);
710 function vendorItemList($entry)
712 $this->doRequirest('`npc_vendor`.`entry` = ?d', $entry);
713 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
714 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
716 function useSpell($entry)
718 $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);
720 function recipeSpell($entry)
722 $this->doRequirest('`spellid_1` = 483 AND `spellid_2` = ?d', $entry);
724 function socketBonus($entry)
726 $this->doRequirest('`SocketBonus` = ?d', $entry);
728 function enchantByGems($entry)
730 global $wDB;
731 if ($list = $wDB->selectCol("SELECT `id` FROM `wowd_gemproperties` WHERE `spellitemenchantement` = ?d", $entry))
732 $this->doRequirest('`GemProperties` IN (?a)', $list);
734 function requireReputation($entry)
736 $this->doRequirest('`RequiredReputationFaction` = ?d', $entry);
738 function lootItem($entry)
740 $ref_loot =& getRefrenceItemLoot($entry);
741 $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));
742 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
746 //=================================================================
747 // Spell trainer list report functions and methods
748 //=================================================================
749 function r_trainerCost($data) {echo money($data['spellcost']);}
750 function r_trainerSpell($data)
752 if ($spell = getSpell($data['spell']))
754 if (!r_spellCreate($spell))
755 r_spellIcon($spell);
758 function r_trainerNSpell($data)
760 if ($spell = getSpell($data['spell']))
762 echo getSpellName($spell);
765 function r_trainerSkill($data) {if ($data['reqskill']) echo getSkillName($data['reqskill']);}
766 function r_trainerValue($data) {if ($data['reqskill']) echo $data['reqskillvalue'];}
767 function r_trainerSkillReq($data){if ($data['reqskill']) echo getSkillName($data['reqskill']).' ('.$data['reqskillvalue'].')';}
768 function r_trainerLevel($data) {echo $data['reqlevel']?$data['reqlevel']:'';}
770 $train_report = array(
771 'TRAIN_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['trainer_level'], 'draw'=>'r_trainerLevel', 'sort_str'=>'`reqlevel`, `reqskillvalue`', 'fields'=>'`reqlevel`' ),
772 'TRAIN_REPORT_ICON' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_trainerSpell', 'sort_str'=>'', 'fields'=>'`spell`' ),
773 'TRAIN_REPORT_NAME' =>array('class'=>'left', 'sort'=>'spell', 'text'=>$lang['trainer_spell'], 'draw'=>'r_trainerNSpell', 'sort_str'=>'`spell`', 'fields'=>'`spell`' ),
774 'TRAIN_REPORT_COST' =>array('class'=>'cost', 'sort'=>'cost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
775 'TRAIN_REPORT_SKILL' =>array('class'=>'small','sort'=>'skill','text'=>$lang['trainer_skill'], 'draw'=>'r_trainerSkill', 'sort_str'=>'`reqskill`', 'fields'=>'`reqskill`' ),
776 'TRAIN_REPORT_VALUE' =>array('class'=>'small','sort'=>'value','text'=>$lang['trainer_value'], 'draw'=>'r_trainerValue', 'sort_str'=>'`reqskillvalue`','fields'=>'`reqskillvalue`'),
779 class NPCTrainerReportGenerator extends ReportGenerator{
780 // Database depend requirest generator
781 // Select only reuire for report fields from database
782 function NPCTrainerReportGenerator($type='')
784 global $train_report, $dDB;
785 $this->db = &$dDB;
786 $this->column_conf =&$train_report;
787 $this->table = '`npc_trainer`';
788 $this->db_fields = '`entry`';
790 function trainSpell($entry)
792 $this->doRequirest('`entry` = ?d', $entry);
793 $this->removeIfAllZero('reqlevel', 'TRAIN_REPORT_LEVEL');
794 $this->removeIfAllZero('reqskill', 'TRAIN_REPORT_SKILL');
795 $this->removeIfAllZero('reqskillvalue', 'TRAIN_REPORT_VALUE');
799 //=================================================================
800 // Creature list report functions and methods
801 //=================================================================
802 function r_npcLvl($data)
804 echo $data['maxlevel'];
805 if ($data['rank'])
806 echo '<br><div class=rank>'.getCreatureRank($data['rank']).'</div>';
808 function r_npcName($data)
810 $h = getHeroicList();
811 $h1 = getHeroicList1();
812 $h2 = getHeroicList2();
813 if (isset($h[$data['entry']]))
815 $heroic = getCreature($h[$data['entry']]);
816 $data['name']=$heroic['name'].' (difficulty_1)';
817 $data['name_loc']=$heroic['name'].' (difficulty_1)';
818 $data['subname']=$heroic['subname'];
820 if (isset($h1[$data['entry']]))
822 $heroic = getCreature($h1[$data['entry']]);
823 $data['name']=$heroic['name'].' (difficulty_2)';
824 $data['name_loc']=$heroic['name'].' (difficulty_2)';
825 $data['subname']=$heroic['subname'];
827 if (isset($h2[$data['entry']]))
829 $heroic = getCreature($h2[$data['entry']]);
830 $data['name']=$heroic['name'].' (difficulty_3)';
831 $data['name_loc']=$heroic['name'].' (difficulty_3)';
832 $data['subname']=$heroic['subname'];
834 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
835 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
836 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a>';
837 if ($subname)
838 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
840 function r_npcRName($data)
842 $h = getHeroicList();
843 $h1 = getHeroicList1();
844 $h2 = getHeroicList2();
845 if (isset($h[$data['entry']]))
847 $heroic = getCreature($h[$data['entry']]);
848 $data['name']=$heroic['name'].' (difficulty_1)';
849 $data['name_loc']=$heroic['name'].' (difficulty_1)';
850 $data['subname']=$heroic['subname'];
852 if (isset($h1[$data['entry']]))
854 $heroic = getCreature($h1[$data['entry']]);
855 $data['name']=$heroic['name'].' (difficulty_2)';
856 $data['name_loc']=$heroic['name'].' (difficulty_2)';
857 $data['subname']=$heroic['subname'];
859 if (isset($h2[$data['entry']]))
861 $heroic = getCreature($h2[$data['entry']]);
862 $data['name']=$heroic['name'].' (difficulty_3)';
863 $data['name_loc']=$heroic['name'].' (difficulty_3)';
864 $data['subname']=$heroic['subname'];
866 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
867 $subname = @$data['subname_loc'] ? $data['subname_loc'] : $data['subname'];
868 echo '<a href="?npc='.$data['entry'].'">'.($name?$name:'no name').'</a> <font size=-3>('.getLoyality($data['faction_A']).')</font>';
869 if ($subname)
870 echo '<br><div class=subname><a href="?s=n&subname='.$subname.'">&lt;'.$subname.'&gt;</a></div>';
872 function r_npcReact($data) {echo getLoyality($data['faction_A']);}
873 function r_npcMap($data)
875 global $lang;
876 $h = getHeroicList();
877 $h1 = getHeroicList1();
878 $h2 = getHeroicList2();
880 if (isset($h2[$data['entry']]))
881 echo '<a href="?map&npc='.$h2[$data['entry']].'">'.$lang['map'].'</a>';
882 else
883 if (isset($h1[$data['entry']]))
884 echo '<a href="?map&npc='.$h1[$data['entry']].'">'.$lang['map'].'</a>';
885 else
886 if (isset($h[$data['entry']]))
887 echo '<a href="?map&npc='.$h[$data['entry']].'">'.$lang['map'].'</a>';
888 else
889 echo '<a href="?map&npc='.$data['entry'].'">'.$lang['map'].'</a>';
891 function r_npcRole($data)
893 $flag = $data['npcflag'];
894 if ($flag == 0) {return;}
895 if ($flag&0x00000001) echo '<img src=images/map_points/gossip_icon.png>';
896 if ($flag&0x00000002 && getNpcQuestrelation($data['entry'])) echo '<img src=images/map_points/available_quest_icon.gif>';
897 if ($flag&0x00000002 && getNpcInvolvedrelation($data['entry'])) echo '<img src=images/map_points/active_quest_icon.gif>';
898 if ($flag&0x00000070) echo '<img src=images/map_points/trainer_icon.gif>';
899 if ($flag&0x00000F80) echo '<img src=images/map_points/vendor_icon.gif>';
900 // if ($flag&0x00001000) echo '<img src=images/map_points/repair.gif>';
901 if ($flag&0x00002000) echo '<img src=images/map_points/taxi_icon.gif>';
902 if ($flag&0x00010000) echo '<img src=images/map_points/inn_icon.png>';
903 if ($flag&0x00820000) echo '<img src=images/map_points/banker_icon.gif>';
904 if ($flag&0x00100000) echo '<img src=images/map_points/battle_master_icon.gif>';
905 if ($flag&0x00200000) echo '<img src=images/map_points/banker_icon.gif>';
906 if ($flag&0x000C0000) echo '<img src=images/map_points/tabard_icon.gif>';
908 define('UNIT_NPC_FLAG_SPIRITHEALER', 0x00004000);
909 define('UNIT_NPC_FLAG_SPIRITGUIDE', 0x00008000);
910 define('UNIT_NPC_FLAG_STABLEMASTER', 0x00400000);*/
912 function r_OnKillRep($data)
914 $creature_rate1 = getCreatureRewRate($data['RewOnKillRepFaction1']);
915 $creature_rate2 = getCreatureRewRate($data['RewOnKillRepFaction2']);
916 if ($data['RewOnKillRepFaction1'])
918 echo ($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1.' '.getFactionName($data['RewOnKillRepFaction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
919 $spillover=getRepSpillover($data['RewOnKillRepFaction1']);
920 if ($spillover)
921 foreach ($spillover as $faction)
923 if ($faction['faction1'])
924 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding1']).')';
925 if ($faction['faction2'])
926 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding1']).')';
927 if ($faction['faction3'])
928 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding1']).')';
929 if ($faction['faction4'])
930 echo '<br>'.($data['RewOnKillRepValue1']>0?'+':'').$data['RewOnKillRepValue1']*$creature_rate1*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding1']).')';
933 if ($data['RewOnKillRepFaction2'])
935 if ($data['RewOnKillRepFaction1'] == 0)
936 echo ($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
937 else
938 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2.' '.getFactionName($data['RewOnKillRepFaction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
939 $spillover=getRepSpillover($data['RewOnKillRepFaction2']);
940 if ($spillover)
941 foreach ($spillover as $faction)
943 if ($faction['faction1'])
944 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_1'].' '.getFactionName($faction['faction1']).' ('.getReputationRankName($data['MaxStanding2']).')';
945 if ($faction['faction2'])
946 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_2'].' '.getFactionName($faction['faction2']).' ('.getReputationRankName($data['MaxStanding2']).')';
947 if ($faction['faction3'])
948 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_3'].' '.getFactionName($faction['faction3']).' ('.getReputationRankName($data['MaxStanding2']).')';
949 if ($faction['faction4'])
950 echo '<br>'.($data['RewOnKillRepValue2']>0?'+':'').$data['RewOnKillRepValue2']*$creature_rate2*$faction['rate_4'].' '.getFactionName($faction['faction4']).' ('.getReputationRankName($data['MaxStanding2']).')';
954 // NPC report generator config
955 $npc_report = array(
956 'NPC_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level','text'=>$lang['creature_level'], 'draw'=>'r_npcLvl', 'sort_str'=>'`maxlevel` DESC, `name`', 'fields'=>'`maxlevel`, `rank`'),
957 '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`'),
958 'NPC_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcName', 'sort_str'=>'`name`', 'fields'=>'`name`, `subname`' ),
959 'NPC_REPORT_RNAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['creature_name'], 'draw'=>'r_npcRName','sort_str'=>'`name`', 'fields'=>'`name`, `subname`, `faction_A`' ),
960 'NPC_REPORT_REACTION'=>array('class'=>'small','sort'=>'', 'text'=>$lang['creature_react'], 'draw'=>'r_npcReact','sort_str'=>'', 'fields'=>'`faction_A`'),
961 'NPC_REPORT_ROLE' =>array('class'=>'', 'sort'=>'role', 'text'=>$lang['creature_role'], 'draw'=>'r_npcRole', 'sort_str'=>'`npcflag` DESC', 'fields'=>'`npcflag`'),
962 'NPC_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_npcMap', 'sort_str'=>'', 'fields'=>''),
963 // vendor
964 'VENDOR_REPORT_COST' =>array('class'=>'', 'sort'=>'cost', 'text'=>$lang['item_cost'], 'draw'=>'r_vendorCost', 'sort_str'=>'`ExtendedCost`, `name`', 'fields'=>'`ExtendedCost`'),
965 '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`'),
966 'VENDOR_REPORT_INCTIME'=>array('class'=>'', 'sort'=>'time', 'text'=>$lang['item_incrtime'], 'draw'=>'r_vendorTime', 'sort_str'=>'`incrtime`, `name`', 'fields'=>'`incrtime`'),
967 // trainer
968 'TRAINER_REPORT_COST' =>array('class'=>'', 'sort'=>'scost', 'text'=>$lang['trainer_cost'], 'draw'=>'r_trainerCost', 'sort_str'=>'`spellcost`', 'fields'=>'`spellcost`'),
969 'TRAINER_REPORT_SPELL'=>array('class'=>'left','sort'=>'', 'text'=>$lang['trainer_spell'],'draw'=>'r_trainerSpell','sort_str'=>'', 'fields'=>'`spell`'),
970 'TRAINER_REPORT_SKILL'=>array('class'=>'', 'sort'=>'skill', 'text'=>$lang['trainer_skill'],'draw'=>'r_trainerSkillReq','sort_str'=>'`reqskill`, `reqskillvalue`','fields'=>'`reqskill`, `reqskillvalue`'),
971 'TRAINER_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'slevel','text'=>$lang['trainer_level'],'draw'=>'r_trainerLevel','sort_str'=>'`reqlevel`', 'fields'=>'`reqlevel`'),
972 // loot
973 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
974 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
975 // reputation
976 '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`'),
979 define('NPC_LOCALE_NAME', 0x01);
980 define('NPC_LOCALE_SUBNAME', 0x02);
981 define('NPC_LOCALE_ALL', NPC_LOCALE_NAME | NPC_LOCALE_SUBNAME);
983 // Creature report class
984 class CreatureReportGenerator extends ReportGenerator{
985 var $dolocale = NPC_LOCALE_ALL;
986 function CreatureReportGenerator($type = '')
988 global $npc_report, $dDB;
989 $this->db = &$dDB;
990 $this->column_conf =&$npc_report;
991 $this->db_fields = '`creature_template`.`entry`';
992 switch ($type) {
993 case 'vendor': $this->table = '(`creature_template` join `npc_vendor` ON `creature_template`.`entry` = `npc_vendor`.`entry`)'; break;
994 case 'trainer':$this->table = '(`creature_template` join `npc_trainer` ON `creature_template`.`entry` = `npc_trainer`.`entry`)'; break;
995 case 'loot': $this->table = '(`creature_template` join `creature_loot_template` ON `creature_template`.`lootid` = `creature_loot_template`.`entry`)'; break;
996 case 'pick': $this->table = '(`creature_template` join `pickpocketing_loot_template` ON `creature_template`.`pickpocketloot` = `pickpocketing_loot_template`.`entry`)'; break;
997 case 'skin': $this->table = '(`creature_template` join `skinning_loot_template` ON `creature_template`.`skinloot` = `skinning_loot_template`.`entry`)'; break;
998 case 'position':$this->table ='(`creature_template` join `creature` ON `creature_template`.`entry` = `creature`.`id`)'; break;
999 case 'reputation':$this->table ='(`creature_template` join `creature_onkill_reputation` ON `creature_template`.`entry` = `creature_onkill_reputation`.`creature_id`)'; break;
1000 default: $this->table = '`creature_template`'; break;
1003 function disableNameLocalisation() {$this->dolocale &= ~NPC_LOCALE_NAME;}
1004 function disableSubnameLocalisation() {$this->dolocale &= ~NPC_LOCALE_SUBNAME;}
1005 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1007 $tables.=' LEFT JOIN `locales_creature` ON `creature_template`.`entry` = `locales_creature`.`entry`';
1008 if ($this->dolocale & NPC_LOCALE_NAME)
1010 $fields = str_replace('`name`','`name`, `locales_creature`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1011 $sort_str = str_replace('`name`','`name_loc`, `name`', $sort_str);
1013 if ($this->dolocale & NPC_LOCALE_SUBNAME)
1015 $fields = str_replace('`subname`','`subname`, `locales_creature`.`subname_loc'.$locale.'` AS `subname_loc`', $fields);
1016 $sort_str = str_replace('`subname`','`subname_loc`, `subname`', $sort_str);
1019 function castSpell($entry)
1021 global $dDB;
1022 $rows_1 = $dDB->selectCol('SELECT `entry` FROM `creature_template` WHERE `spell1` = ?d OR `spell2` = ?d OR `spell3` = ?d OR `spell4` = ?d', $entry, $entry, $entry, $entry);
1023 $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);
1024 $casters = array_unique(array_merge($rows_1, $rows_2));
1025 if (count($casters))
1026 $this->doRequirest('`creature_template`.`entry` in (?a)', $casters);
1028 function inFaction($entry)
1030 global $wDB;
1031 if ($templatesId =& getFactionTemplates($entry))
1032 $this->doRequirest('`faction_A` in (?a) OR `faction_H` in (?a)', $templatesId, $templatesId);
1034 function soldItem($entry, $price)
1036 $this->db_fields.=', '.$price.' AS `BuyPrice`';
1037 $this->doRequirest('`item` = ?d', $entry);
1038 $this->removeIfAllZero('sold_count', 'VENDOR_REPORT_COUNT');
1039 $this->removeIfAllZero('incrtime', 'VENDOR_REPORT_INCTIME');
1041 function trainSpell($entry)
1043 $this->doRequirest('`spell` = ?d', $entry);
1044 $this->removeIfAllZero('reqskill', 'TRAINER_REPORT_SKILL');
1046 function kreditGroup($entry)
1048 $this->doRequirest('`KillCredit1` = ?d OR `KillCredit2` = ?d', $entry, $entry);
1050 function lootItem($entry)
1052 $ref_loot =& getRefrenceItemLoot($entry);
1053 $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));
1054 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1056 // Position
1057 function onMap($entry)
1059 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1061 function onArea($area_data)
1063 $this->setManualPagenateMode();
1064 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1065 $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]);
1066 $setId = array();
1067 foreach($this->data_array as $id=>$c)
1069 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1070 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1071 unset($this->data_array[$id]);
1072 else
1073 $setId[$c['entry']] = 1;
1076 // Reputation
1077 function rewardFactionReputation($id)
1079 $this->doRequirest('`RewOnKillRepFaction1` = ?d OR `RewOnKillRepFaction2` = ?d', $id, $id);
1081 function rewardNpcFactionReputation($entry)
1083 $this->doRequirest('`creature_id` = ?d', $entry);
1087 //=================================================================
1088 // Gameobject list report functions and methods
1089 //=================================================================
1090 function r_objName($data)
1092 $name = @$data['name_loc'] ? $data['name_loc'] : $data['name'];
1093 echo '<a href="?object='.$data['entry'].'">'.($name?$name:'no name').'</a>';
1095 function r_objType($data) {echo getGameobjectType($data['type'], 0);}
1096 function r_objMap($data) {global $lang; echo '<a href="?map&obj='.$data['entry'].'">'.$lang['map'].'</a>';}
1098 // GO report generator config
1099 $go_report = array(
1100 'GO_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['go_name'], 'draw'=>'r_objName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1101 'GO_REPORT_TYPE' =>array('class'=>'', 'sort'=>'type', 'text'=>$lang['go_type'], 'draw'=>'r_objType', 'sort_str'=>'`type`', 'fields'=>'`type`'),
1102 'GO_REPORT_MAP' =>array('class'=>'small','sort'=>'', 'text'=>$lang['map'], 'draw'=>'r_objMap', 'sort_str'=>'', 'fields'=>''),
1103 // loot
1104 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `name`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1105 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
1108 define('GO_LOCALE_NAME', 0x01);
1109 define('GO_LOCALE_ALL', NPC_LOCALE_NAME);
1111 // GO report class
1112 class GameobjectReportGenerator extends ReportGenerator{
1113 var $dolocale = GO_LOCALE_ALL;
1114 function GameobjectReportGenerator($type = '')
1116 global $go_report, $dDB;
1117 $this->db = &$dDB;
1118 $this->column_conf =&$go_report;
1119 $this->db_fields = '`gameobject_template`.`entry`';
1120 switch ($type) {
1121 case 'loot':
1122 $this->table =
1123 '(`gameobject_template`
1124 join
1125 `gameobject_loot_template`
1127 `gameobject_template`.`data1` = `gameobject_loot_template`.`entry` AND
1128 `gameobject_template`.`type` IN (3, 17, 25))';
1129 break;
1130 case 'position':$this->table ='(`gameobject_template` join `gameobject` ON `gameobject_template`.`entry` = `gameobject`.`id`)';break;
1131 default: $this->table = '`gameobject_template`';break;
1134 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1135 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1137 $tables.= ' LEFT JOIN `locales_gameobject` ON `gameobject_template`.`entry` = `locales_gameobject`.`entry`';
1138 if ($this->dolocale & GO_LOCALE_NAME)
1140 $fields = str_replace('`name`', '`name`, `locales_gameobject`.`name_loc'.$locale.'` AS `name_loc`', $fields);
1141 $sort_str= str_replace('`name`', '`name_loc`, `name`', $sort_str);
1143 $fields = str_replace('`castbarcaption`','`castbarcaption`, `locales_gameobject`.`castbarcaption_loc'.$locale.'` AS `castbarcaption_loc`', $fields);
1145 function castSpell($entry)
1147 $this->doRequirest(
1148 '(`type` = ?d AND `data3` = ?d) OR
1149 (`type` = ?d AND `data10` = ?d) OR
1150 (`type` = ?d AND `data1` = ?d) OR
1151 (`type` = ?d AND `data0` = ?d) OR
1152 (`type` = ?d AND (`data2` = ?d OR `data3` = ?d))',
1153 GAMEOBJECT_TYPE_TRAP, $entry,
1154 GAMEOBJECT_TYPE_GOOBER, $entry,
1155 GAMEOBJECT_TYPE_SUMMONING_RITUAL, $entry,
1156 GAMEOBJECT_TYPE_SPELLCASTER, $entry,
1157 GAMEOBJECT_TYPE_AURA_GENERATOR, $entry, $entry);
1159 function inFaction($entry)
1161 global $wDB;
1162 if ($templatesId =& getFactionTemplates($entry))
1163 $this->doRequirest('`faction` in (?a)', $templatesId);
1165 function spellFocus($entry)
1167 $this->doRequirest('`type` = ?d AND `data0` = ?d', GAMEOBJECT_TYPE_SPELL_FOCUS, $entry);
1169 function lootItem($entry)
1171 $ref_loot =& getRefrenceItemLoot($entry);
1172 $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));
1173 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1175 // Position
1176 function onMap($entry)
1178 $this->doRequirest('`map` = ?d GROUP BY `id`', $entry);
1180 function onArea($area_data)
1182 $this->setManualPagenateMode();
1183 $this->addFieldsRequirest('`map`, `position_x`, `position_y`, `position_z`');
1184 $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]);
1185 $setId = array();
1186 foreach($this->data_array as $id=>$c)
1188 $zone = getZoneFromPoint($c['map'], $c['position_x'], $c['position_y'], $c['position_z']);
1189 if ($zone!=$area_data[1] || isset($setId[$c['entry']]))
1190 unset($this->data_array[$id]);
1191 else
1192 $setId[$c['entry']] = 1;
1197 //=================================================================
1198 // Quest list report functions and methods
1199 //=================================================================
1200 function r_questLvl($data) {echo $data['QuestLevel'];}
1201 function r_questReqLvl($data) {echo $data['MinLevel'];}
1202 function r_questName($data)
1204 global $lang;
1205 $name = @$data['Title_loc']?$data['Title_loc']:$data['Title'];
1206 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 1101) && ($data['RequiredRaces'] !=1791))
1207 echo "<img width=22 height=22 src='images/player_info/factions_img/alliance.gif'>&nbsp;";
1208 if (getAllowableRace($data['RequiredRaces']) && ($data['RequiredRaces'] & 690) && ($data['RequiredRaces'] !=1791))
1209 echo "<img width=22 height=22 src='images/player_info/factions_img/horde.gif'>&nbsp;";
1210 echo '<a href="?quest='.$data['entry'].'">'.($name?$name:'no name').'</a><br>';
1211 if ($data['ZoneOrSort']>0)
1212 echo '<div class=areaname><a href="?s=q&ZoneID='.$data['ZoneOrSort'].'">'.getAreaName($data['ZoneOrSort']).'</a></div>';
1213 else
1214 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
1215 (-$data['ZoneOrSort']) == 284 OR (-$data['ZoneOrSort']) == 25 OR (-$data['ZoneOrSort']) == 41 OR (-$data['ZoneOrSort']) < 24))
1216 echo '<div class=areaname><a href="?s=q&SortID='.(-$data['ZoneOrSort']).'">'.getQuestSort(-$data['ZoneOrSort']).'</a></div>';
1217 if ($data['RequiredClasses'])
1218 echo '<div class=classqname>'.getQAllowableClass($data['RequiredClasses']).'</div>';
1219 if ($data['RequiredSkill'])
1220 echo '<div class=areaname><a href="?s=q&SkillID='.($data['RequiredSkill']).'">'.getSkillName($data['RequiredSkill'], 0).'('.$data['RequiredSkillValue'].')</a></div>';
1221 if ($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY)
1222 echo '<div class=areaname><a href="?s=q&Sfm='.($data['SpecialFlags']).'">'.$lang['quest_type3'].'</a></div>';
1223 if ($data['QuestFlags'] & QUEST_FLAGS_WEEKLY)
1224 echo '<div class=areaname><a href="?s=q&Sfw='.($data['QuestFlags']).'">'.$lang['quest_type2'].'</a></div>';
1225 if ($data['QuestFlags'] & QUEST_FLAGS_DAILY)
1226 echo '<div class=areaname><a href="?s=q&Sfd='.($data['QuestFlags']).'">'.$lang['quest_type1'].'</a></div>';
1227 if (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_REPEATABLE) && (($data['SpecialFlags'] & QUEST_SPECIAL_FLAG_MONTHLY) ==0) && ($data['QuestFlags'] & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY)) == 0)
1228 echo '<div class=areaname><a href="?s=q&Sfr='.($data['SpecialFlags']).'">'.$lang['quest_type0'].'</a></div>';
1230 function r_questGiver($data)
1232 global $dDB;
1233 // Search creature quest giver
1234 if ($src = $dDB->select(
1235 'SELECT `entry`, `name`, `subname`, `faction_A`
1236 FROM `creature_template` left join `creature_questrelation` ON `creature_template`.`entry` = `creature_questrelation`.`id`
1237 WHERE `creature_questrelation`.`quest` = ?d', $data['entry']))
1239 foreach ($src as $creature){localiseCreature($creature);r_npcRName($creature);}
1240 return;
1242 // Search GO quest giver
1243 if ($src = $dDB->select(
1244 'SELECT `entry`, `name`
1245 FROM `gameobject_template` left join `gameobject_questrelation` ON `gameobject_template`.`entry` = `gameobject_questrelation`.`id`
1246 WHERE `gameobject_questrelation`.`quest` = ?d', $data['entry']))
1248 foreach ($src as $go) {localiseGameobject($go); r_objName($go);}
1249 return;
1251 // Search item quest giver
1252 if ($src = $dDB->select("SELECT `entry`, `name`, `Quality` FROM `item_template` WHERE `startquest` = ?d", $data['entry']))
1254 foreach ($src as $item) {localiseItem($item);r_itemName($item);}
1255 return;
1257 echo '---(?)---';
1259 function r_questReward($quest)
1261 global $lang;
1262 if ($quest['RewItemId1'] OR $quest['RewItemId2'] OR $quest['RewItemId3'] OR $quest['RewItemId4'])
1264 // echo $lang['Rew_item'].'<br>';
1265 if ($quest['RewItemId1']) echo text_show_item($quest['RewItemId1'], 0, 'quest');
1266 if ($quest['RewItemId2']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId2'], 0, 'quest');
1267 if ($quest['RewItemId3']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId3'], 0, 'quest');
1268 if ($quest['RewItemId4']) echo $lang['item_sel_and'].text_show_item($quest['RewItemId4'], 0, 'quest');
1269 echo '<br>';
1271 if ($quest['RewChoiceItemId1'] OR $quest['RewChoiceItemId2'] OR $quest['RewChoiceItemId3'] OR
1272 $quest['RewChoiceItemId4'] OR $quest['RewChoiceItemId5'] OR $quest['RewChoiceItemId6'])
1274 echo $lang['Rew_select_item'].'<br>';
1275 if ($quest['RewChoiceItemId1']) echo text_show_item($quest['RewChoiceItemId1'], 0, 'quest');
1276 if ($quest['RewChoiceItemId2']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId2'], 0, 'quest');
1277 if ($quest['RewChoiceItemId3']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId3'], 0, 'quest');
1278 if ($quest['RewChoiceItemId4']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId4'], 0, 'quest');
1279 if ($quest['RewChoiceItemId5']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId5'], 0, 'quest');
1280 if ($quest['RewChoiceItemId6']) echo $lang['item_sel_or'].text_show_item($quest['RewChoiceItemId6'], 0, 'quest');
1281 echo "<br>";
1283 if ($quest['RewSpell'] AND $quest['RewSpellCast'])
1285 show_spell($quest['RewSpell'], 0, 'quest');
1286 echo '<br>';
1288 if (!$quest['RewSpell'] AND $quest['RewSpellCast'])
1290 show_spell($quest['RewSpellCast'], 0, 'quest');
1291 echo '<br>';
1293 for ($i = 1; $i <= 5; $i++)
1295 switch (ABS($quest['RewRepValueId'.$i])):
1296 case 1: $RepValueId[$i] = 10; break;
1297 case 2: $RepValueId[$i] = 25; break;
1298 case 3: $RepValueId[$i] = 75; break;
1299 case 4: $RepValueId[$i] = 150; break;
1300 case 5: $RepValueId[$i] = 250; break;
1301 case 6: $RepValueId[$i] = 350; break;
1302 case 7: $RepValueId[$i] = 500; break;
1303 case 8: $RepValueId[$i] = 1000; break;
1304 case 9: $RepValueId[$i] = 5; break;
1305 default: $RepValueId[$i] = 0;
1306 endswitch;
1308 $quest_rate[$i] = getRepRewRate($quest['RewRepFaction'.$i]);
1310 if ($quest['RewRepValueId'.$i] < 0)
1311 $RepValueId[$i] = -$RepValueId[$i];
1313 if ($quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1314 $quest['RewRepValue'.$i] = $quest['RewRepValue'.$i]/100;
1316 if (!$quest['RewRepValue'.$i] && $quest['RewRepValueId'.$i])
1317 $quest['RewRepValue'.$i] = $RepValueId[$i];
1319 $quest['RewRepValue'.$i]=$quest['RewRepValue'.$i]*$quest_rate[$i];
1322 if ($quest['RewRepFaction1'] AND !$quest['RewRepFaction2'] AND
1323 !$quest['RewRepFaction3'] AND !$quest['RewRepFaction4'] AND
1324 !$quest['RewRepFaction5'])
1326 $spillover=getRepSpillover($quest['RewRepFaction1']);
1327 if ($spillover)
1328 foreach ($spillover as $faction)
1330 if ($faction['faction1'])
1332 $quest['RewRepFaction2']=$faction['faction1'];
1333 $quest['RewRepValue2']=$quest['RewRepValue1']*$faction['rate_1'];
1335 if ($faction['faction2'])
1337 $quest['RewRepFaction3']=$faction['faction2'];
1338 $quest['RewRepValue3']=$quest['RewRepValue1']*$faction['rate_2'];
1340 if ($faction['faction3'])
1342 $quest['RewRepFaction4']=$faction['faction3'];
1343 $quest['RewRepValue4']=$quest['RewRepValue1']*$faction['rate_3'];
1345 if ($faction['faction4'])
1347 $quest['RewRepFaction5']=$faction['faction4'];
1348 $quest['RewRepValue5']=$quest['RewRepValue1']*$faction['rate_4'];
1353 if ($quest['RewRepFaction1'] && $quest['RewRepValue1'])echo getFactionName($quest['RewRepFaction1']).': '.$quest['RewRepValue1'].'<br>';
1354 if ($quest['RewRepFaction2'] && $quest['RewRepValue2'])echo getFactionName($quest['RewRepFaction2']).': '.$quest['RewRepValue2'].'<br>';
1355 if ($quest['RewRepFaction3'] && $quest['RewRepValue3'])echo getFactionName($quest['RewRepFaction3']).': '.$quest['RewRepValue3'].'<br>';
1356 if ($quest['RewRepFaction4'] && $quest['RewRepValue4'])echo getFactionName($quest['RewRepFaction4']).': '.$quest['RewRepValue4'].'<br>';
1357 if ($quest['RewRepFaction5'] && $quest['RewRepValue5'])echo getFactionName($quest['RewRepFaction5']).': '.$quest['RewRepValue5'].'<br>';
1358 if ($quest['RewMoneyMaxLevel'])
1359 echo $lang['Rew_XP'].' '.getQuestXPValue($quest).' xp<br>';
1360 if ($quest['RewOrReqMoney'])
1361 echo $lang['Rew_money'].' '.money($quest['RewOrReqMoney'], 7).'<br>';
1364 $quest_reward_fields =
1365 '`RewXPId`, `RewChoiceItemId1`, `RewChoiceItemId2`, `RewChoiceItemId3`, `RewChoiceItemId4`, `RewChoiceItemId5`, `RewChoiceItemId6`,
1366 `RewChoiceItemCount1`, `RewChoiceItemCount2`, `RewChoiceItemCount3`, `RewChoiceItemCount4`, `RewChoiceItemCount5`, `RewChoiceItemCount6`,
1367 `RewItemId1`, `RewItemId2`, `RewItemId3`, `RewItemId4`, `RewItemCount1`, `RewItemCount2`, `RewItemCount3`, `RewItemCount4`,
1368 `RewRepFaction1`, `RewRepFaction2`, `RewRepFaction3`, `RewRepFaction4`, `RewRepFaction5`,
1369 `RewRepValue1`, `RewRepValue2`, `RewRepValue3`, `RewRepValue4`, `RewRepValue5`,
1370 `RewRepValueId1`, `RewRepValueId2`, `RewRepValueId3`, `RewRepValueId4`, `RewRepValueId5`,
1371 `RewOrReqMoney`, `RewMoneyMaxLevel`, `RewSpell`, `RewSpellCast`, `RewMailTemplateId`, `RewMailDelaySecs`';
1373 $quest_report = array(
1374 'QUEST_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['quest_lvl'], 'draw'=>'r_questLvl', 'sort_str'=>'`QuestLevel` DESC', 'fields'=>'`QuestLevel`' ),
1375 'QUEST_REPORT_REQLEVEL'=>array('class'=>'small','sort'=>'req_lvl','text'=>$lang['quest_reqlvl'], 'draw'=>'r_questReqLvl','sort_str'=>'`MinLevel` DESC', 'fields'=>'`MinLevel`' ),
1376 '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`'),
1377 'QUEST_REPORT_GIVER' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['quest_giver'], 'draw'=>'r_questGiver', 'sort_str'=>'', 'fields'=>''),
1378 'QUEST_REPORT_REWARD' =>array('class'=>'full', 'sort'=>'reward', 'text'=>$lang['quest_rewards'], 'draw'=>'r_questReward','sort_str'=>'`RewMoneyMaxLevel` DESC','fields'=>&$quest_reward_fields),
1379 // loot
1380 'LOOT_REPORT_CHANCE'=>array('class'=>'', 'sort'=>'chance', 'text'=>$lang['loot_chance'], 'draw'=>'r_lootChance', 'sort_str'=>'ABS(`ChanceOrQuestChance`) DESC, `Title`', 'fields'=>'`ChanceOrQuestChance`, `mincountOrRef`'),
1381 'LOOT_REPORT_REQ' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['loot_require'],'draw'=>'r_lootRequire','sort_str'=>'', 'fields'=>'`lootcondition`, `condition_value1`, `condition_value2`'),
1384 define('QUEST_LOCALE_NAME', 0x01);
1385 define('QUEST_LOCALE_ALL', NPC_LOCALE_NAME);
1387 // Quest report class
1388 class QuestReportGenerator extends ReportGenerator{
1389 var $dolocale = QUEST_LOCALE_ALL;
1390 function QuestReportGenerator($type='')
1392 global $quest_report, $dDB;
1393 $this->db = &$dDB;
1394 $this->column_conf =&$quest_report;
1395 switch ($type){
1396 case 'go_giver': $this->table = '(`quest_template` join `gameobject_questrelation` ON `quest_template`.`entry` = `gameobject_questrelation`.`quest`)';break;
1397 case 'go_take': $this->table = '(`quest_template` join `gameobject_involvedrelation` ON `quest_template`.`entry` = `gameobject_involvedrelation`.`quest`)';break;
1398 case 'npc_giver': $this->table = '(`quest_template` join `creature_questrelation` ON `quest_template`.`entry` = `creature_questrelation`.`quest`)';break;
1399 case 'npc_take': $this->table = '(`quest_template` join `creature_involvedrelation` ON `quest_template`.`entry` = `creature_involvedrelation`.`quest`)';break;
1400 case 'mail_loot': $this->table = '(`quest_template` join `mail_loot_template` ON `quest_template`.`RewMailTemplateId` = `mail_loot_template`.`entry`)';break;
1401 default: $this->table = '`quest_template`';break;
1403 $this->db_fields = '`quest_template`.`entry`';
1405 function disableNameLocalisation() {$this->dolocale &= ~GO_LOCALE_NAME;}
1406 function localiseRequirest($locale, &$tables, &$fields, &$sort_str)
1408 $tables.= ' LEFT JOIN `locales_quest` ON `quest_template`.`entry` = `locales_quest`.`entry`';
1409 if ($this->dolocale & QUEST_LOCALE_NAME)
1411 $fields = str_replace('`Title`', '`Title`, `locales_quest`.`Title_loc'.$locale.'` AS `Title_loc`', $fields);
1412 $sort_str = str_replace('`Title`', '`Title_loc`, `Title`', $sort_str);
1415 // Create quest givers/take list by entry
1416 function getGiveTakeList($entry)
1418 $this->doRequirest('`id` = ?d', $entry);
1420 // Create quest list require GO for comlete
1421 function requireGO($entry)
1423 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', -$entry, -$entry, -$entry, -$entry);
1425 // Create quest list require GO for comlete
1426 function requireCreature($entry)
1428 $this->doRequirest('`ReqCreatureOrGOId1`= ?d OR `ReqCreatureOrGOId2`= ?d OR `ReqCreatureOrGOId3`= ?d OR `ReqCreatureOrGOId4`= ?d', $entry, $entry, $entry, $entry);
1430 function oneQuest($entry)
1432 $this->doRequirest('`quest_template`.`entry` = ?d', $entry);
1434 // Create quest list require item for comlete
1435 function requireItem($entry, $giveQuest)
1437 $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);
1439 // Create quest list prowide item at take
1440 function provideItem($entry, $giveQuest)
1442 $this->doRequirest('`SrcItemId` = ?d AND `quest_template`.`entry` <> ?d', $entry, $giveQuest);
1444 // Create quest list reward item
1445 function rewardItem($entry)
1447 $this->doRequirest('`RewItemId1`= ?d OR `RewItemId2`= ?d OR `RewItemId3`= ?d OR `RewItemId4`= ?d OR
1448 `RewChoiceItemId1`= ?d OR`RewChoiceItemId2`= ?d OR `RewChoiceItemId3`= ?d OR `RewChoiceItemId4`= ?d OR `RewChoiceItemId5`= ?d OR `RewChoiceItemId6`= ?d',
1449 $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1451 // Create quest list cast/reward spell
1452 function rewardSpell($entry)
1454 $this->doRequirest('`RewSpell` = ?d OR `RewSpellCast` = ?d', $entry, $entry);
1456 // Return quest list where exist faction reputation reward
1457 function rewardReputation($entry)
1459 $this->doRequirest('`RewRepFaction1`= ?d OR `RewRepFaction2`= ?d OR `RewRepFaction3`= ?d OR `RewRepFaction4`= ?d OR `RewRepFaction5`= ?d', $entry, $entry, $entry, $entry, $entry);
1461 // Mail loot
1462 function lootItem($entry)
1464 $ref_loot =& getRefrenceItemLoot($entry);
1465 $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));
1466 $this->removeIfAllZero('lootcondition', 'LOOT_REPORT_REQ');
1471 //=================================================================
1472 // Spell list report functions and methods
1473 //=================================================================
1474 function r_spellLevel($data) {echo $data['spellLevel'];}
1475 function r_spellIcon($data) {show_spell($data['id'], $data['SpellIconID']);}
1476 function r_spellName($data)
1478 echo '<a href="?spell='.$data['id'].'">'.$data['SpellName'].'</a>';
1479 if ($data['Rank'])
1480 echo '<div class=srank>'.$data['Rank'].'</div>';
1482 function r_spellRecipe($data)
1484 r_spellName($data);
1485 if ($skilname = getSkillNameForSpell($data['id']))
1486 echo '<div class=srank>&lt;'.$skilname.'&gt;</div>';
1488 function r_spellSkill($data)
1490 global $lang;
1491 r_spellName($data);
1492 if ($data['RequiresSpellFocus'])
1493 echo '<div class=reqfocus>'.sprintf($lang['spell_req_focus'], getSpellFocusName($data['RequiresSpellFocus'], 2)).'</div>';
1494 if ($data['TotemCategory_1'] OR $data['TotemCategory_2'])
1496 $text= '';
1497 if ($data['TotemCategory_1']) $text = getTotemCategory($data['TotemCategory_1']);
1498 if ($data['TotemCategory_2']) $text.= ", ".getTotemCategory($data['TotemCategory_2']);
1499 echo '<div class=reqfocus>'.sprintf($lang['spell_req_totem'], $text).'</div>';
1502 function r_spellSchool($data){echo getSpellSchool($data['SchoolMask']);}
1503 function r_spellReagents($data)
1505 echo '<table class=reagents><tr>';
1506 for ($i=1;$i<9;$i++)
1507 if ($data['Reagent_'.$i])
1508 echo '<td>'.text_show_item($data['Reagent_'.$i],0,'reagent').'<br>x'.$data['ReagentCount_'.$i].'</td>';
1509 echo "</tr></table>";
1511 function r_spellCreate($data)
1513 if ($data['EffectItemType_1'] == 0 AND $data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1514 return 0;
1515 if ($data['EffectItemType_2'] == 0 AND $data['EffectItemType_3'] == 0)
1516 echo text_show_item($data['EffectItemType_1']);
1517 else
1519 echo '<table class=reagents><tr>';
1520 for ($i=1;$i<4;$i++)
1521 if ($data['EffectItemType_'.$i])
1522 echo '<td>'.text_show_item($data['EffectItemType_'.$i], 0, "reagent").($data['EffectBasePoints_'.$i]>0?'<br>x&nbsp;'.($data['EffectBasePoints_'.$i]+1):'').'</td>';
1523 echo '</tr></table>';
1525 return 1;
1527 function r_spellEquiped($data)
1529 echo $data['EquippedItemClass'].'<br />';
1530 echo $data['EquippedItemSubClassMask'].'<br />';
1531 echo $data['EquippedItemInventoryTypeMask'].'<br />';
1533 function r_skillLevel($data) {echo $data['min_value'];}
1534 function r_skillIcon($data)
1536 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1537 r_spellCreate($data);
1538 else
1539 r_spellIcon($data);
1541 $reagents= '`Reagent_1`, `Reagent_2`, `Reagent_3`, `Reagent_4`, `Reagent_5`, `Reagent_6`, `Reagent_7`, `Reagent_8`,
1542 `ReagentCount_1`, `ReagentCount_2`, `ReagentCount_3`, `ReagentCount_4`, `ReagentCount_5`, `ReagentCount_6`, `ReagentCount_7`, `ReagentCount_8`';
1543 // Spell report generator config
1544 $spell_report = array(
1545 'SPELL_REPORT_LEVEL' =>array('class'=>'small','sort'=>'level', 'text'=>$lang['spell_level'], 'draw'=>'r_spellLevel', 'sort_str'=>'`spellLevel`', 'fields'=>'`spellLevel`' ),
1546 'SPELL_REPORT_ICON' =>array('class'=>'s_ico','sort'=>'icon', 'text'=>'', 'draw'=>'r_spellIcon', 'sort_str'=>'`SpellIconID`', 'fields'=>'`SpellIconID`' ),
1547 'SPELL_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['spell_name'], 'draw'=>'r_spellName', 'sort_str'=>'`SpellName`, `id`','fields'=>'`SpellName`, `Rank`' ),
1548 '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`'),
1549 'SPELL_REPORT_SCHOOL'=>array('class'=>'', 'sort'=>'school','text'=>$lang['spell_school'], 'draw'=>'r_spellSchool', 'sort_str'=>'`SchoolMask`', 'fields'=>'`SchoolMask`' ),
1550 'SPELL_REPORT_REAGENTS'=>array('class'=>'reag','sort'=>'', 'text'=>$lang['spell_reagent'],'draw'=>'r_spellReagents','sort_str'=>'', 'fields'=>&$reagents),
1551 '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`'),
1552 'SPELL_REPORT_EQUIP'=>array('class'=>'left', 'sort'=>'', 'text'=>'', 'draw'=>'r_spellEquiped','sort_str'=>'', 'fields'=>'`EquippedItemClass`, `EquippedItemSubClassMask`, `EquippedItemInventoryTypeMask`'),
1553 // Skill
1554 '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`'),
1555 '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`' ),
1556 '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`'),
1559 // Spell report class
1560 class SpellReportGenerator extends ReportGenerator{
1561 function SpellReportGenerator($type='')
1563 global $spell_report, $wDB;
1564 $this->db = &$wDB;
1565 $this->column_conf =&$spell_report;
1566 switch ($type){
1567 case 'skill': $this->table = '(`wowd_spell` join `wowd_skill_line_ability` ON `wowd_skill_line_ability`.`spellId` =`wowd_spell`.`id`)';break;
1568 default: $this->table = '`wowd_spell`';break;
1570 $this->db_fields = '`wowd_spell`.`id`';
1572 function summonGO($entry)
1574 $effList = array(50, 76, 104, 105, 106, 107);
1575 $this->doRequirest(
1576 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1577 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1578 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1580 function summonCreature($entry)
1582 $effList = array(28, 56, 90, 93, 134);
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 // List of spells use item as reagent
1589 function useRegent($entry)
1591 $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);
1592 $create = 0;
1593 foreach($this->data_array as &$data)
1594 if ($data['EffectItemType_1'] OR $data['EffectItemType_2'] OR $data['EffectItemType_3'])
1595 $create = 1;
1596 if (!$create) $this->removeField('SPELL_REPORT_CREATE');
1598 // List of spells create this item
1599 function createItem($entry)
1601 $eff_list = array(107, 108, 109, 112);
1602 $this->doRequirest(
1603 '(`EffectItemType_1` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1604 (`EffectItemType_2` = ?d AND EffectApplyAuraName_1 NOT IN (?a)) OR
1605 (`EffectItemType_3` = ?d AND EffectApplyAuraName_1 NOT IN (?a))', $entry, $eff_list, $entry, $eff_list, $entry, $eff_list);
1607 // List os spells give faction reputation
1608 function giveReputation($entry)
1610 $this->doRequirest(
1611 '(`EffectMiscValue_1` = ?d AND `Effect_1` = 103) OR
1612 (`EffectMiscValue_2` = ?d AND `Effect_2` = 103) OR
1613 (`EffectMiscValue_3` = ?d AND `Effect_3` = 103)', $entry, $entry, $entry);
1615 function triggerFromSpells($entry)
1617 $this->doRequirest(
1618 '`EffectTriggerSpell_1` = ?d OR
1619 `EffectTriggerSpell_2` = ?d OR
1620 `EffectTriggerSpell_3` = ?d', $entry, $entry, $entry);
1622 function enchantFromSpells($entry)
1624 $effList = array(53, 54, 92);
1625 $this->doRequirest(
1626 '(`EffectMiscValue_1` = ?d AND `Effect_1` IN (?a)) OR
1627 (`EffectMiscValue_2` = ?d AND `Effect_2` IN (?a)) OR
1628 (`EffectMiscValue_3` = ?d AND `Effect_3` IN (?a))', $entry, $effList, $entry, $effList, $entry, $effList);
1630 function affectedBySpells($family, $maskA, $maskB, $maskC)
1632 $this->doRequirest(
1633 '`SpellFamilyName` = ?d AND
1635 (`EffectApplyAuraName_1` IN (107, 108) AND ( (`EffectSpellClassMaskA_1` & ?d) OR (`EffectSpellClassMaskA_2` & ?d) OR (`EffectSpellClassMaskA_3` & ?d) ) ) OR
1636 (`EffectApplyAuraName_2` IN (107, 108) AND ( (`EffectSpellClassMaskB_1` & ?d) OR (`EffectSpellClassMaskB_2` & ?d) OR (`EffectSpellClassMaskB_3` & ?d) ) ) OR
1637 (`EffectApplyAuraName_3` IN (107, 108) AND ( (`EffectSpellClassMaskC_1` & ?d) OR (`EffectSpellClassMaskC_2` & ?d) OR (`EffectSpellClassMaskC_3` & ?d) ) )
1638 )', $family, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC, $maskA, $maskB, $maskC);
1640 function castByCreature($creature)
1642 global $wDB, $dDB;
1643 $spell_list = array();
1644 // By creature fields
1645 for ($i=1;$i<5;$i++) if ($creature['spell'.$i]) $spell_list[] = $creature['spell'.$i];
1646 // By event AI table
1647 for ($i=1;$i<=3;$i++)
1648 $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']));
1649 if (count($spell_list))
1650 $this->doRequirest('`id` IN (?a)', array_unique($spell_list));
1652 function doSkillList($skill)
1654 if (isset($_REQUEST['guid']))
1656 $spells = getPlayerSpells($_REQUEST['guid']);
1657 $this->rowCallback = 'playerSpellCallback';
1659 $this->doRequirest('`skillId` = ?d', $skill);
1661 function lootItem($entry)
1663 global $dDB;
1664 $ref_loot =& getRefrenceItemLoot($entry);
1665 $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));
1666 if ($spells)
1667 $this->doRequirest('`id` IN (?a)', array_keys($spells));
1671 //=================================================================
1672 // Glyph list report functions and methods
1673 //=================================================================
1674 function r_glyphId($data) {echo $data['id'];}
1675 function r_glyphName($data) {$spell=getSpell($data['SpellId']); echo $spell['SpellName'];}
1676 function r_glyphIcon($data) {echo '<img src="'.getSpellIcon($data['iconId']).'">';}
1678 $glyph_report = array(
1679 'GLYPH_REPORT_ID' =>array('class'=>'small','sort'=>'','text'=>$lang['glyph_id' ], 'draw'=>'r_glyphId', 'sort_str'=>'', 'fields'=>'' ),
1680 'GLYPH_REPORT_NAME'=>array('class'=>'left', 'sort'=>'','text'=>$lang['glyph_name'], 'draw'=>'r_glyphName','sort_str'=>'', 'fields'=>'`SpellId`' ),
1681 'GLYPH_REPORT_ICON'=>array('class'=>'i_ico','sort'=>'','text'=>'', 'draw'=>'r_glyphIcon','sort_str'=>'', 'fields'=>'`iconId`'),
1684 class GlyphReportGenerator extends ReportGenerator{
1685 // Database depend requirest generator
1686 // Select only reuire for report fields from database
1687 function GlyphReportGenerator($type='')
1689 global $glyph_report, $wDB;
1690 $this->db = &$wDB;
1691 $this->column_conf =&$glyph_report;
1692 $this->table = '`wowd_glyphproperties`';
1693 $this->db_fields = '`id`';
1695 function useSpell($entry)
1697 $this->doRequirest('`SpellId` = ?d', $entry);
1701 //=================================================================
1702 // Random Suffix list report functions and methods
1703 //=================================================================
1704 function r_rndSuffId($data) {echo $data['id'];}
1705 function r_rndSuffName($data) {echo '&nbsp;... '.$data['name'];}
1706 function r_rndSuffDetail($data)
1708 for ($j=1;$j<=3;$j++)
1709 if ($data['EnchantID_'.$j])
1710 echo str_ireplace('$i', round($data['Prefix_'.$j]/100, 2).'%', getEnchantmentDesc($data['EnchantID_'.$j]))."<br>";
1713 $rsuff_report = array(
1714 'RSUFF_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndSuffId', 'sort_str'=>'', 'fields'=>'' ),
1715 'RSUFF_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndSuffName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1716 '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`'),
1719 class RandomSuffixReportGenerator extends ReportGenerator{
1720 // Database depend requirest generator
1721 // Select only reuire for report fields from database
1722 function RandomSuffixReportGenerator($type='')
1724 global $rsuff_report, $wDB;
1725 $this->db = &$wDB;
1726 $this->column_conf =&$rsuff_report;
1727 $this->table = '`wowd_item_random_suffix`';
1728 $this->db_fields = '`id`';
1730 function enchantFrom($entry)
1732 $this->doRequirest('`EnchantID_1` = ?d OR `EnchantID_2` = ?d OR `EnchantID_3` = ?d', $entry, $entry, $entry);
1736 //=================================================================
1737 // Random Suffix list report functions and methods
1738 //=================================================================
1739 function r_rndPropId($data) {echo $data['id'];}
1740 function r_rndPropName($data) {echo '&nbsp;... '.$data['name'];}
1741 function r_rndPropDetail($data)
1743 for ($j=1;$j<=5;$j++)
1744 if ($data['EnchantID_'.$j])
1745 echo getEnchantmentDesc($data['EnchantID_'.$j])."<br>";
1748 $rprop_report = array(
1749 'RPROP_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['rand_enchant_id' ], 'draw'=>'r_rndPropId', 'sort_str'=>'', 'fields'=>'' ),
1750 'RPROP_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['rand_enchant_name'], 'draw'=>'r_rndPropName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1751 '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`'),
1754 class RandomPropetyReportGenerator extends ReportGenerator{
1755 // Database depend requirest generator
1756 // Select only reuire for report fields from database
1757 function RandomPropetyReportGenerator($type='')
1759 global $rprop_report, $wDB;
1760 $this->db = &$wDB;
1761 $this->column_conf =&$rprop_report;
1762 $this->table = '`wowd_item_random_propety`';
1763 $this->db_fields = '`id`';
1765 function enchantFrom($entry)
1767 $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);
1771 //=================================================================
1772 // Lock list report functions and methods
1773 //=================================================================
1774 function r_LockId($data) {echo $data['id'];}
1775 function r_LockKeys($data)
1777 for ($i=0;$i<8;$i++)
1779 switch ($data['keytype_'.$i]){
1780 case 0: continue;
1781 case 1: echo text_show_item($data['key_'.$i], 0, 'cost').($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1782 case 2: echo getLockType($data['key_'.$i]).($data['reqskill_'.$i]?' ('.$data['reqskill_'.$i].')':'').'<br>';break;
1786 function r_LockProvide($data)
1788 global $lang, $dDB;
1789 if ($items = $dDB->select('SELECT `entry`, `Quality`, `displayid`, `name` FROM `item_template` WHERE `lockid` = ?d', $data['id']))
1790 foreach ($items as $i)
1791 show_item($i['entry'], $i['displayid'], 'sell');
1793 $data0 = array(GAMEOBJECT_TYPE_QUESTGIVER,GAMEOBJECT_TYPE_CHEST,GAMEOBJECT_TYPE_TRAP,GAMEOBJECT_TYPE_GOOBER,GAMEOBJECT_TYPE_CAMERA);
1794 $data1 = array(GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_BUTTON);
1795 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']))
1796 foreach ($go_list as $go)
1798 localiseGameobject($go);
1799 r_objName($go);echo '<br>';
1801 if (count($items) + count($go_list) == 0)
1802 echo $lang['no_found'];
1805 $lock_report = array(
1806 'LOCK_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['lock_id'], 'draw'=>'r_LockId', 'sort_str'=>'', 'fields'=>''),
1807 'LOCK_REPORT_KEY' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['lock_keys'],'draw'=>'r_LockKeys', 'sort_str'=>'', 'fields'=>''),
1808 'LOCK_REPORT_HAVE'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['locked_list'],'draw'=>'r_LockProvide','sort_str'=>'', 'fields'=>''),
1811 class LockReportGenerator extends ReportGenerator{
1812 // Database depend requirest generator
1813 // Select only reuire for report fields from database
1814 function LockReportGenerator($type='')
1816 global $lock_report, $wDB;
1817 $this->db = &$wDB;
1818 $this->column_conf =&$lock_report;
1819 $this->table = '`wowd_lock`';
1820 $this->db_fields = '*';
1822 function haveItemAsKey($entry)
1824 $this->doRequirest(
1825 '(`keytype_0` = 1 AND `key_0` = ?d) OR
1826 (`keytype_1` = 1 AND `key_1` = ?d) OR
1827 (`keytype_2` = 1 AND `key_2` = ?d) OR
1828 (`keytype_3` = 1 AND `key_3` = ?d) OR
1829 (`keytype_4` = 1 AND `key_4` = ?d)', $entry, $entry, $entry, $entry, $entry);
1833 //=================================================================
1834 // Extend cost list report functions and methods
1835 //=================================================================
1836 function r_excostId($data) {echo $data['id'];}
1837 function r_excostCost($data, $side = 0)
1839 if ($side) $side = "images/honor_horde.png";
1840 else $side = "images/honor_alliance.png";
1841 $str='<div class=ex_cost>';
1842 if ($data['reqhonorpoints']) $str.= $data['reqhonorpoints'].'x<img class=cost src='.$side.'>';
1843 if ($data['reqarenapoints']) $str.= $data['reqarenapoints'].'x<img class=cost src=images/arena_points.png>';
1844 for ($i=1;$i<6;$i++)
1845 if ($data['reqitem_'.$i]) $str.= $data['reqitemcount_'.$i].' x '.text_show_item($data['reqitem_'.$i], 0, 'cost');
1846 echo $str.'</div>';
1849 function r_excostItem($data)
1851 global $lang, $dDB;
1852 if ($items = $dDB->selectCol("SELECT `item` FROM `npc_vendor` WHERE ExtendedCost = ?d GROUP BY `item`", $data['id']))
1853 foreach ($items as $itemid)
1854 show_item($itemid, 0, "sell");
1855 else
1856 echo $lang['no_found'];
1858 $excost_report = array(
1859 'EXCOST_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['excost_id'], 'draw'=>'r_excostId', 'sort_str'=>'`id`', 'fields'=>''),
1860 'EXCOST_REPORT_COST'=>array('class'=>'small','sort'=>'cost', 'text'=>$lang['excost_cost'], 'draw'=>'r_excostCost','sort_str'=>'`reqitemcount_1`,`reqitemcount_2`, `reqitemcount_3`', 'fields'=>''),
1861 'EXCOST_REPORT_ITEM'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['excost_items'],'draw'=>'r_excostItem','sort_str'=>'', 'fields'=>''),
1864 class ExCostReportGenerator extends ReportGenerator{
1865 // Database depend requirest generator
1866 // Select only reuire for report fields from database
1867 function ExCostReportGenerator($type='')
1869 global $excost_report, $wDB;
1870 $this->db = &$wDB;
1871 $this->column_conf =&$excost_report;
1872 $this->table = '`wowd_item_ex_cost`';
1873 $this->db_fields = '*';
1875 function useItemAsCost($entry)
1877 $this->doRequirest(
1878 '`reqitem_1` = ?d OR
1879 `reqitem_2` = ?d OR
1880 `reqitem_3` = ?d OR
1881 `reqitem_4` = ?d OR
1882 `reqitem_5` = ?d', $entry, $entry, $entry, $entry, $entry);
1886 //=================================================================
1887 // Item set list report functions and methods
1888 //=================================================================
1889 function r_setId($data) {echo $data['id'];}
1890 function r_setName($data){echo '<a href="?itemset='.$data['id'].'">'.$data['name'].'</a>';}
1891 function r_setItems($data)
1893 for($i=1;$i<18;$i++)
1894 if ($set_item = $data['item_'.$i])
1895 echo '&nbsp;'.text_show_item($set_item).'&nbsp;';
1897 function r_setSpells($data)
1899 for($i=1; $i<9; $i++)
1900 if ($spellID = $data['spell_'.$i])
1901 echo '<a class=spell href="?spell='.$spellID.'">('.$data['count_'.$i].') '.get_spell_details($spellID).'</a><br>';
1903 function r_setClass($data){}
1904 function r_setLevel($data){}
1906 $itemset_report = array(
1907 'SET_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['set_id'], 'draw'=>'r_setId', 'sort_str'=>'`id`', 'fields'=>''),
1908 'SET_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['set_name'], 'draw'=>'r_setName', 'sort_str'=>'`name`','fields'=>''),
1909 'SET_REPORT_ITEM' =>array('class'=>'iset', 'sort'=>'', 'text'=>$lang['set_items'], 'draw'=>'r_setItems', 'sort_str'=>'', 'fields'=>''),
1910 'SET_REPORT_SPELL'=>array('class'=>'', 'sort'=>'', 'text'=>$lang['set_spells'],'draw'=>'r_setSpells','sort_str'=>'', 'fields'=>''),
1911 // Not supported yet
1912 'SET_REPORT_CLASS'=>array('class'=>'', 'sort'=>'class','text'=>$lang['set_class'], 'draw'=>'r_setClass', 'sort_str'=>'', 'fields'=>''),
1913 'SET_REPORT_LEVEL'=>array('class'=>'', 'sort'=>'level','text'=>$lang['set_level'], 'draw'=>'r_setLevel', 'sort_str'=>'', 'fields'=>''),
1916 class ItemSetReportGenerator extends ReportGenerator{
1917 // Database depend requirest generator
1918 // Select only reuire for report fields from database
1919 function ItemSetReportGenerator($type='')
1921 global $itemset_report, $wDB;
1922 $this->db = &$wDB;
1923 $this->column_conf =&$itemset_report;
1924 $this->table = '`wowd_itemset`';
1925 $this->db_fields = '*';
1927 function useSpell($entry)
1929 $this->doRequirest(
1930 '`spell_1` = ?d OR `spell_2` = ?d OR `spell_3` = ?d OR `spell_4` = ?d OR
1931 `spell_5` = ?d OR `spell_6` = ?d OR `spell_7` = ?d OR `spell_8` = ?d', $entry, $entry, $entry, $entry, $entry, $entry, $entry, $entry);
1935 //=================================================================
1936 // Faction list report functions and methods
1937 //=================================================================
1938 function r_factionId($data) {echo $data['id'];}
1939 function r_factionName($data) {echo '<a href="?faction='.$data['id'].'">'.$data['name'].'</a>';}
1940 function r_factionDetail($data){echo $data['details'];}
1942 $faction_report = array(
1943 'FACTION_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['faction_id' ], 'draw'=>'r_factionId', 'sort_str'=>'', 'fields'=>'' ),
1944 'FACTION_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['faction_name'], 'draw'=>'r_factionName', 'sort_str'=>'`name`', 'fields'=>'`name`' ),
1945 'FACTION_REPORT_DETAILS' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['faction_details'],'draw'=>'r_factionDetail','sort_str'=>'', 'fields'=>'`details`'),
1948 class FactionReportGenerator extends ReportGenerator{
1949 // Database depend requirest generator
1950 // Select only reuire for report fields from database
1951 function FactionReportGenerator($type='')
1953 global $faction_report, $wDB;
1954 $this->db = &$wDB;
1955 $this->column_conf =&$faction_report;
1956 $this->table = '`wowd_faction`';
1957 $this->db_fields = '`id`';
1961 //=================================================================
1962 // Enchants list report functions and methods
1963 //=================================================================
1964 function r_enchId($data) {echo $data['id'];}
1965 function r_enchName($data) {echo '<a href="?enchant='.$data['id'].'">'.$data['description'].'</a>';}
1966 function r_enchGem($data) { if ($data['GemID']) echo text_show_item($data['GemID']);}
1967 $enchants_report = array(
1968 'ENCH_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['enchant_id'], 'draw'=>'r_enchId', 'sort_str'=>'`id`', 'fields'=>''),
1969 'ENCH_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['enchant_name'],'draw'=>'r_enchName', 'sort_str'=>'`description`','fields'=>'`description`'),
1970 'ENCH_REPORT_GEM' =>array('class'=>'small','sort'=>'', 'text'=>'', 'draw'=>'r_enchGem', 'sort_str'=>'', 'fields'=>'`GemID`'),
1973 class EnchantReportGenerator extends ReportGenerator{
1974 // Database depend requirest generator
1975 // Select only reuire for report fields from database
1976 function EnchantReportGenerator($type='')
1978 global $enchants_report, $wDB;
1979 $this->db = &$wDB;
1980 $this->column_conf =&$enchants_report;
1981 $this->table = '`wowd_item_enchantment`';
1982 $this->db_fields = '`id`';
1984 function useSpell($entry)
1986 $this->doRequirest('`spellid_1` = ?d OR `spellid_2` = ?d OR `spellid_3` = ?d', $entry, $entry, $entry);
1987 $this->removeIfAllZero('GemID', 'ENCH_REPORT_GEM');
1991 //=================================================================
1992 // Talents list report functions and methods
1993 //=================================================================
1994 function r_talentId($data) {echo $data['TalentTab'];}
1995 function r_talentName($data) {echo getTalentName($data['TalentTab']);}
1996 $talent_report = array(
1997 'TALENT_REPORT_ID' =>array('class'=>'small','sort'=>'', 'text'=>$lang['talent_id'], 'draw'=>'r_talentId', 'sort_str'=>'', 'fields'=>'`TalentTab`'),
1998 'TALENT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'', 'text'=>$lang['talent_name'],'draw'=>'r_talentName', 'sort_str'=>'','fields'=>'`TalentTab`'),
2001 class TalentReportGenerator extends ReportGenerator{
2002 // Database depend requirest generator
2003 // Select only reuire for report fields from database
2004 function TalentReportGenerator($type='')
2006 global $talent_report, $wDB;
2007 $this->db = &$wDB;
2008 $this->column_conf =&$talent_report;
2009 $this->table = '`wowd_talents`';
2010 $this->db_fields = '`TalentID`';
2012 function useSpell($entry)
2014 $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);
2017 //=================================================================
2018 // Zones list report functions and methods
2019 //=================================================================
2020 function r_zoneId($data) {echo $data['id'];}
2021 function r_zoneName($data) {echo '<a href="?zone='.$data['id'].'">'.$data['name'].'</a>';}
2022 $zone_report = array(
2023 'ZONE_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['zone_id'], 'draw'=>'r_zoneId', 'sort_str'=>'`id`', 'fields'=>''),
2024 'ZONE_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['zone_name'],'draw'=>'r_zoneName', 'sort_str'=>'`name`','fields'=>'`name`'),
2027 class ZoneReportGenerator extends ReportGenerator{
2028 function ZoneReportGenerator($type='')
2030 global $zone_report, $wDB;
2031 $this->db = &$wDB;
2032 $this->column_conf =&$zone_report;
2033 $this->table = '`wowd_zones`';
2034 $this->db_fields = '`id`';
2036 function parentZone($entry)
2038 $this->doRequirest('`id` = ?d', $entry);
2040 function subZones($entry)
2042 $this->doRequirest('`zone_id` = ?d', $entry);
2046 //=================================================================
2047 // Areatrigger teleport list report functions and methods
2048 //=================================================================
2049 function r_atId($data) {echo $data['id'];}
2050 function r_atName($data) {echo $data['name'];}
2051 function r_atReq($data)
2053 global $lang;
2054 if ($data['required_level'])
2055 echo 'Req level: '.$data['required_level'].'<br>';
2057 if ($data['required_item'] OR $data['required_item2'])
2059 echo 'Req items:<br>';
2060 if ($data['required_item']) echo text_show_item($data['required_item'], 0, 'quest');
2061 if ($data['required_item2']) echo $lang['item_sel_and'].text_show_item($data['required_item2'], 0, 'quest');
2062 echo '<br>';
2064 if ($data['heroic_key'] OR $data['heroic_key2'])
2066 echo 'Heroic key:<br>';
2067 if ($data['heroic_key']) echo text_show_item($data['heroic_key'], 0, 'quest');
2068 if ($data['heroic_key2']) echo $lang['item_sel_and'].text_show_item($data['heroic_key2'], 0, 'quest');
2069 echo '<br>';
2073 $at_report = array(
2074 'AT_REPORT_ID' =>array('class'=>'small','sort'=>'id', 'text'=>$lang['at_id'], 'draw'=>'r_atId', 'sort_str'=>'`id`', 'fields'=>''),
2075 'AT_REPORT_NAME' =>array('class'=>'left', 'sort'=>'name', 'text'=>$lang['at_name'],'draw'=>'r_atName', 'sort_str'=>'`name`','fields'=>'`name`'),
2076 '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`'),
2079 class AreaTriggerReportGenerator extends ReportGenerator{
2080 function AreaTriggerReportGenerator($type='')
2082 global $at_report, $wDB;
2083 $this->db = &$wDB;
2084 $this->column_conf =&$at_report;
2085 $this->table = '`areatrigger_teleport`';
2086 $this->db_fields = '*';
2088 function onMap($entry)
2090 $this->doRequirest('`target_map` = ?d', $entry);
2092 function onArea($area_data)
2094 $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]);
2098 //=================================================================
2099 // Players list report functions and methods
2100 //=================================================================
2101 function r_plGUID($data) {echo $data['guid'];}
2102 function r_plName($data) {echo '<a href=?player='.$data['guid'].'>'.$data['name'].'</a>';}
2103 function r_plRace($data) {echo '<img src="'.getRaceImage($data['race'],$data['gender']).'">';}
2104 function r_plClass($data) {echo '<img src="'.getClassImage($data['class']).'">';}
2105 function r_plFaction($data){echo '<img src="'.getFactionImage($data['race']).'">';}
2106 function r_plLevel($data) {echo $data['level'];}
2107 function r_plPos($data)
2109 global $config;
2110 $map_name = getMapNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2111 $area_name = getAreaNameFromPoint($data['map'], $data['position_x'], $data['position_y'], $data['position_z']);
2112 $extra_name = "";
2113 if ($area_name)
2115 $extra_name = "<br><font size=-2>".$map_name."</font>";
2116 $map_name = "&bdquo;".str_replace(' ','&nbsp;', $area_name)."&ldquo;";
2118 else
2119 $map_name = "&bdquo;".str_replace(' ','&nbsp;',$map_name)."&ldquo;";
2121 if ($config['show_map_ptr'])
2122 $map_name = "<a href=\"?map&point=$data[map]:$data[position_x]:$data[position_y]:$data[position_z]\">".$map_name."</a>";
2123 echo $map_name.$extra_name;
2125 function r_plGuildNote($data) {echo $data['pnote']."<br>".$data['offnote'];}
2126 function r_plGuildRank($data)
2128 // Получаем названия рангов в гильдии
2129 $rank = getGuildRankList($data['guildid']);
2130 echo @$rank[$data['rank']]['rname'];
2133 function r_plItem($data){show_item_by_data(explode(' ',$data['item_data']));}
2135 $pl_report = array(
2136 'PL_REPORT_GUID' =>array('class'=>'small', 'sort'=>'id', 'text'=>$lang['pl_guid'], 'draw'=>'r_plGUID', 'sort_str'=>'`id`', 'fields'=>''),
2137 'PL_REPORT_NAME' =>array('class'=>'player','sort'=>'name', 'text'=>$lang['pl_name'], 'draw'=>'r_plName', 'sort_str'=>'`name`', 'fields'=>'`name`'),
2138 'PL_REPORT_RACE' =>array('class'=>'i_ico', 'sort'=>'race', 'text'=>$lang['pl_race'], 'draw'=>'r_plRace', 'sort_str'=>'`race`', 'fields'=>'`race`, `gender`'),
2139 'PL_REPORT_CLASS' =>array('class'=>'i_ico', 'sort'=>'class', 'text'=>$lang['pl_class'], 'draw'=>'r_plClass', 'sort_str'=>'`class`', 'fields'=>'`class`'),
2140 'PL_REPORT_FACTION'=>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plFaction','sort_str'=>'', 'fields'=>'`race`'),
2141 'PL_REPORT_LEVEL' =>array('class'=>'small', 'sort'=>'level', 'text'=>$lang['pl_level'], 'draw'=>'r_plLevel', 'sort_str'=>'`level` DESC','fields'=>'`level`'),
2142 '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`'),
2143 // Guild member info
2144 'PL_REPORT_NOTE' =>array('class'=>'', 'sort'=>'', 'text'=>$lang['pl_note'], 'draw'=>'r_plGuildNote','sort_str'=>'', 'fields'=>'`pnote`, `offnote`'),
2145 'PL_REPORT_GRANK' =>array('class'=>'rank', 'sort'=>'rank', 'text'=>$lang['pl_rank'], 'draw'=>'r_plGuildRank','sort_str'=>'`rank`', 'fields'=>'`guildid`,`rank`'),
2146 // Item owner
2147 'PL_REPORT_ITEM' =>array('class'=>'i_ico', 'sort'=>'', 'text'=>'', 'draw'=>'r_plItem' ,'sort_str'=>'', 'fields'=>'`item_instance`.`data` AS `item_data`'),
2150 class PlayerReportGenerator extends ReportGenerator{
2151 function PlayerReportGenerator($type='')
2153 global $pl_report, $cDB;
2154 $this->db = &$cDB;
2155 $this->column_conf =&$pl_report;
2156 switch ($type){
2157 case 'guild': $this->table = '(`characters` join `guild_member` ON `guild_member`.`guid` = `characters`.`guid`)';break;
2158 case 'item': $this->table = '(`characters` join `item_instance` ON `characters`.`guid` = `item_instance`.`owner_guid`)';break;
2159 default: $this->table = '`characters`';break;
2162 $this->db_fields = '`characters`.`guid`';
2164 function online()
2166 $this->doRequirest('`online` <> 0 AND NOT `extra_flags`&'.PLAYER_EXTRA_GM_INVISIBLE);
2168 // Select guild members by guild guid
2169 function guildMembers($gguid)
2171 $this->doRequirest('`guildid` = ?d', $gguid);
2173 function itemOwner($id)
2175 $this->doRequirest("(SUBSTRING_INDEX( SUBSTRING_INDEX(`item_instance`.`data` , ' ' , ?d) , ' ' , -1 )+0) = ?d", ITEM_FIELD_ENTRY + 1, $id);