function fetch($mode = 'fullPage') { // build the prizes page if (isset($_GET['currentPage'])) { $currentPage = $_GET['currentPage']; } else { $currentPage = 1; } if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = NULL; } if (isset($_GET['step'])) { $step = $_GET['step']; } else { $step = NULL; } if (isset($_GET['message'])) { $message = $_GET['message']; } else { $message = ''; } if ($_GET['debug']) { echo '<pre>' . print_r($_GET, true) . '</pre>'; } require_once PATH_FACEBOOK . '/classes/actionTeam.class.php'; $this->teamObj = new actionTeam($this->page); $tabs .= $this->teamObj->buildSubNav('rewards'); $inside = '<div id="col_left"><!-- begin left side -->'; require_once PATH_CORE . '/classes/prizes.class.php'; $rewards = new rewards($this->db); require_once PATH_CORE . '/classes/prizes.class.php'; $pt = new PrizeTable($this->db); $prize = $pt->getRowObject(); if ($step == 'submit') { $id = $_POST['prizeid']; } if (!$id || !$prize->load($id)) { $inside .= 'Error: cannot redeem a prize with no id specified'; } else { $inside .= $rewards->fetchRewardDetail($id, true); if ($step != 'submit') { if (!$this->checkOrderPossible(&$prize, &$this->page->session->u, &$this->page->session->ui, $message)) { $inside .= $this->page->buildMessage('error', "There is a problem redeeming this prize", $message); } else { // order form $inside .= $this->buildOrderForm(&$prize, &$this->page->session->u, &$this->page->session->ui); } } else { // repopulate form with get vars $user =& $this->page->session->u; $userinfo =& $this->page->session->ui; //$user->email = $_GET['email']; $uipostfields = array('address1', 'address2', 'city', 'state', 'phone', 'zip'); //echo '<pre>'.print_r($_POST, true). '</pre>'; foreach ($uipostfields as $field) { if (isset($_POST[$field])) { $userinfo->{$field} = $_POST[$field]; } } $userinfo->update(); // sync updated address info to database //echo '<pre>'.print_r($userinfo, true). '</pre>'; $message = ''; if (!$this->validateOrderFields($prize, $user, $userinfo, $message)) { $inside .= $this->page->buildMessage('error', "There was a problem with your submission", $message); $inside .= $this->buildOrderForm(&$prize, &$this->page->session->u, &$this->page->session->ui); } else { // success $orderid = $this->processPrizeOrder($prize->id, $user->userid, $message); // TODO: make this function a bit faster by using whats stored in the session if (!$orderid) { $inside .= $this->page->buildMessage('error', "There was a problem redeeming this prize", $message); } else { $inside .= $this->page->buildMessage('success', "Order received", $message); require_once PATH_FACEBOOK . '/pages/pageOrders.class.php'; $orders = new pageOrders($this->page); $inside .= '<div class="panel_1">' . '<div class="panelBar clearfix"> <h2>Order Details</h2> <div class="bar_link"><a href="?p=orders" onclick="setTeamTab(\'orders\'); return false;">See all</a></div> </div><!__end "panelBar"__>' . $orders->fetchOrderDetail($orderid) . '</div><!-- end panel_1 -->'; } } } } $inside .= '</div><!-- end left side --><div id="col_right">'; $inside .= $this->teamObj->fetchSidePanel('challenges'); $inside .= '</div> <!-- end right side -->'; //$inside.='<input type="hidden" id="pagingFunction" value="fetchChallenges">'; if ($mode == 'teamWrap') { return $inside; } $inside = $tabs . '<div id="teamWrap">' . $inside . '<!-- end teamWrap --></div>'; if ($this->page->isAjax) { return $inside; } $code = $this->page->constructPage('team', $inside, ''); return $code; }
function fetchRewardPanel() { $this->templateObj->registerTemplates(MODULE_ACTIVE, 'rewards'); // reward base page $inside .= '<div id="alltimeLeaderRewardHead"> <div id="rewardsHead"> <div class="panel_half float_left"> <div class="storyBlockWrap"> <p>' . $this->templateObj->templates['leaderRewardAlltimeOverview'] . '</p> </div><!--end "storyBlockWrap"--> </div><!--end "panel_half"--> <div class="panel_half float_right">' . $this->templateObj->templates['GrandPrize'] . '</div><!--end "panel_half"--> </div><!--end "rewardsHead"--> </div>'; require_once PATH_CORE . '/classes/prizes.class.php'; $rewards = new rewards($this->db); $pt = new PrizeTable($this->db); $weeklyPrizeList = $pt->getWeeklyPrizesByDate("NOW()", 'RAND()'); $weeklyPrizeIds = array_keys($weeklyPrizeList); $id = $weeklyPrizeIds[0]; // just show one prize for now //foreach ($weeklyPrizeIds as $id) $weekly .= '<div id="leaderWeeklyRewardBlock">' . $rewards->fetchRewardDetail($id, true, true) . '</div>'; // bit of a hack // this one hidden by default since thats the default state on page fetch $inside .= '<div id="weeklyLeaderRewardHead" class="hidden"> <div id="rewardsHead"> <div class="panel_half float_left"> <div class="storyBlockWrap"> <p>' . $this->templateObj->templates['leaderRewardWeeklyOverview'] . '</p> </div><!--end "storyBlockWrap"--> </div><!--end "panel_half"--> <div class="panel_half float_right"> ' . $weekly . '</div><!--end "panel_half"--> </div><!--end "rewardsHead"--> </div>'; return $inside; }
function fetch($mode = 'fullPage', $o = '') { // build the prizes page if (isset($_GET['currentPage'])) { $currentPage = $_GET['currentPage']; } else { $currentPage = 1; } if (isset($_GET['filter'])) { $filter = $_GET['filter']; } else { $filter = 'weekly'; } //REDEEM:'redeemable'; require_once PATH_CORE . '/classes/prizes.class.php'; $rewards = new rewards($this->db); require_once PATH_FACEBOOK . '/classes/actionTeam.class.php'; $this->teamObj = new actionTeam($this->page); $tabs = $this->teamObj->buildSubNav('rewards'); // required for ajax paging require_once PATH_CORE . '/classes/template.class.php'; $this->templateObj = new template($this->db); $this->templateObj->registerTemplates(MODULE_ACTIVE, 'rewards'); if (isset($_GET['o']) && $_GET['o'] == 'summary') { $inside = $this->fetchSummaryPage(isset($_GET['textOnly'])); } else { if (isset($_GET['o']) && $_GET['o'] == 'winners' || $o == 'winners') { $inside = $this->fetchWinnersPage($currentPage); $inside .= '<input type="hidden" id="pagingFunction" value="fetchWinners">'; } else { if (isset($_GET['id']) && $_GET['id']) { $inside = '<div id="col_left"><!-- begin left side -->'; // reward detail page $inside .= '<a href="?p=rewards" onclick="setTeamTab(\'rewards\'); return false;"> «' . htmlentities($this->templateObj->templates['BackText']) . '</a><br /><br />'; $inside .= '<hr />'; if ($this->page->session->isLoaded and ($this->page->session->u->eligibility == 'general' or $this->page->session->u->eligibility == 'ineligible')) { $inside .= $this->fetchEligibilityBox(); $showRedeemButtons = true; } else { $showRedeemButtons = false; } $inside .= $rewards->fetchRewardDetail($_GET['id'], $showRedeemButtons); $inside .= '</div><!-- end left side --><div id="col_right">'; $inside .= $this->teamObj->fetchSidePanel('rewards'); $inside .= '</div> <!-- end right side -->'; } else { // reward base page if ($this->page->session->isLoaded and ($this->page->session->u->eligibility == 'general' or $this->page->session->u->eligibility == 'ineligible')) { $inside .= $this->fetchEligibilityBox(); } $inside .= ' <div id="rewardsHead"> <div class="panel_half float_left"> <div class="storyBlockWrap"> <p>' . $this->templateObj->templates['rewardOverview'] . '</p> <p class="bump10"><a href="?p=invite" onclick="switchPage(\'invite\');return false;" class="btn_1">Invite more friends</a></p> </div><!--end "storyBlockWrap"--> </div><!--end "panel_half"--> <div class="panel_half float_right">' . $this->templateObj->templates['GrandPrize'] . '</div><!--end "panel_half"--> </div><!--end "rewardsHead"-->'; //$inside .='<div>'; $inside .= '<h2>' . $this->templateObj->templates['RewardTitle'] . '</h2>'; //$inside .='<div style="float: right"><a href="?p=rewards&o=summary">Summary</div></div>'; $inside .= $rewards->fetchRewards('dollarValue', $filter, $currentPage, false, 'team'); // $this->page->session->u->eligibility - with 16-25 yo change, show every reward to everyone $inside .= '<h3><a href="?p=rewards&o=summary">Summary of all rewards by week...</a></h3>'; } } } if ($mode == 'teamWrap') { return $inside; } $inside = $tabs . '<div id="teamWrap">' . $inside . '<!-- end teamWrap --></div>'; if ($this->page->isAjax) { return $inside; } $code = $this->page->constructPage('team', $inside, 'fetchRewardsPage'); return $code; }