/application/controllers/monetization.php
PHP | 704 lines | 483 code | 167 blank | 54 comment | 36 complexity | c0217c67c0c2e5766b92a18c424e766f MD5 | raw file
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Monetization extends MY_Controller
- {
- private $guest = NULL;
- public function __construct()
- {
- parent::__construct();
- if ($this->ion_auth->logged_in())
- {
- $this->setLayout('layout/member');
- $this->layoutData['member_page'] = 'CHANGE ME [' . $this->router->method . ']';
- $this->guest = FALSE;
- }
- else
- {
- $this->guest = TRUE;
- $referrerId = get_cookie('ref');
- $referrerData = $referrerId ? $this->ion_auth->user($referrerId)->row() : null;
- $this->layoutData['registerForm'] = $this->loadPartialView('partial/register', compact('referrerData'));
- $this->layoutData['loginForm'] = $this->loadPartialView('partial/login');
- $this->layoutData['forgotForm'] = $this->loadPartialView('partial/forgot');
- $this->layoutData['activationForm'] = $this->loadPartialView('partial/activation');
- }
- $this->load->model('monetization_model', 'Monetization');
- $this->load->model('payment_method_model', 'PaymentMethod');
- $this->load->model('investment_model', 'Investment');
- $this->load->model('game_model', 'Game');
- $this->load->model('games/coin_flip_model', 'CoinFlip');
- $this->load->model('games/blackjack_model', 'Blackjack');
- $this->load->library('table');
- $this->load->library('AccountObject');
- $this->load->driver('cache', array('adapter' => 'file'));
- //$this->output->enable_profiler(true);
- }
- //Monetization Portfolio
- public function index()
- {
- $guest = $this->guest;
- $balances = $this->PaymentMethod->getList();
- $cashier = array();
- $gaming = array();
- $sumRevenues = 0;
- $sumSufficient = 0;
- $sumBuildCost = 0;
- foreach ($balances as $balance)
- {
- $revenues = $this->Monetization->sumAllRevenues($balance->code);
- $otherCosts = $this->Monetization->sumAllOtherCosts($balance->code);
- $moduleInfo = $this->Monetization->getModuleDetails($balance->code);
- $cost = $revenues->cost - $otherCosts->other_cost;
- $row = array();
- $row[] = anchor('monetization/method/' . $balance->code . '.html', $balance->name);
- $row[] = money($moduleInfo->installation_cost);
- $row[] = money($cost);
- $row[] = money($moduleInfo->installation_cost / MON_VAL_1);
- $row[] = money($cost > 0 ? $cost / MON_VAL_2 : 0);
- $cashier[$balance->code] = $row;
- $sumRevenues = $sumRevenues + $cost;
- $sumSufficient = $sumSufficient + ($cost / MON_VAL_2);
- $sumBuildCost = $sumBuildCost + $moduleInfo->installation_cost;
- }
- // Shares
- $revenues = $this->Monetization->sumAllShareRevenues();
- $moduleInfo = $this->Monetization->getModuleDetails('shares');
- $cost = $revenues->fee;
- $shares = array(
- 'buildCost' => money($moduleInfo->installation_cost),
- 'cost' => money($cost),
- 'investmentConsumed' => money($moduleInfo->installation_cost / MON_VAL_1),
- 'investmentRepaid' => money($cost > 0 ? $cost / MON_VAL_2 : 0)
- );
- // Do the Games
- $games = $this->Game->getAll();
- foreach ($games as $game)
- {
- $revenues = $this->Monetization->sumAllGameRevenues($game->code);
- $moduleInfo = $this->Monetization->getModuleDetails($game->code);
- $cost = $revenues;
- $row = array();
- $row[] = anchor('monetization/game/' . $game->code . '.html', $game->name);
- $row[] = money($moduleInfo->installation_cost);
- $row[] = money($cost);
- $row[] = money($moduleInfo->installation_cost / MON_VAL_1);
- $row[] = money($cost > 0 ? $cost / MON_VAL_2 : 0);
- $gaming[$game->code] = $row;
- $sumRevenues = $sumRevenues + $cost;
- $sumSufficient = $sumSufficient + ($cost / MON_VAL_2);
- $sumBuildCost = $sumBuildCost + $moduleInfo->installation_cost;
- }
-
- // Coin flip game. Use this function to model all future games so they fit
- // here nicely.
- $gameMonetizationData = $this->CoinFlip->getGameMonetizationData();
- $sumRevenues += $gameMonetizationData->cost;
- $sumSufficient += $sumSufficient + ($gameMonetizationData->cost / MON_VAL_2);
- $sumBuildCost += $gameMonetizationData->moduleInfo->installation_cost;
- $gaming[$gameMonetizationData->gameData->code] = $gameMonetizationData->viewRows;
-
- // Blackjack
- $gameMonetizationData = $this->Blackjack->getGameMonetizationData();
- $sumRevenues += $gameMonetizationData->cost;
- $sumSufficient += $sumSufficient + ($gameMonetizationData->cost / MON_VAL_2);
- $sumBuildCost += $gameMonetizationData->moduleInfo->installation_cost;
- $gaming[$gameMonetizationData->gameData->code] = $gameMonetizationData->viewRows;
-
- // [ADD OTHER GAMES HERE]
-
-
- $totalInvested = $this->Investment->getTotalInvested();
- $this->layoutData['member_page'] = 'Monetization Portfolio';
- $this->loadView('monetization/index', 'My Traffic Value: Monetization Portfolio', compact('guest', 'cashier', 'shares', 'gaming', 'sumRevenues', 'sumSufficient', 'sumBuildCost', 'totalInvested'));
- }
- //Monetization Portfolio -> view details of deposit method
- public function revenue_method($code, $page = 1)
- {
- $moduleDetails = $this->Monetization->getModuleDetails($code);
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->Monetization->getMonetizationDays($code, $startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url('monetization/revenue_method/' . $code), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/revenue_method', compact('guest', 'code', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $revenues = $this->Monetization->sumAllrevenues($code);
- $otherCosts = $this->Monetization->sumAllOtherCosts($code);
- $uniqueUsers = $this->Monetization->getUniqueUsers($code);
- $billing = $this->PaymentMethod->getLatestBillDetails($code);
- $methodName = $this->PaymentMethod->getNameFromCode($code);
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - ' . $methodName;
- $this->loadView('monetization/revenue_method', 'My Traffic Value: Monetization Portfolio - ' . $methodName, compact('guest', 'methodName', 'moduleDetails', 'revenues', 'otherCosts', 'breakdown', 'uniqueUsers', 'billing'));
- }
- }
- //Monetization Portfolio -> Deposit Method -> view date
- public function daily_revenue_method($code, $day, $type = null, $page = 1, $perpage = 20)
- {
- $date = strtotime($day);
- $this->load->model('transaction_model', 'Transaction');
- if (!$type || $type == 'deposit')
- {
- $count = $this->Transaction->countTransactions($code, 'deposit', 'ok', $date);
- $data = $this->Transaction->getDepositsSubset($code, 'ok', $page, $perpage, $date);
- $transactionType = 'deposit';
- $paging = generatePagination(site_url('monetization/daily_revenue_method/' . $code . '/' . $day . '/' . $transactionType), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $deposits = $this->loadPartialView('monetization/partial/daily_revenue_method_transactions', compact('date', 'transactionType', 'paging', 'hasPages', 'count', 'data'));
- if ($this->input->is_ajax_request())
- {
- echo $deposits;
- return;
- }
- }
- if (!$type || $type == 'cashout')
- {
- $count = $this->Transaction->countTransactions($code, 'cashout', 'ok', $date);
- $data = $this->Transaction->getCashoutsSubset($code, 'ok', $page, $perpage, $date);
- $transactionType = 'cashout';
- $paging = generatePagination(site_url('monetization/daily_revenue_method/' . $code . '/' . $day . '/' . $transactionType), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $cashouts = $this->loadPartialView('monetization/partial/daily_revenue_method_transactions', compact('date', 'transactionType', 'paging', 'hasPages', 'count', 'data'));
- if ($this->input->is_ajax_request())
- {
- echo $cashouts;
- return;
- }
- }
- $guest = $this->guest;
- $billing = $this->PaymentMethod->getLatestBillDetails($code, $date);
- $methodName = $this->PaymentMethod->getNameFromCode($code);
- $depositRevenues = $this->Monetization->sumAllrevenues($code, 'deposit', $date);
- $cashoutRevenues = $this->Monetization->sumAllrevenues($code, 'cashout', $date);
- $otherCosts = $this->Monetization->sumAllOtherCosts($code, $date);
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/method/' . $code . '.html', $methodName) . ' - ' . $day;
- $this->loadView('monetization/daily_revenue_method', "My Traffic Value: Monetization Portfolio - $methodName - DATE", compact('guest', 'methodName', 'deposits', 'cashouts', 'otherCosts', 'billing', 'date', 'depositRevenues', 'cashoutRevenues'));
- }
- // Share Transfers
- public function share_transfers($page = 1)
- {
- $moduleDetails = $this->Monetization->getModuleDetails('shares');
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->Monetization->getMonetizationSharesDays($startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url('monetization/share_transfers'), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/share_transfers', compact('guest', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $revenues = $this->Monetization->sumAllShareRevenues();
- $uniqueUsers = $this->Monetization->getUniqueShareUsers();
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - Share Transfers';
- $this->loadView('monetization/share_transfers', 'My Traffic Value: Monetization Portfolio - Share Transfers', compact('guest', 'moduleDetails', 'revenues', 'breakdown', 'uniqueUsers'));
- }
- }
- // Daily Share Transfers
- public function daily_revenue_shares($day, $page = 1, $perpage = 20)
- {
- $date = strtotime($day);
- $this->load->model('shares_model', 'Shares');
- $count = $this->Shares->getTransfersCount(false, $date, 'ok');
- $data = $this->Shares->getTransfersSubset($page, $perpage, false, $date, 'ok');
- $paging = generatePagination(site_url('monetization/daily_revenue_shares/' . $day), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $transfers = $this->loadPartialView('monetization/partial/daily_revenue_shares', compact('date', 'transactionType', 'paging', 'hasPages', 'count', 'data'));
- if ($this->input->is_ajax_request())
- {
- echo $transfers;
- return;
- }
- $guest = $this->guest;
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/shares.html', 'Share Transfers') . ' - ' . $day;
- $this->loadView('monetization/daily_revenue_shares', "My Traffic Value: Monetization Portfolio - Share Transfers - $day", compact('guest', 'transfers', 'date'));
- }
- // Investment
- public function direct_investment($page = 1)
- {
- $moduleDetails = $this->Monetization->getModuleDetails('invest');
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->Monetization->getMonetizationInvestmentDays($startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url('monetization/direct_investment'), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/direct_investments', compact('guest', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $uniqueUsers = $this->Monetization->getUniqueInvestmentUsers();
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - Direct Invest Contributions';
- $this->loadView('monetization/direct_investment', 'My Traffic Value: Monetization Portfolio - Direct Invest Contributions', compact('guest', 'moduleDetails', 'breakdown', 'uniqueUsers'));
- }
- }
- // Daily Share Transfers
- public function daily_direct_investment($day, $page = 1, $perpage = 20)
- {
- $date = strtotime($day);
- $this->load->model('investment_model', 'Investment');
- $count = $this->Investment->getUnitsCount($date);
- $data = $this->Investment->getUnitsSubset($date, $page, $perpage);
- $paging = generatePagination(site_url('monetization/daily_direct_investment/' . $day), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $investments = $this->loadPartialView('monetization/partial/daily_direct_investment', compact('date', 'paging', 'hasPages', 'count', 'data'));
- if ($this->input->is_ajax_request())
- {
- echo $investments;
- return;
- }
- $guest = $this->guest;
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/investment.html', 'Direct Invest Contributions') . ' - ' . $day;
- $this->loadView('monetization/daily_direct_investment', "My Traffic Value: Monetization Portfolio - Direct Invest Contributions - $day", compact('guest', 'investments', 'date'));
- }
-
- // Change Game
- public function standard_game($code, $page = 1)
- {
- $gameData = $this->Game->getGameData($code);
- if (!$gameData) show_404();
- $moduleDetails = $this->Monetization->getModuleDetails($code);
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->Monetization->getMonetizationGameDays($code, $startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url('monetization/standard_game/' . $code), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/standard_game', compact('guest', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages', 'gameData'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $uniqueUsers = $this->Monetization->getUniqueGameUsers($code);
- $revenues = $this->Monetization->sumAllGameRevenues($code);
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - The ' . $gameData->name;
- $this->loadView('monetization/standard_game', 'My Traffic Value: Monetization Portfolio - The ' . $gameData->name, compact('guest', 'moduleDetails', 'breakdown', 'uniqueUsers', 'revenues', 'gameData'));
- }
- }
-
- // Con flip Game
- public function coin_flip_game($page = 1)
- {
- $code = "coin_flip";
- $paginationTitle = "coin_flip_game";
- $gameMonetizationData = $this->CoinFlip->getGameMonetizationData();
- $revenues = $gameMonetizationData->revenues;
-
- $houseEdge = $gameMonetizationData->houseEdge;
- $uniqueUsers = $gameMonetizationData->uniqueUsers;
- $gameData = $this->Game->getGameData($code);
- if (!$gameData) show_404();
-
- $moduleDetails = $this->Monetization->getModuleDetails($code);
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
-
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->CoinFlip->getMonetizationGameDays($startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url("monetization/$paginationTitle"), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/standard_game', compact('guest', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages', 'gameData', 'houseEdge'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - The ' . $gameData->name;
- $this->loadView('monetization/standard_game', 'My Traffic Value: Monetization Portfolio - The ' . $gameData->name, compact('guest', 'moduleDetails', 'breakdown', 'uniqueUsers', 'revenues', 'gameData'));
- }
- }
-
- // Blackjack
- public function blackjack_game($page = 1)
- {
- $code = "blackjack";
- $paginationTitle = "blackjack_game";
- $gameMonetizationData = $this->Blackjack->getGameMonetizationData();
- $revenues = $gameMonetizationData->revenues;
-
- $houseEdge = $gameMonetizationData->houseEdge;
- $uniqueUsers = $gameMonetizationData->uniqueUsers;
- $gameData = $this->Game->getGameData($code);
- if (!$gameData) show_404();
-
- $moduleDetails = $this->Monetization->getModuleDetails($code);
- $guest = $this->guest;
- if (!$moduleDetails) show_404();
-
- $monthInstall = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), 1, date("Y", $moduleDetails->installation_date));
- // Work out how many pages we will have from the installation date until now
- $pages = 0;
- while ($monthInstall < now())
- {
- $pages++;
- $monthInstall = strtotime("+1 month", $monthInstall);
- }
-
- // We need to calculate the start of the month depending on the page we are on
- $_page = $page - 1;
- $pageDate = $_page ? strtotime("-$_page month", now()) : now();
- // A few dates to help with the data to display
- $now = mktime(0, 0, 0, date("n", now()), date("j", now()), date("Y", now()));
- $installDay = mktime(0, 0, 0, date("n", $moduleDetails->installation_date), date("j", $moduleDetails->installation_date), date("Y", $moduleDetails->installation_date));
- $startMonth = mktime(0, 0, 0, date("n", $pageDate), 1, date("Y", $pageDate));
- $nextMonth = strtotime("+1 month", $startMonth);
- $dailyResults = $this->Blackjack->getMonetizationGameDays($startMonth);
- // Last day of the month to display
- $lastDay = strtotime("-1 day", $nextMonth);
- // But are we in the current month and is the last day in the future? if Yes then stop at today
- $lastDay = min($lastDay, $now);
- // The first day in the list will either be the 1st of the month OR the installation date - whichever is greater
- $firstDay = max($startMonth, $installDay);
- $paging = generatePagination(site_url("monetization/$paginationTitle"), $pages, $page, 1, true);
- $hasPages = $pages;
- $breakdown = $this->loadPartialView('monetization/partial/standard_game', compact('guest', 'dailyResults', 'lastDay', 'firstDay', 'paging', 'hasPages', 'gameData', 'houseEdge'));
- if ($this->input->is_ajax_request())
- {
- echo $breakdown;
- }
- else
- {
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor('monetization.html', 'Monetization Portfolio') . ' - The ' . $gameData->name;
- $this->loadView('monetization/standard_game', 'My Traffic Value: Monetization Portfolio - The ' . $gameData->name, compact('guest', 'moduleDetails', 'breakdown', 'uniqueUsers', 'revenues', 'gameData'));
- }
- }
-
- public function daily_coin_flip($day, $page = 1, $perpage = 20)
- {
- $code = "coin_flip";
- $gameData = $this->CoinFlip->getGameData();
- $date = strtotime($day);
- $count = $this->CoinFlip->getPlaysCount($date);
- $data = $this->CoinFlip->getPlaysSubset($date, $page, $perpage);
- $paging = generatePagination(site_url("monetization/daily_$code/" . $day), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $plays = $this->loadPartialView("monetization/partial/daily_$code", compact('date', 'paging', 'hasPages', 'count', 'data', 'gameData'));
- if ($this->input->is_ajax_request())
- {
- echo $plays;
- return;
- }
- $guest = $this->guest;
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/game/' . $code . '.html', 'The ' . $gameData->name) . ' - ' . $day;
- $this->loadView('monetization/daily_standard_game', "My Traffic Value: Monetization Portfolio - The ' . $gameData->name . ' - $day", compact('guest', 'plays', 'date', 'gameData'));
- }
-
- public function daily_blackjack($day, $page = 1, $perpage = 20)
- {
- $gameData = $this->Blackjack->getGameData();
- $code = $gameData->code;
- $date = strtotime($day);
- $count = $this->Blackjack->getPlaysCount($date);
- $data = $this->Blackjack->getPlaysSubset($date, $page, $perpage);
- $paging = generatePagination(site_url("monetization/daily_$code/" . $day), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $plays = $this->loadPartialView("monetization/partial/daily_$code", compact('date', 'paging', 'hasPages', 'count', 'data', 'gameData'));
- if ($this->input->is_ajax_request())
- {
- echo $plays;
- return;
- }
- $guest = $this->guest;
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/game/' . $code . '.html', 'The ' . $gameData->name) . ' - ' . $day;
- $this->loadView('monetization/daily_standard_game', "My Traffic Value: Monetization Portfolio - The ' . $gameData->name . ' - $day", compact('guest', 'plays', 'date', 'gameData'));
- }
-
- // Daily Share Transfers
- public function daily_standard_game($code, $day, $page = 1, $perpage = 20)
- {
- $gameData = $this->Game->getGameData($code);
- $date = strtotime($day);
- $count = $this->Game->getPlaysCount($code, $date);
- $data = $this->Game->getPlaysSubset($code, $date, $page, $perpage);
- $paging = generatePagination(site_url("monetization/daily_standard_game/" . $code . "/" . $day), $count, $page, $perpage, true);
- $hasPages = $count > $perpage;
- $plays = $this->loadPartialView("monetization/partial/daily_standard_game", compact('date', 'paging', 'hasPages', 'count', 'data', 'gameData'));
- if ($this->input->is_ajax_request())
- {
- echo $plays;
- return;
- }
- $guest = $this->guest;
- $this->addJavascript(asset('scripts/paging.js'));
- $this->layoutData['member_page'] = anchor ('monetization.html', 'Monetization Portfolio') . ' - ' . anchor('monetization/game/' . $code . '.html', 'The ' . $gameData->name) . ' - ' . $day;
- $this->loadView('monetization/daily_standard_game', "My Traffic Value: Monetization Portfolio - The ' . $gameData->name . ' - $day", compact('guest', 'plays', 'date', 'gameData'));
- }
- }