Пример #1
0
 public function getVisitorData($stattype = "events", $distinguishNordic = FALSE, $distinguishBaltic = FALSE, $countPolandAsBaltic = FALSE, $onlyShowNordic = FALSE, $confids = array())
 {
     $from_timestamp = "UNIX_TIMESTAMP('2007-01-01 00:00:00')";
     $to_timestamp = "UNIX_TIMESTAMP()";
     //$from_timestamp = "UNIX_TIMESTAMP('2009-01-01 00:00:00')";
     //$to_timestamp   = "UNIX_TIMESTAMP('2010-12-31 00:00:00')";
     if (isset($confids[0])) {
         unset($confids[0]);
     }
     $where = $tmp = array();
     if (in_array($stattype, array("visitors"))) {
         $where[] = "((" . $from_timestamp . "<V.v_start) AND (V.v_start<" . $to_timestamp . "))";
     }
     if (!empty($confids)) {
         foreach ($confids as $id) {
             $tmp[] = "E.e_code='" . $id . "'";
         }
         $where[] = implode(" OR ", $tmp);
     }
     $where[] = "V.v_status <> 'STATUS_NO'";
     $sql = "\nSELECT\n  A.av_firstname,\n  A.av_lastname,\n  A.av_residentship,\n  A.av_city,\n  A.av_institute,\n  E.e_code,\n  E.e_name,\n  V.v_start,\n  V.v_end,\n" . "\n  V.v_type\nFROM\n  abs_visits AS V\n  LEFT JOIN zzz_avatars AS A ON A.av_id=V.v_avid\n  LEFT JOIN abs_events AS E ON E.e_code=SUBSTRING(V.v_code,1,LENGTH(E.e_code)) " . (!empty($where) ? " WHERE (" . implode(") AND (", $where) . ") " : "") . " ORDER BY\n  A.av_lastname,A.av_firstname,V.v_start";
     // v_type: _COLL, _RENT, _PROG
     $res = $this->query($sql, IS_TESTSERVER);
     // includes a call to connect
     if (!$res || $this->num_rows($res) == 0) {
         return array();
     }
     // ------------------------
     // Convert search result to array of data type visitorDataRecord
     //   $applicant[][lastname,firstname,citizenship,residentship,ms,phd,
     //                 cit_continent,res_continent,ms_continent,phd_continent,
     //                 nordic,baltic,event]
     // ------------------------
     $applicant = array();
     while ($cell = $this->next_record_assoc($res)) {
         switch ($stattype) {
             case "allguests":
             case "events":
                 $select = !empty($cell["e_code"]) ? true : false;
                 break;
             case "visitors":
                 $select = $cell["v_type"] == "_COLL" ? true : false;
                 break;
             case "brief":
                 $select = !empty($cell["e_code"]) && $cell["v_type"] == "_COLL" ? true : false;
                 break;
             default:
                 return array();
         }
         // end switch
         if ($select) {
             if (strlen($cell["av_residentship"]) > 2) {
                 $cell["av_residentship"] = functions::fromCountryToCodeAdHoc($cell["av_residentship"]);
             } else {
                 if ($cell["av_residentship"] == "SX") {
                     $cell["av_residentship"] = "RS";
                 }
             }
             $applicant[] = array("lastname" => mb_convert_case($cell["av_lastname"], MB_CASE_TITLE, "UTF-8"), "firstname" => mb_convert_case($cell["av_firstname"], MB_CASE_TITLE, "UTF-8"), "institute" => $cell["av_institute"], "cit" => "", "res" => $cell["av_residentship"], "ms" => "", "phd" => "", "cit_continent" => "", "res_continent" => functions::fromCountryCodeTo("continentcode", $cell["av_residentship"], $distinguishNordic, $distinguishBaltic, $countPolandAsBaltic), "ms_continent" => "", "phd_continent" => "", "nordic" => functions::isInRegion("nordic", array($cell["av_residentship"]), $countPolandAsBaltic), "baltic" => functions::isInRegion("baltic", array($cell["av_residentship"]), $countPolandAsBaltic), "local" => strpos($cell["av_city"], "Stockholm") !== false ? 1 : 0, "id" => $cell["e_code"], "visit_start" => $cell["v_start"], "visit_end" => $cell["v_end"]);
         }
         // end if
     }
     // end while
     return $applicant;
 }
Пример #2
0
 private static function outputPeopleLayoutEmployment($employmentarray = array())
 {
     if (empty($employmentarray)) {
         return BLURB_SORRY_PEOPLE;
     }
     $stdout = "";
     $stat = array();
     functions::gpc_declare_input("sd", "2007-01-01", false);
     // start date
     functions::gpc_declare_input("ed", date("Y-m-d"), false);
     // end date
     functions::gpc_declare_input("current", 0, true);
     // end date
     // ---------------------------------------------------------------------------
     // ADAPT DATA
     // ---------------------------------------------------------------------------
     // Only want people who are or have been Nordita employees or visitors (board doesn't count)
     // Only want employment records within the selected time interval
     foreach ($employmentarray as $avid => $person) {
         if (!$person["nw_isnorditaalumn"] || !$GLOBALS["current"] && $person["nw_current_isnorditastaff"]) {
             unset($employmentarray[$avid]);
         } else {
             foreach ($person["nw_nordita_employment"] as $key => $entry) {
                 if (!$entry["nw_employment_isnorditaemployment"] || !functions::isFirstIntervalInSecondInterval($entry["nw_employment_fromdate"], $entry["nw_employment_todate"], $GLOBALS["sd"], $GLOBALS["ed"])) {
                     unset($employmentarray[$avid]["nw_nordita_employment"][$key]);
                 }
             }
         }
     }
     // ---------------------------------------------------------------------------
     // OUTPUT TO SCREEN
     // ---------------------------------------------------------------------------
     $stdout .= " <form action='" . $_SERVER["PHP_SELF"] . "' method='post' style='margin-bottom:2em'>\r\n" . "   <p>Only list alumni positions between these dates:\r\n" . "   from <input type='date' name='sd' value='" . $GLOBALS["sd"] . "' size='10' style='margin: 0 0.5em'>\r\n" . "   to <input type='date' name='ed' value='" . $GLOBALS["ed"] . "' size='10' style='margin: 0 0.5em'></p>\r\n" . "   Also show current Nordita staff <input type='checkbox' name='current' value='1'" . ($GLOBALS["current"] ? " checked='checked'" : "") . "></p>\r\n" . "   <p><input type='submit' value='Redraw the table with these settings!' style='margin: 0 1em'></p>\r\n" . "   " . "</form>\r\n" . "\r\n";
     $stdout .= " <table class='b_zebra' style='border-top:2px solid black;border-bottom:2px solid black'>\r\n";
     $stdout .= " <thead>\r\n" . " <tr>\r\n" . "   <th style='padding:0'></th>\r\n" . "   <th style='padding:0.5em'>Name</th>\r\n" . "   <th style='padding:0.5em'>Current affiliation (if&nbsp;known)</th>\r\n" . "   <th style='padding:0.5em'>Period of employment or visit</th>\r\n" . "   <th style='padding:0.5em'>Position</th>\r\n" . " </tr>\r\n" . " </thead>\r\n";
     $stdout .= " <tbody>\r\n";
     $row = 1;
     foreach ($employmentarray as $avid => $item) {
         $class = "b_zebra" . ($row % 2 + 1);
         $rows = isset($item["nw_nordita_employment"]) ? count($item["nw_nordita_employment"]) : 1;
         if ($item["nw_current_isnorditastaff"]) {
             $img = "<img src='img/favicon.png' alt=''>";
         } elseif ($item["nw_current_isnordic"] && !empty($item["nw_current_country"])) {
             $img = "<img src='img/_flags/png_16x11/" . strtolower($item["nw_current_country"]) . ".png' alt=''>";
         } else {
             $img = "";
         }
         $pdata = " <tr>\r\n" . "   <td rowspan='" . $rows . "' style='width:16px;padding:3px 0.5em 0 0'>" . $img . "</td>\r\n" . "   <td class='" . $class . " bold nowrap' title='" . $item["nw_fullname_reverse"] . "' " . "rowspan='" . $rows . "'>" . $item["nw_fullname_reverse"] . ($item["nw_deceased"] ? " [&#8224;]" : "") . "</td>\r\n" . "   <td class='" . $class . "' rowspan='" . $rows . "' style='border-right:1px dotted #666'>" . (!empty($item["nw_current_title"]) ? "<em>" . $item["nw_current_title"] . "</em><br>" : "") . "<span class='bold'>" . $item["nw_current_email"] . "</span><br>" . $item["nw_current_institute"] . ($item["nw_current_isnordic"] && $item["nw_current_institute"] != "Nordita" && !empty($item["nw_current_country"]) ? "<br><span class='green bold'>" . functions::fromCountryCodeTo("country", $item["nw_current_country"]) . "</span>" : "") . "</td>\r\n" . "";
         $edata = "";
         $i = 0;
         foreach ($item["nw_nordita_employment"] as $entry) {
             $edata .= ($i ? " <tr>\r\n" : "") . "   <td class='" . $class . " nowrap'>&#8226; <em>" . $entry["nw_employment_date"] . "</em></td>\r\n" . "   <td class='" . $class . " nowrap'><em" . " title='" . (!empty($entry["nw_employment_type"]) ? $entry["nw_employment_type"] : "-") . "'" . ">" . $entry["nw_employment_title"] . "</em></td>\r\n" . " </tr>\r\n";
             $stat[strtolower($entry["nw_employment_type"])][strtolower($entry["nw_employment_title"])][] = $item["nw_fullname_reverse"];
             $i++;
         }
         // end foreach
         if (!empty($edata)) {
             $stdout .= $pdata . $edata;
             $row++;
         }
     }
     $stdout .= " </tbody>\r\n" . " </table>\r\n" . "\r\n";
     krsort($stat);
     foreach ($stat as $type => $data) {
         $stdout .= (!empty($type) ? "<h3>" . ucfirst($type) . "</h3>\r\n" : "<h3>[uncategorized]</h3>\r\n") . "<dl>\r\n";
         $a = $b = array();
         foreach ($data as $title => $item) {
             $stdout .= "<dd title='" . implode("; \r\n", $item) . "'><strong>" . count($item) . "</strong> " . $title . "</dd>\r\n";
         }
         $stdout .= "</dl>\r\n";
     }
     // -------------------------------------------------
     return $stdout;
 }
Пример #3
0
 private static function outputNationLists($stattype = "applicants", $nationlists = array(), $charts = array(), $aux = array(), $countPolandAsBaltic = FALSE, $showOnlyNordic = FALSE)
 {
     /* data = array(
          [0] => conts
          [1] => extconts
         //[2] => type
         //[3] => show
         //[4] => event
         //[5] => applicant
         //[6] => person
          [7] => columns
          [8] => extcolumns
          [9] => nationlists
          //[10] => pie
     ) */
     $stdout = "";
     $label = self::getEventLabel($stattype);
     switch ($stattype) {
         case "applicants":
             $caveattext = "per Application (not per individual applicant)";
             $summarytext1 = "applications";
             $summarytext2 = "applicants";
             break;
         case "events":
             $caveattext = "per Event (not per individual)";
             $summarytext1 = "participants";
             $summarytext2 = "";
             break;
         case "allguests":
             $caveattext = "per Event (not per individual)";
             $summarytext1 = "visits";
             $summarytext2 = "";
             break;
     }
     // end switch
     // ------------------------
     // Auxiliary parameters
     // -- $no_of_decimals
     // ------------------------
     $no_of_decimals = 0;
     // ------------------------
     // Output local styles
     // ------------------------
     if (count($aux["columns"]) > 3) {
         $stdout .= "          <style type='text/css'>.nationalities table { width: 100%; }</style>\r\n" . "\r\n";
     }
     // ------------------------
     // Output: table start code
     // ------------------------
     $table_start = "            <table>\r\n" . "              <tr>\r\n" . "                <th>&nbsp;</th>\r\n";
     foreach ($aux["extColumns"] as $coltitle) {
         $table_start .= "                <th>" . $coltitle . "</th>\r\n";
     }
     $table_start .= "              </tr>\r\n";
     // ------------------------
     // Output: loop over events
     // ------------------------
     foreach ($nationlists as $idx => $event) {
         if ((!isset($GLOBALS["beenthere"]) && ($idx == 0 || $stattype != "visitors") || isset($GLOBALS["eventindex"][$idx]) && ($idx != 0 || count($GLOBALS["eventindex"]) > 2) && ($idx != 0 || count($GLOBALS["eventindex"]) > 2)) && !empty($event["summary"]["total"])) {
             $stdout .= "          <div class='nationalities" . ($showOnlyNordic && !$idx ? " summary" : "") . ($showOnlyNordic && $idx ? " nordic" : "") . "'>\r\n" . "\r\n" . ($stattype != "visitors" ? "            <h2>" . $event["title"] . "</h2>\r\n" : "") . "\r\n";
             // ------------------------
             // Summary
             // ------------------------
             if (!$showOnlyNordic || !$idx) {
                 $stdout .= "            <h4>" . ($stattype != "visitors" ? "Statistics " . ($idx == 0 ? $caveattext : " for this " . ucfirst($label)) : "Total Visitor Statistics") . "</h4>\r\n";
             }
             $stdout .= "            <dl>\r\n" . "              <dd>Any Nordic Connection: " . "<strong>" . $event["summary"]["nordic"] . "</strong> &nbsp;&nbsp;" . "(" . $event["summary"]["nordicpr"] . "%)" . "</dd>\r\n" . "              <dd>No Nordic Connection: " . "<strong>" . $event["summary"]["nonordic"] . "</strong> &nbsp;&nbsp;" . "(" . (100 - $event["summary"]["nordicpr"]) . "%)" . "</dd>\r\n" . "              <dd>Total number of " . $summarytext1 . ": " . "<strong>" . $event["summary"]["total"] . "</strong></dd>\r\n" . ($idx == 0 ? "              <dd>[Number of unique " . $summarytext2 . ": " . "<strong>" . $event["summary"]["unique"] . "</strong>]</dd>\r\n" : "") . "            </dl>\r\n" . "\r\n";
             // ------------------------
             // By campaign
             // ------------------------
             //debug::rr($nationlists[0]);
             //debug::rr($nationlists[7]);
             if ($stattype == "applicants" && $idx == 0) {
                 // summary of all selected
                 $stdout .= "            <h4>Nordic Applicants, by Campaign:</h4>\r\n" . "            <table>\r\n" . "              <tr>\r\n" . "                <th>&nbsp;</th>\r\n" . "                <th>Total Number of&nbsp;Applications</th>\r\n" . "                <th>Nordic <br>Citizens</th>\r\n" . "                <th>Nordic <br>Residents</th>\r\n" . "                <th>Nordic PhD&nbsp;Degree</th>\r\n" . "              </tr>\r\n";
                 foreach ($nationlists as $nidx => $nevent) {
                     if ($nidx != 0) {
                         $brieftitle = strlen($nevent["title"]) > 45 ? substr($nevent["title"], 0, 38) . "... [" . $nevent["year"] . "]" : $nevent["title"];
                         $stdout .= "                <tr>\r\n" . "                  <td class='red bold'>" . $brieftitle . "</td>\r\n" . "                  <td><strong>" . $nationlists[$nidx]["summary"]["total"] . "</strong></td>\r\n" . "                  <td><strong>" . $nationlists[$nidx]["continent"]["NO"]["cit"] . "</strong> (" . round(100 * $nationlists[$nidx]["continent"]["NO"]["cit"] / $nationlists[$nidx]["summary"]["total"]) . "%)</td>\r\n" . "                  <td><strong>" . $nationlists[$nidx]["continent"]["NO"]["res"] . "</strong> (" . round(100 * $nationlists[$nidx]["continent"]["NO"]["res"] / $nationlists[$nidx]["summary"]["total"]) . "%)</td>\r\n" . "                  <td><strong>" . $nationlists[$nidx]["continent"]["NO"]["phd"] . "</strong> (" . round(100 * $nationlists[$nidx]["continent"]["NO"]["phd"] / $nationlists[$nidx]["summary"]["total"]) . "%)</td>\r\n" . "                </tr>\r\n";
                     }
                 }
                 $stdout .= "                <tr>\r\n" . "                  <td><em>Total, selected campaigns</em></td>\r\n" . "                  <td class='total'><strong>" . $nationlists[0]["summary"]["total"] . "</strong></td>\r\n" . "                  <td class='total'><strong>" . $nationlists[0]["continent"]["NO"]["cit"] . "</strong> (" . round(100 * $nationlists[0]["continent"]["NO"]["cit"] / $nationlists[0]["summary"]["total"]) . "%)</td>\r\n" . "                  <td class='total'><strong>" . $nationlists[0]["continent"]["NO"]["res"] . "</strong> (" . round(100 * $nationlists[0]["continent"]["NO"]["res"] / $nationlists[0]["summary"]["total"]) . "%)</td>\r\n" . "                  <td class='total'><strong>" . $nationlists[0]["continent"]["NO"]["phd"] . "</strong> (" . round(100 * $nationlists[0]["continent"]["NO"]["phd"] / $nationlists[0]["summary"]["total"]) . "%)</td>\r\n" . "                </tr>\r\n";
                 $stdout .= "            </table>\r\n" . "\r\n";
             }
             // end if
             // ------------------------
             // By continent
             // ------------------------
             if (!$showOnlyNordic) {
                 $noinfo = $event["continent"][""];
                 $stdout .= ($stattype != "applicants" || $idx ? "            <h4>By Region and Continent:</h4>\r\n" : "            <h4>All applicants, by Region and Continent:</h4>\r\n") . $table_start;
                 foreach ($aux["extConts"] as $cc => $item) {
                     if (!empty($cc)) {
                         $regular = "/(\\(except Nordic [^)]*\\))/iU";
                         $item = preg_replace($regular, "<span style='font-weight:normal;font-style:italic;color:#333;font-size:smaller;'>\\1</span>", $item);
                         $stdout .= "              <tr>\r\n" . "                <th" . ($cc == "NO" ? " class='nordic'" : ($cc == "BA" ? " class='baltic'" : "")) . ">" . $item . "</th>\r\n";
                         foreach ($aux["extColumns"] as $col => $dummy) {
                             if ($cc != "" || $col != "any") {
                                 $stdout .= !isset($event["continent"][$cc][$col]) ? "                <td" . ($col == "any" ? " class='any'" : "") . "><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n" : "                <td" . ($col == "any" ? " class='any'" : "") . "><strong>" . ($event["continent"][$cc][$col] + 0) . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["continent"][$cc][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                             }
                         }
                         $stdout .= "              </tr>\r\n";
                         // Subtotal for Europe, listed just after "rest of Europe" line
                         if ($cc == "EU") {
                             $stdout .= "              <tr>\r\n" . "                <td class='europe'><em>Total Europe</em></th>\r\n";
                             foreach ($aux["extColumns"] as $col => $dummy) {
                                 $stdout .= !isset($event["continent"]["eur"][$col]) ? "                <td" . ($col == "any" ? " class='any'" : "") . "><strong>0</strong>&nbsp;&nbsp;(0%)</td>" : "                <td class='europe" . ($col == "any" ? " any" : "") . "'><strong>" . ($event["continent"]["eur"][$col] + 0) . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["continent"]["eur"][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                             }
                             $stdout .= "              </tr>\r\n";
                         }
                         // end subtotal europe
                     }
                 }
                 // end foreach continent
                 $stdout .= "              <tr>\r\n" . "                <td class='total'><em>Total</em></td>\r\n";
                 foreach ($aux["extColumns"] as $col => $dummy) {
                     if ($col != "any") {
                         $stdout .= !isset($event["continent"]["tot"][$col]) ? "                <td class='total'><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n" : "                <td class='total'><strong>" . $event["continent"]["tot"][$col] . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["continent"]["tot"][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                     } else {
                         $stdout .= "                <td class='total'>&nbsp;</td>\r\n";
                     }
                 }
                 $stdout .= "              </tr>\r\n" . "              <tr>\r\n" . "                <td class='none'><em>No country information submitted</em></td>\r\n";
                 foreach ($aux["extColumns"] as $col => $dummy) {
                     if ($col != "any") {
                         $stdout .= !isset($noinfo[$col]) ? "                <td class='none'><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n" : "                <td class='none'><strong>" . $noinfo[$col] . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($noinfo[$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                     } else {
                         $stdout .= "                <td class='none'>&nbsp;</td>\r\n";
                     }
                 }
                 $stdout .= "              </tr>\r\n" . "            </table>\r\n" . "\r\n";
             }
             // end if
             // ------------------------
             // By Continent - Piechart
             // ------------------------
             if (!empty($charts) && !$showOnlyNordic) {
                 if (true && $idx == 0 && $stattype == "applicants") {
                     $stdout .= "          <div>\r\n";
                     foreach ($charts[$idx] as $col => $chartData) {
                         $stdout .= self::outputPiechart($idx . $col, $chartData, $aux["extColumns"][$col] . " - By Region and Continent", "370", "250", self::$palette["nbr"]);
                     }
                     $stdout .= "          </div>\r\n";
                 }
                 if (true && $idx == 0 && $stattype == "events") {
                     $stdout .= "          <div>\r\n";
                     foreach ($charts[$idx] as $col => $chartData) {
                         $stdout .= self::outputPiechart($idx . $col, $chartData, $aux["extColumns"][$col] . " - By Country", "350", "250", self::$palette["nbr"]);
                     }
                     $stdout .= "          </div>\r\n";
                 }
             }
             // end if
             // ------------------------
             // By Country
             // ------------------------
             $noinfo = isset($event["country"][""]) ? $event["country"][""] : array();
             if (!$showOnlyNordic) {
                 if ($stattype != "applicants" || $idx) {
                     $stdout .= "            <h4>By Country:</h4>\r\n";
                 } else {
                     $stdout .= "            <h4>All applicants, by Country:</h4>\r\n";
                 }
             } elseif (!$idx) {
                 $stdout .= "            <h4>Nordic applicants, by Country:</h4>\r\n";
             }
             $stdout .= $table_start;
             foreach ($event["country"] as $cc => $dummy) {
                 if (!empty($cc) && $cc != "tot" && (!$showOnlyNordic || functions::isInRegion("nordic", array($cc), FALSE))) {
                     $stdout .= "              <tr>\r\n" . "                <th" . (!$showOnlyNordic && functions::isInRegion("nordic", array($cc), $countPolandAsBaltic) ? " class='nordic'" : (!$showOnlyNordic && functions::isInRegion("baltic", array($cc), $countPolandAsBaltic) ? " class='baltic'" : "")) . ">" . functions::fromCountryCodeTo("country", $cc, in_array("NO", $aux["conts"]) ? true : false, in_array("BA", $aux["conts"]) ? true : false) . "</th>\r\n";
                     foreach ($aux["extColumns"] as $col => $dummy) {
                         if ($cc != "" || $col != "any") {
                             $stdout .= !isset($event["country"][$cc][$col]) ? "                <td><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n" : "                <td" . ($col == "any" ? " class='any'" : "") . "><strong>" . ($event["country"][$cc][$col] + 0) . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["country"][$cc][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                         }
                     }
                     $stdout .= "              </tr>\r\n";
                     if ($stattype == "events" && $cc == "SE") {
                         $stdout .= "              <tr>\r\n" . "                <td style='text-indent:1em;white-space:nowrap;font-style:italic'>Stockholm</td>\r\n" . "                <td style='text-indent:1em;white-space:nowrap;font-style:italic'>" . $event["country"]["local"][$col] . "&nbsp;&nbsp;(" . number_format(100 * ($event["country"]["local"][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n" . "              </tr>\r\n" . "              <tr>\r\n" . "                <td style='text-indent:1em;white-space:nowrap;font-style:italic'>non-locals</td>\r\n" . "                <td style='text-indent:1em;white-space:nowrap;font-style:italic'>" . ($event["country"]["SE"][$col] - $event["country"]["local"][$col]) . "&nbsp;&nbsp;(" . number_format(100 * ($event["country"]["SE"][$col] - $event["country"]["local"][$col]) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n" . "              </tr>\r\n";
                     }
                 }
             }
             // end foreach country
             $stdout .= "              <tr>\r\n" . "                <td><em>Total Nordic countries</em></td>\r\n";
             foreach ($aux["extColumns"] as $col => $dummy) {
                 if ($col != "any") {
                     if (!isset($event["country"]["tot"][$col])) {
                         $stdout .= "                <td class='total'><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n";
                     } elseif (!$showOnlyNordic) {
                         $stdout .= "                <td class='total'><strong>" . $event["country"]["tot"][$col] . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["country"]["tot"][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                     } else {
                         $stdout .= "                <td class='total'><strong>" . $event["continent"]["NO"][$col] . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($event["continent"]["NO"][$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                     }
                 } else {
                     $stdout .= "                <td class='total'>&nbsp;</td>\r\n";
                 }
             }
             $stdout .= "              </tr>\r\n" . "              <tr>\r\n" . "                <td class='none'><em>No country information submitted</em></td>\r\n";
             foreach ($aux["extColumns"] as $col => $dummy) {
                 if ($col != "any") {
                     $stdout .= !isset($noinfo[$col]) ? "                <td class='none'><strong>0</strong>&nbsp;&nbsp;(0%)</td>\r\n" : "                <td class='none'><strong>" . $noinfo[$col] . "</strong>&nbsp;&nbsp;(" . number_format(100 * ($noinfo[$col] + 0) / $event["summary"]["total"], $no_of_decimals) . "%)</td>\r\n";
                 } else {
                     $stdout .= "                <td class='none'>&nbsp;</td>\r\n";
                 }
             }
             $stdout .= "              </tr>\r\n" . "            </table>\r\n" . "\r\n";
             // ------------------------
             $stdout .= "          </div>\r\n" . "\r\n";
         }
     }
     // end foreach ($show as $idx => $event)
     return $stdout;
 }
Пример #4
0
 public static function OutputEventParticipants()
 {
     $stdout = "";
     $eventParticipants = $eventParticipantsThisDay = array();
     //    $visit = functions::callMethod('fromdb_vm','fromdb/vm','getArrivingVisitors');
     if (!isset($dbVm) || !is_object($dbVm)) {
         require_once PATH_CLASSES . "/fromdb/vm.php";
         $dbVm = new fromdb_vm();
     }
     // ------------------------------------------------------------------------
     // GPC
     // ------------------------------------------------------------------------
     //$GLOBALS["confid"] = array('4989','4987');
     functions::gpc_declare_input("thedate", "", false);
     if (!strtotime($GLOBALS["thedate"])) {
         $GLOBALS["thedate"] = "";
     }
     if ($GLOBALS["thedate"] == date("Y-m-d", 0)) {
         $GLOBALS["thedate"] = date("Y-m-d");
         if (!empty($_REQUEST["confid"])) {
             $d = $dbVm->getDateInterval(current($_REQUEST["confid"]));
             // $GLOBALS['confid'] not yet declared
             $GLOBALS["thedate"] = strtotime($d[1]) ? $d[1] : date("Y-m-d");
         }
     }
     // ------------------------------------------------------------------------
     // Output drop-down list
     // ------------------------------------------------------------------------
     $stdout .= empty($GLOBALS["thedate"]) ? event::outputEventDropdown(array("photos"), "participant list", "") : event::outputEventDropdown(array(), "participants", $GLOBALS["thedate"]);
     // ------------------------------------------------------------------------
     if (!isset($_REQUEST["confid"]) || empty($_REQUEST["confid"])) {
         return $stdout;
     }
     // ------------------------------------------------------------------------
     // Obtain data
     // ------------------------------------------------------------------------
     // Must be after call to event::outputEventDropdown() where $GLOBALS["confid"] is set.
     if (!isset($GLOBALS["confid"])) {
         functions::gpc_declare_input("confid", array(), false);
     }
     if (!empty($GLOBALS["confid"])) {
         $confidArray = is_array($GLOBALS["confid"]) ? $GLOBALS["confid"] : array($GLOBALS["confid"]);
     }
     foreach ($confidArray as $confid) {
         $eventShortname[$confid] = $GLOBALS["documentClass"]->getPathFromAgendaId($confid);
         $eventTitle[$confid] = event::getEventByAgendaid($confid, "title");
         $dates[$confid] = $dbVm->getDateInterval($confid);
         $oneEventParticipants[$confid] = $dbVm->getEventsParticipants($confid, 1);
     }
     // Merge all participants to one array
     foreach ($oneEventParticipants as $confid => $parts) {
         foreach ($parts as $key => $data) {
             $eventParticipants[strtolower($key)] = $data;
         }
     }
     ksort($eventParticipants);
     foreach ($eventParticipants as $data) {
         if ($data["start"] <= $GLOBALS["thedate"] && $GLOBALS["thedate"] <= $data["end"]) {
             $eventParticipantsThisDay[] = $data;
         }
     }
     // ------------------------------------------------------------------------
     // Output data
     // ------------------------------------------------------------------------
     $stdout .= "        <hr class='only_online'>\r\n" . "\r\n";
     foreach ($confidArray as $confid) {
         $stdout .= "          <div class='eventheading bottommargin clear'>\r\n" . "            <p><img src='" . PATH_EVENTLOGOS . "/" . $eventShortname[$confid] . ".png' alt='' " . "style='float:left;margin:0px 20px 2em 0px;'></p>\r\n" . "            <h2>" . $eventTitle[$confid] . "</h2>\r\n" . (!empty($dates[$confid][0]) ? "            <p>" . $dates[$confid][0] . "</p>\r\n" : "<br>") . "\r\n";
     }
     $stdout .= (!empty($GLOBALS["thedate"]) ? "            <h3 style='clear:both'>PARTICIPANTS PRESENT ON " . $GLOBALS["thedate"] . "</h3>\r\n" : "") . "          </div> <!-- eventheading -->\r\n" . "\r\n";
     // -------------
     if (empty($eventParticipants)) {
         return $stdout . "        " . BLURB_SORRY_NO_PARTICIPANTS;
     }
     // -------------
     if (!empty($GLOBALS["thedate"])) {
         if (empty($eventParticipantsThisDay)) {
             return $stdout . "        " . BLURB_SORRY_NO_PARTICIPANTS;
         }
         $stdout .= "          <dl>\r\n";
         foreach ($eventParticipantsThisDay as $data) {
             $stdout .= "            <dd>" . $data["firstname"] . " " . $data["lastname"] . "</dd>\r\n";
         }
         $stdout .= "          </dl>\r\n\r\n";
         return $stdout;
     }
     // -------------
     $stdout .= "            <h3 style='clear:both'>" . count($eventParticipants) . " REGISTERED PARTICIPANTS</h3>\r\n" . "          </div> <!-- eventheading -->\r\n" . "\r\n" . "          <table class='b_zebra'>\r\n";
     $i = 0;
     foreach ($eventParticipants as $data) {
         $stdout .= "            <tr>\r\n" . (isset($_REQUEST["with_abstract"]) && !empty($data["photo"]) ? "              <td class='b_zebra" . ($i + 1) . "'>" . "<img src='http://cms.nordita.org/sites/default/files/myPear/photos/" . substr($data["photo"], 0, 1) . "/" . $data["photo"] . "' alt=''" . " style='max-width:60px;max-height:80px'" . ">" . "</td>\r\n" : "              <td class='b_zebra" . ($i + 1) . "'>&nbsp;</td>\r\n") . "              <td class='b_zebra" . ($i + 1) . "'>" . "<strong>" . $data["firstname"] . " <span class='nowrap'>" . $data["lastname"] . "</span></strong>" . "</td>\r\n" . "              <td class='b_zebra" . ($i + 1) . "'>" . "<em>" . str_replace(" of ", "&nbsp;of&nbsp;", $data["institute"]) . "</em>" . "<br>" . $data["city"] . ", " . functions::fromCountryCodeTo("country", $data["country"]) . "</td>\r\n" . "              <td class='b_zebra" . ($i + 1) . "' style='white-space:nowrap!important'><strong>" . $data["email"] . "</strong><br>" . " &nbsp; &nbsp; " . functions::readableDateInterval($data["start"], $data["end"]) . "</td>\r\n" . "            </tr>\r\n";
         $i = 1 - $i;
     }
     $stdout .= "          </table>\r\n\r\n";
     /* TODO: no-table output
           $i = 0;
           $stdout .= "<p>";
           foreach ($eventParticipants as $data) {
             $stdout .=
               "<br><strong>" . $data["firstname"] . " <span class='nowrap'>" . $data["lastname"] . "</span></strong>, " .
               "<em>" . str_replace(" of ","&nbsp;of&nbsp;",$data["institute"]) . "</em>," .
               " " . $data["city"] . ", " . functions::fromCountryCodeTo("country",$data["country"]);
     
             $i = 1-$i;
           }
           $stdout .= "</p>\r\n";
     */
     return $stdout;
 }
Пример #5
0
 function getApplicantData($stattype = "applicants", $distinguishNordic = TRUE, $distinguishBaltic = TRUE, $countPolandAsBaltic = FALSE)
 {
     $applicant = array();
     // ------------------------
     // Read CSV file to array $this->applicantDataSource[line]
     // ------------------------
     if (!$this->setApplicantDataSource()) {
         return array();
     }
     //TODO: nicer error handling
     // ------------------------
     // Convert raw data to array
     //   $applicant[][lastname,firstname,citizenship,residentship,ms,phd,
     //                 cit_continent,res_continent,ms_continent,phd_continent,
     //                 nordic,baltic,campaign_id]
     // ------------------------
     $idx = 0;
     foreach ($this->applicantDataSource as $line) {
         if (preg_match("/^.*--- (.*)/", trim($line), $res)) {
             $idx++;
         } elseif (!isset($GLOBALS["beenthere"]) || !$GLOBALS["beenthere"] || isset($GLOBALS["reset"]) || isset($GLOBALS["eventindex"][$idx])) {
             $arr = preg_split("/\\s?,\\s?/", str_Replace("??", "", $line));
             if (count($arr) > 1) {
                 $applicant[] = array("lastname" => mb_convert_case($arr[4], MB_CASE_TITLE, "UTF-8"), "firstname" => mb_convert_case($arr[5], MB_CASE_TITLE, "UTF-8"), "cit" => $arr[0], "res" => $arr[1], "ms" => $arr[2], "phd" => $arr[3], "cit_continent" => functions::fromCountryCodeTo("continentcode", $arr[0], $distinguishNordic, $distinguishBaltic, $countPolandAsBaltic), "res_continent" => functions::fromCountryCodeTo("continentcode", $arr[1], $distinguishNordic, $distinguishBaltic, $countPolandAsBaltic), "ms_continent" => functions::fromCountryCodeTo("continentcode", $arr[2], $distinguishNordic, $distinguishBaltic, $countPolandAsBaltic), "phd_continent" => functions::fromCountryCodeTo("continentcode", $arr[3], $distinguishNordic, $distinguishBaltic, $countPolandAsBaltic), "nordic" => functions::isInRegion("nordic", array($arr[0], $arr[1], $arr[2], $arr[3]), $countPolandAsBaltic), "baltic" => functions::isInRegion("baltic", array($arr[0], $arr[1], $arr[2], $arr[3]), $countPolandAsBaltic), "id" => $idx, "timestamp" => 0, "timestamp" => 0);
             }
         }
     }
     return $applicant;
 }