public function getDisplay($email)
 {
     $obj = new database();
     $stuArr = $obj->getStudent($email);
     $stuGroup = $obj->getGroup($stuArr['hotel']);
     $stuLoc = $obj->getLocation($stuGroup['location']);
     //$str = implode(" ", $stuGroup);
     //print_r($stuGroup['name']);
     $game = $obj->getGame($stuGroup['game']);
     $period = $game['periodNum'] - 1;
     //var_dump($period);
     //print_r("current period is " . $period);
     $periodDecName = "GAME_" . $stuGroup['game'] . "_P_" . $period;
     $decisions = $obj->getStudentDecisions($periodDecName, $stuGroup['id']);
     // = false for first period
     $advertTotal = $obj->getadvertising();
     $adSize = count($advertTotal);
     //getting advertising list for home display - this is only those selected by student
     $personnelName = $obj->getPersonnel();
     //var_dump($personnelName);
     $personnel = array();
     $temp = "You have selected:<br/>";
     $advertising = array();
     if ($decisions != false) {
         for ($a = 1; $a < $adSize; $a++) {
             $adv = "adv" . $a;
             if ($decisions[$adv] == 0) {
                 break;
             } else {
                 $temp = $obj->getadvertisingNameAndPrice($a);
                 array_push($advertising, $temp);
                 // $advertising [0][0]['type'] then [1][0] and [2][0] to access
             }
         }
         //getting selected personnel
         for ($a = 1; $a < 4; $a++) {
             $per = "P" . $a;
             if ($decisions[$per] != 0) {
                 $temp .= "<p>" . $a . " " . $personnelName[$a]['name'] . " \$" . $personnelName[$a]['cost'] * $a . "</p>";
                 array_push($personnel, $temp);
             }
         }
     }
     $groups = $obj->getGameGroupsId($stuGroup['game']);
     //var_dump($groups);
     $returnArray = array();
     $makertshare = periodController::marketShare($periodDecName, $game, $groups, $period);
     // this will be moved to commit later
     $groupcount = $obj->getGameGroupCount($game['id']);
     $groupcount = implode("", $groupcount);
     //var_dump($groups);
     //var_dump($stuGroup['id']);
     //var_dump($makertshare);
     if ($makertshare != false) {
         $marketShareByGroup = array();
         for ($k = 0; $k < $groupcount; $k++) {
             $id = $groups[$k]['id'];
             $temp = "group" . $id;
             array_push($marketShareByGroup, $makertshare[$temp]);
         }
     } else {
         $marketShareByGroup = false;
     }
     $rev = $obj->getRevenue($stuArr['hotel']);
     $leaderboard = $obj->getLeaderboardTable($stuGroup['game']);
     //sorting array to present in descending order
     for ($i = 0; $i < count($leaderboard); $i++) {
         for ($j = 0; $j < count($leaderboard); $j++) {
             if (intval($leaderboard[$i]['revenue']) > intval($leaderboard[$j]['revenue'])) {
                 $temp = $leaderboard[$j]['revenue'];
                 $leaderboard[$j]['revenue'] = $leaderboard[$i]['revenue'];
                 $leaderboard[$i]['revenue'] = $temp;
             }
         }
     }
     $selectedResearch = $obj->getPeriodResearch($periodDecName, $stuGroup['id']);
     $researched = array();
     //var_dump($selectedResearch);
     if ($selectedResearch != false) {
         foreach ($selectedResearch as $res) {
             foreach ($res as $r) {
                 //var_dump($res);
                 if ($r != "NULL") {
                     array_push($researched, $r);
                 }
             }
         }
     }
     //var_dump($researched);
     $researchDisplay = "You have not selected a group to research yet";
     $researchDisplay2 = "";
     $resCount = 1;
     if (count($researched) > 0) {
         $temp = "research" . $resCount;
         $researchDisplay = "</h4><h4 style = 'color:green'>" . $researched[0] . "<h4 style='font-weight: bold'>\n\t\t\t\t\t\t\t\t<h4>Average rate : \$";
         $id = $obj->gethotelIdbyName($researched[0]);
         //Var_dump($researched[0]);
         $decs = $obj->getStudentDecisions($periodDecName, $id[0]['id']);
         //var_dump($decs);
         $researchDisplay .= $decs['aveRate'];
         //Var_dump($decs['aveRate']);
         $resAdvert = array();
         for ($a = 1; $a < $adSize; $a++) {
             $adv = "adv" . $a;
             if ($decisions[$adv] == 0) {
                 break;
             } else {
                 $temp = $obj->getadvertisingNameAndPrice($a);
                 array_push($resAdvert, $temp);
                 // $advertising [0][0]['type'] then [1][0] and [2][0] to access
             }
         }
         $i = 0;
         $researchDisplay .= "</h4><h4 style='font-weight: bold'> Advertising:</h4><h4>";
         foreach ($resAdvert as $ad) {
             //print_r($resAdvert[$i][0]['type']);
             $researchDisplay .= "<h4>" . $resAdvert[$i][0]['type'] . "</h4>";
             $i++;
         }
         $researchDisplay2 .= "<br/><h4 style='font-weight: bold'>Number of personnel<h4><h4>Entry Level : " . $decs['P1'] . "</h4>\n\t\t\t\t<h4>Manager in training : " . $decs['P2'] . "</h4>\n\t\t\t\t<h4>Experienced Professional : " . $decs['P3'] . "</h4>";
         $researchDisplay2 .= "<h4 style='font-weight: bold'>OTA Allocations : " . $decs['OTA'] . "</h4>";
     }
     //var_dump($leaderboard);
     // I need to return research for the prior period.  That means that I need to update the database with all the entries
     //I think I will merely return a string here or empty string if use hasn't selected research
     array_push($returnArray, $decisions, $stuArr, $stuGroup, $stuLoc, $game, $periodDecName, $advertising, $personnel, $period, $makertshare, $marketShareByGroup, $groups, $rev, $leaderboard, $researchDisplay, $researchDisplay2);
     return $returnArray;
 }
Exemplo n.º 2
0
require 'Model/database.php';
require '/srv/marketsim/www/Controller/periodController.php';
$stuArr = array();
$stuGroup = array();
session_start();
if (isset($_SESSION['admin login'])) {
    header("Location: /admin/ManagePage.php");
    exit;
} else {
    if (!isset($_SESSION['login user'])) {
        header("Location: /login.php");
        exit;
    } else {
        echo "<div style = 'text-align: left; padding-left: 25px'>" . $_SESSION['login user'] . " is not you? login \n\t\t\t<a href='/login.php'> here</a>\n\t\t</div>";
        $email = $_SESSION['login user'];
        $periodDecs = new periodController();
        $displayArr = $periodDecs->getDisplay($email);
        //var_dump($displayArr);
        //var_dump($displayArr);
        $decisions = $displayArr[0];
        $stuArr = $displayArr[1];
        $stuGroup = $displayArr[2];
        $stuLoc = $displayArr[3];
        $periodDecName = $displayArr[5];
        $aveRate = $decisions['aveRate'];
        $advertising = $displayArr[6];
        $personnel = $displayArr[7];
        $periodNum = $displayArr[8];
        $marketshare = $displayArr[9];
        $marketShareByGroup = $displayArr[10];
        // false if it is the first period
Exemplo n.º 3
0
<?php

require '/srv/marketsim/www/Controller/periodController.php';
require "/srv/marketsim/www/Model/database.php";
session_start();
if (isset($_SESSION['login user'])) {
    $email = $_SESSION['login user'];
    //do nothing
} else {
    header("Location: /login.php");
}
if (isset($_POST['commitText'])) {
    $comments = $_POST['commitText'];
    //echo $comments;
    $obj = new periodController();
    $obj->commit($comments, $email);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Commit</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>