Example #1
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  * 	- or -
  * 		http://example.com/index.php/welcome/index
  * 	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see https://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $this->data['pagebody'] = 'home';
     // this is the view we want shown
     // Add Page-specific style to load
     $this->pageStyles[] = "home";
     $this->pageStyles[] = "https://cdn.datatables.net/t/dt/dt-1.10.11,fh-3.1.1,r-2.0.2/datatables.min.css";
     // Add Page-specific scripts to load
     $this->pageScripts[] = "https://cdn.datatables.net/t/dt/dt-1.10.11,fh-3.1.1,r-2.0.2/datatables.min.js";
     $this->pageScripts[] = "welcome";
     //get the data from all tables
     $players = $this->players->all_summary($this->getStatus()['round']);
     $cards = $this->collections->all();
     $table = $this->series->all();
     if (count($players)) {
         $playersTable = array();
         foreach ($players as $player) {
             $pRow = array('link' => $this->data['appRoot'] . "/player/" . $player->Player, 'Player' => $player->Player, 'Peanuts' => $player->Peanuts, 'Equity' => count($this->collections->some('Player', $player->Player)) + $player->Peanuts);
             $playersTable[] = $pRow;
         }
         // Obtain a list of columns
         foreach ($playersTable as $key => $row) {
             $equity[$key] = $row['Equity'];
             $name[$key] = $row['Player'];
         }
         // Sort the data with equity descending, player name ascending
         // Add $playersTable as the last parameter, to sort by the common key
         array_multisort($equity, SORT_DESC, $name, SORT_ASC, $playersTable);
         $PlayerSummary['Players'] = $playersTable;
         $this->data['playerInfo'] = $this->parser->parse('_playerinfo1', $PlayerSummary, true);
     } else {
         // No Recent/active players
         $this->data['playerInfo'] = "";
     }
     $series = array();
     foreach ($table as $type) {
         $row = array('Series' => $type->Series, 'Description' => $type->Description, 'Frequency' => $type->Frequency, 'Value' => $type->Value, 'Quantity' => 0);
         $series[] = $row;
     }
     // Get all cards in db
     foreach ($cards as $card) {
         $key = array_search(substr($card->Piece, 0, 2), array_column($series, 'Series'));
         $series[$key]['Quantity']++;
     }
     // prep for ci parser
     $summary['collection'] = $series;
     $this->data['botPieceSummary'] = $this->parser->parse('_pieceSummary', $summary, true);
     $transactions = csv_to_assoc($this->agent->get('server_URL')->value . "/data/transactions/10");
     $this->data['serverLatestActivity'] = $this->parser->parse('_transactions_global', array('transactions' => $transactions), true);
     $agent_transactions = $this->getLatestTransactions();
     $this->data['agentLatestActivity'] = $this->parser->parse('_transactions_agent', array('transactions' => $agent_transactions), true);
     $this->render();
 }
Example #2
0
 function getBotSeries($serverURL)
 {
     $response = csv_to_assoc($serverURL . "/data/series");
     $result = array();
     foreach ($response as $one) {
         $record = array();
         foreach ($one as $key => $value) {
             if ($key == 'code') {
                 $key = 'series';
             }
             $record[ucfirst($key)] = $value;
         }
         $result[] = $record;
     }
     // Get current series known in agent
     $current = $this->all();
     $compare = array();
     foreach ($current as $one) {
         $compare[] = get_object_vars($one);
     }
     $different = false;
     // Check if equal records
     if (count($result) == count($compare)) {
         for ($x = 0; $x < count($result); $x++) {
             $check = !empty(array_diff_assoc($result[$x], $compare[$x]));
             if ($check) {
                 $different = true;
                 break;
             }
         }
     } else {
         $different = true;
     }
     if ($different) {
         // Delete all records from series
         $this->truncate();
         // Add records from server
         $this->add_batch($result);
     }
 }