/**
  * View Bossprogress page
  * @param viewNavigation $Navigation
  */
 public function buildpage(viewNavigation $Navigation)
 {
     global $phpbb_root_path, $phpEx, $user, $template, $config;
     $igame = new \bbdkp\controller\games\Game();
     $igame->game_id = $Navigation->getGameId();
     $igame->Get();
     $Guild = new \bbdkp\controller\guilds\Guilds($Navigation->getGuildId());
     $bp = new \bbdkp\controller\Raids\GuildProgress();
     $data = $bp->GetProgress($Guild);
     $numzones = 0;
     foreach ($data as $zone_id => $zone) {
         $numzones += 1;
     }
     $start = request_var('start', 0);
     $template->assign_vars(array('S_STYLE' => $config['bbdkp_zone_style'], 'S_BPSHOW' => true, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $Guild->game_id . '/' . $Guild->game_id . '.png', 'F_BP' => \append_sid("{$phpbb_root_path}dkp.{$phpEx}", 'page=bossprogress&guild_id=' . $Navigation->getGuildId()), 'GAME_ID' => $Navigation->getGameId(), 'GAME_NAME' => $igame->getName(), 'GUILD_ID' => $Guild->guildid, 'PAGE_NUMBER' => \on_page($numzones, 2, $start), 'PAGINATION' => \generate_pagination(append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=bossprogress&guild_id=" . $Guild->guildid), $numzones, 2, $start, true), 'U_BPIMG' => "{$phpbb_root_path}images/bbdkp/gameworld/{$Navigation->getGameId()}/{$Navigation->getGameId()}.png"));
     $i = 0;
     $j = 0;
     //loop the zones
     foreach ($data as $zone_id => $zone) {
         $i += 1;
         if ($i >= $start) {
             $j += 1;
             //show max 2 zones per page
             if ($j <= 2) {
                 $template->assign_block_vars('zone', array('ZONE_NAME' => $zone['zonename'], 'ZONE_ID' => $zone['zoneid'], 'ZONE_PROGRESSIMG' => $zone['zoneimage'], 'ZONE_BACKGROUNDIMG' => $zone['zonebackground'], 'ZONECOMPLETE' => $zone['zonecomplete'], 'ZONESTATS' => $zone['zonestats']));
                 foreach ($zone['bosses'] as $boss_id => $boss) {
                     $killdate = '';
                     if ($boss['bosskilldate'] != '') {
                         $killdate = date($config['bbdkp_date_format'], $boss['bosskilldate']);
                         // convert UNIX timestamp to PHP DateTime
                     }
                     if ($boss['bosskilled'] == 0) {
                         $bossimg = "{$phpbb_root_path}images/bbdkp/gameworld/" . $Guild->game_id . '/bosses/' . $boss['imagename'] . '_b.png';
                     } else {
                         $bossimg = "{$phpbb_root_path}images/bbdkp/gameworld/" . $Guild->game_id . '/bosses/' . $boss['imagename'] . '.png';
                     }
                     $template->assign_block_vars('zone.boss', array('BOSS_NAME' => $boss['bossname'], 'BOSS_IMAGENAME' => $bossimg, 'BOSS_ID' => $boss['id'], 'BOSS_WEBID' => $boss['webid'], 'BOSS_TYPE' => $boss['type'], 'BOSS_URL' => sprintf($igame->getBossbaseurl(), $boss['webid']), 'BOSS_URLVIEW' => $phpbb_root_path . "images/bbdkp/icons/view.gif", 'BOSS_KILLED' => $boss['bosskilled'] == 1 ? 'checked="checked"' : '', 'BOSS_SHOW' => $boss['bossshow'] == 1 ? "checked=checked" : '', 'BOSS_KILLDATE' => $killdate, 'BOSS_COUNTER' => $boss['bosscounter'], 'S_BOSS_KILLED' => $boss['bosskilled']));
                 }
             }
         }
     }
     page_header($user->lang['MENU_BOSS']);
 }
function display_bpblock($guild_id)
{
    global $config, $user, $phpbb_root_path, $template, $phpEx;
    //include the guilds class
    if (!class_exists('\\bbdkp\\controller\\guilds\\Guilds')) {
        require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Guilds.{$phpEx}";
    }
    $Guild = new \bbdkp\controller\guilds\Guilds($guild_id);
    if (!class_exists('\\bbdkp\\controller\\raids\\GuildProgress')) {
        require "{$phpbb_root_path}includes/bbdkp/controller/raids/BossProgress.{$phpEx}";
    }
    $bp = new \bbdkp\controller\Raids\GuildProgress();
    $igame = new \bbdkp\controller\games\Game();
    $igame->game_id = $Guild->game_id;
    $igame->Get();
    $data = $bp->GetProgress($Guild);
    //loop the zones
    foreach ($data as $zone_id => $zone) {
        if ((int) $zone['zonecomplete'] <= 0) {
            $cssclass = 'bpprogress00';
        } elseif ((int) $zone['zonecomplete'] <= 25) {
            $cssclass = 'bpprogress25';
        } elseif ((int) $zone['zonecomplete'] <= 50) {
            $cssclass = 'bpprogress50';
        } elseif ((int) $zone['zonecomplete'] <= 75) {
            $cssclass = 'bpprogress75';
        } elseif ((int) $zone['zonecomplete'] <= 99) {
            $cssclass = 'bpprogress99';
        } elseif ((int) $zone['zonecomplete'] >= 100) {
            $cssclass = 'bpprogress100';
        }
        $template->assign_block_vars('zone', array('ZONE_NAME' => $zone['zonename'], 'ZONE_ID' => $zone['zoneid'], 'ZONECOMPLETE' => $zone['zonecomplete'], 'ZONEKILLS' => $zone['zonekills'], 'BOSSCOUNT' => $zone['zonebosses'], 'ZONE_URL' => sprintf($igame->getZonebaseurl(), $zone['webid']), 'CSSCLASS' => $cssclass));
        foreach ($zone['bosses'] as $boss_id => $boss) {
            $template->assign_block_vars('zone.boss', array('BOSS_NAME' => $boss['bossname'], 'BOSS_URL' => sprintf($igame->getBossbaseurl(), $boss['webid']), 'BOSS_KILLED' => $boss['bosskilled'] == "1" ? "1" : "0"));
        }
    }
}
 public function main($id, $mode)
 {
     global $user, $template, $phpEx, $phpbb_admin_path, $phpbb_root_path, $db;
     $user->add_lang(array('mods/dkp_admin', 'mods/dkp_common', 'mods/dkp_gameworld'));
     $this->tpl_name = 'dkp/acp_bossprogress';
     switch ($mode) {
         case 'guildprogress':
             $selectguild = isset($_POST['member_guild_id']) ? true : false;
             $submit = isset($_POST['bpsave']) ? true : false;
             $Guild = new \bbdkp\controller\guilds\Guilds();
             $guildlist = $Guild->guildlist(1);
             if (count((array) $guildlist) == 0) {
                 trigger_error('ERROR_NOGUILD', E_USER_WARNING);
             }
             if ($selectguild) {
                 $Guild->guildid = request_var('member_guild_id', 0);
             } else {
                 $Guild->guildid = request_var('hidden_guild_id', request_var('guild_id', 0));
             }
             $Guild->Getguild();
             if ($submit) {
                 $selectgame = request_var('hidden_game_id', '');
                 $krequest = new \bbdkp\admin\krequest();
                 $zones = $krequest->variable('boss', array('' => array('' => array('' => ''))), true, \bbdkp\admin\krequest::POST);
                 $krequest->enable_super_globals();
                 unset($krequest);
                 foreach ($zones as $bosses) {
                     $boss_ids = array();
                     foreach ($bosses as $id => $boss) {
                         if (isset($boss['killed']) || $boss['killdate'] != '' && $this->validateDate($boss['killdate'])) {
                             if ($boss['killdate'] != '') {
                                 $kd = \date_create($boss['killdate']);
                                 $kd = date_format($kd, 'U');
                             } else {
                                 $kd = time();
                             }
                             $sql_ary[] = array('guild_id' => $Guild->guildid, 'boss_id' => $id, 'bosskilled' => 1, 'bosskilldate' => $kd, 'bosscounter' => 1);
                             unset($kd);
                         }
                         $boss_ids[] = $id;
                     }
                     $sql = 'DELETE FROM ' . GUILD_BOSS . ' WHERE guild_id = ' . $Guild->guildid . ' AND ' . $db->sql_in_set('boss_id', $boss_ids);
                     $db->sql_query($sql);
                     $db->sql_multi_insert(GUILD_BOSS, $sql_ary);
                     unset($boss, $boss_ids, $sql_ary, $sql);
                 }
             }
             foreach ($guildlist as $g) {
                 if ($Guild->guildid == 0) {
                     $Guild->guildid = $g['id'];
                     $Guild->name = $g['name'];
                     $Guild->Getguild();
                 }
                 if ($Guild->guildid == 0 && $Guild->name == 'Guildless') {
                     trigger_error('ERROR_NOGUILD', E_USER_WARNING);
                 }
                 break;
             }
             foreach ($guildlist as $g) {
                 $template->assign_block_vars('guild_row', array('VALUE' => $g['id'], 'SELECTED' => $g['id'] == $Guild->guildid ? ' selected="selected"' : '', 'OPTION' => !empty($g['name']) ? $g['name'] : '(None)'));
             }
             $this->igame = new games\Game();
             $this->igame->game_id = $Guild->game_id;
             $this->igame->Get();
             $bp = new \bbdkp\controller\Raids\GuildProgress();
             $data = $bp->GetProgress($Guild);
             $numzones = 0;
             foreach ($data as $zone_id => $zone) {
                 $numzones += 1;
             }
             $start = request_var('start', 0);
             $template->assign_vars(array('PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_bossprogress&amp;mode=guildprogress&amp;guild_id=" . $Guild->guildid), $numzones, 2, $start, true), 'PAGE_NUMBER' => on_page($numzones, 2, $start), 'F_CONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_bossprogress&amp;mode=guildprogress&amp;guild_id=" . $Guild->guildid), 'GUILD_ID' => $Guild->guildid, 'GAME_ID' => $Guild->game_id));
             $i = 0;
             $j = 0;
             foreach ($data as $zone_id => $zone) {
                 $i += 1;
                 if ($i >= $start) {
                     $j += 1;
                     //show max 2 zones per page
                     if ($j <= 2) {
                         $template->assign_block_vars('zone', array('ZONE_NAME' => $zone['zonename'], 'ZONE_ID' => $zone['zoneid'], 'ZONE_PROGRESSIMG' => $zone['zoneimage'], 'ZONE_BACKGROUNDIMG' => $zone['zonebackground'], 'ZONECOMPLETE' => $zone['zonecomplete'], 'ZONESTATS' => $zone['zonestats']));
                         foreach ($zone['bosses'] as $boss_id => $boss) {
                             $killdate = '';
                             if ($boss['bosskilldate'] != '') {
                                 $killdate = date('d-m-y', $boss['bosskilldate']);
                                 // convert UNIX timestamp to PHP DateTime
                             }
                             $template->assign_block_vars('zone.boss', array('BOSS_NAME' => $boss['bossname'], 'BOSS_IMAGENAME' => $phpbb_root_path . "images/bbdkp/gameworld/" . $Guild->game_id . "/bosses/" . $boss['imagename'] . ".png", 'BOSS_ID' => $boss['id'], 'BOSS_WEBID' => $boss['webid'], 'BOSS_TYPE' => $boss['type'], 'BOSS_URL' => sprintf($this->igame->getBossbaseurl(), $boss['webid']), 'BOSS_URLVIEW' => $phpbb_root_path . "images/bbdkp/icons/view.gif", 'BOSS_KILLED' => $boss['bosskilled'] == 1 ? 'checked="checked"' : '', 'BOSS_SHOW' => $boss['bossshow'] == 1 ? "checked=checked" : '', 'BOSS_KILLDATE' => $killdate, 'BOSS_COUNTER' => $boss['bosscounter'], 'S_BOSS_KILLED' => $boss['bosskilled']));
                         }
                     }
                 }
             }
             break;
     }
 }