Пример #1
0
 function distanceCenter($storeBean)
 {
     $lat = $storeBean->getLat();
     $lng = $storeBean->getLng();
     $point = new Point($lat, $lng);
     return distanceBetweenPoints($point, $this->getCenter(), $this . getUnit());
 }
Пример #2
0
 print "</th>";
 print "</tr>";
 $count = 0;
 while ($rowEntry = $resultEntry->fetch()) {
     if ($count % 2 == 0) {
         $rowNum = "even";
     } else {
         $rowNum = "odd";
     }
     $count++;
     $entryCount++;
     print "<tr class={$rowNum}>";
     print "<td>";
     print "<span title='" . htmlPrep($rowEntry["description"]) . "'><b><u>" . $rowEntry["name"] . "</u></b></span><br/>";
     print "<span style='font-size: 90%; font-style: italic; font-weight: normal'>";
     $unit = getUnit($connection2, $rowEntry["gibbonUnitID"], $rowEntry["gibbonHookID"], $rowEntry["gibbonCourseClassID"]);
     if (isset($unit[0])) {
         print $unit[0] . "<br/>";
     }
     if (isset($unit[1])) {
         if ($unit[1] != "") {
             print $unit[1] . " " . _('Unit') . "</i><br/>";
         }
     }
     if ($rowEntry["completeDate"] != "") {
         print _("Marked on") . " " . dateConvertBack($guid, $rowEntry["completeDate"]) . "<br/>";
     } else {
         print _("Unmarked") . "<br/>";
     }
     print $rowEntry["type"];
     if ($rowEntry["attachment"] != "" and file_exists($_SESSION[$guid]["absolutePath"] . "/" . $rowEntry["attachment"])) {
                    if ($in == 4) {
                        $return = "TB";
                        return $return;
                    }
                }
            }
        }
    }
}
$res = $db->query($query);
while ($row = $res->fetchRow()) {
    $row['numLin'] = $numLine;
    while ($row['remaining_space'] >= 1024) {
        $row['remaining_space'] = $row['remaining_space'] / 1024;
        $in = $in + 1;
    }
    $row['unit'] = getUnit($in);
    $in = 0;
    $row['remaining_space'] = round($row['remaining_space']);
    $row['ratio'] = ceil($row['ratio'] * 100);
    $data[] = $row;
    $numLine++;
}
$template->assign('preferences', $preferences);
$template->assign('widgetID', $widgetId);
$template->assign('preferences', $preferences);
$template->assign('data', $data);
$template->display('table_top10memory.ihtml');
?>

Пример #4
0
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null)
{
    $cacheAge = 60 * 60;
    $offset = getOffset();
    setTimezone();
    $cache = phpFastCache();
    //$cache->clean();
    $dt = getDates($from);
    $from = $dt[0];
    if ($to == null) {
        $to = $dt[1];
    }
    $from = str_replace("-", "/", $from);
    $to = str_replace("-", "/", $to);
    $phour = getPeakHours();
    $unit = getUnit($id_item);
    $plan = getPlan($id_plan);
    $item = getItem($id_item);
    $div = 1;
    if (strtolower($unit) == 'bps') {
        $div = 1024 * 1024;
        $unit = 'Mbps';
    }
    $rtag = "";
    foreach ($_SESSION['tag'] as $key => $value) {
        if ($key != "" && $key != "None") {
            $rtag = $rtag . ',"' . $key . '"';
        }
    }
    if ($rtag == '') {
        $rtag = 'bm_tags.tag like "%"';
    } else {
        $rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')';
    }
    if ($id_plan == 0) {
        $id_plan = '> 0';
    } else {
        $id_plan = '=' . $id_plan;
    }
    if ($id_host == null) {
        $id_host = "";
    } else {
        $id_host = " and bm_host.id_host=" . $id_host;
    }
    $hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host
						from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard
						where bm_host.id_plan=bm_plan.id_plan
							and bm_host.groupid = ' . $_SESSION['groupid'] . '
							and bm_plan.id_plan ' . $id_plan . '
							and bm_plan_groups.id_plan = bm_plan.id_plan
							and bm_host.borrado=0
							and bm_host.id_plan=bm_plan.id_plan
							and bm_plan_groups.groupid=bm_host.groupid
							and bm_threshold.id_item=bi_dashboard.id_item
							and bm_host.id_host in (select id from bm_tags where ' . $rtag . ')
							and bi_dashboard.id_item=' . $id_item . $id_host . '
						order by bm_host.id_plan';
    //var_dump($hosts);
    // Find Percentile 5 and 95
    if (true) {
        $hostsr = mysql_query($hosts);
        while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) {
            $id_host = $host['id_host'];
            $hostName = $host['host'];
            $nominal = $host['nominal'];
            $critical = $host['critical'];
            $warning = $host['warning'];
            $nacD = $host['nacD'] * 1024;
            $nacU = $host['nacU'] * 1024;
            if ($nominal == -1) {
                $nominal = $nacD;
            }
            if ($nominal == -2) {
                $nominal = $nacU;
            }
            $hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU);
            $incache = true;
            unset($cachedData);
            $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days'));
            while ($dfrom != $to) {
                $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days'));
                $key = $dfrom . '-' . $id_host . '-' . $id_item;
                //if (isset($_SESSION['cache'][$key]))
                //	$obj = $_SESSION['cache'][$key];
                //else
                //echo $key . "<br>";
                $obj = $cache->get($key);
                if ($obj == null) {
                    $incache = false;
                    $_SESSION['cacheFull'] = false;
                } else {
                    $_SESSION['cachePartial'] = true;
                    foreach ($obj as $key => $value) {
                        if (isset($value['clock'])) {
                            $cachedData[] = $value;
                        }
                    }
                }
            }
            if (!isset($cachedData)) {
                $incache = false;
            }
            if ($incache) {
                foreach ($cachedData as $key => $row) {
                    $skip = false;
                    if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') {
                        $skip = true;
                    }
                    if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') {
                        $skip = true;
                    }
                    if (!$skip) {
                        $allData[] = $row['value'];
                        $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                    }
                }
            } else {
                $table = 'xyz_' . str_pad($id_item, 10, "0", STR_PAD_LEFT);
                //var_dump($table);
                if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table . "'")) == 1) {
                    if ($phour['peak'] > $phour['offpeak']) {
                        $q = 'select clock,value,valid,if((date_format(from_unixtime(clock),"%H")>=0 and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ') or date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ',"P","O") as t
							from ' . $table . '
							where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and
								id_host=' . $id_host;
                    } else {
                        $q = 'select clock,value,valid,if(date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ' and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ',"P","O") as t
							from ' . $table . '
							where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and
								id_host=' . $id_host;
                    }
                    //var_dump($q);
                    $qr = mysql_query($q);
                    while ($row = mysql_fetch_array($qr, MYSQL_ASSOC)) {
                        $key = date('Y/m/d', $row['clock']);
                        $data[$key][$id_host . '-' . $id_item][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                        $skip = false;
                        if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') {
                            $skip = true;
                        }
                        if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') {
                            $skip = true;
                        }
                        if (!$skip) {
                            $allData[] = $row['value'];
                            $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']);
                        }
                    }
                }
                // check miising data
                $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days'));
                while ($dfrom != $to) {
                    $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days'));
                    $key = $dfrom . '-' . $id_host . '-' . $id_item;
                    $obj = $cache->get($key);
                    if ($obj == null) {
                        $cache->set($key, array('clock' => 0, 'value' => 0, 'valid' => 0, 't' => ''), $cacheAge);
                        //$_SESSION['cache'][$key]= array('clock'=>0,'value'=>0,'valid'=>0,'t'=>'');
                    }
                }
            }
        }
    }
    if (isset($incache) && !$incache && isset($data)) {
        foreach ($data as $key => $value) {
            foreach ($value as $hkey => $hvalue) {
                $thekey = $key . '-' . $hkey;
                //echo $thekey . ' ';
                $cache->set($thekey, $hvalue, $cacheAge);
                //$_SESSION['cache'][$thekey] = $hvalue;
            }
        }
    }
    if (isset($allData)) {
        return array('allData' => $allData, 'historyList' => $historyList, 'hostList' => $hostList, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to);
    } else {
        return array('allData' => null, 'historyList' => null, 'hostList' => null, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to);
    }
}
Пример #5
0
{
    $rs = mysql_query("select alotdate from current_lsm where year='{$kapa}' and division='{$divi}' and lotno='{$lotno}' and todate='0000-00-00'");
    $row = mysql_fetch_array($rs);
    return $row['alotdate'];
}
echo "<table width=900px border=1><tr><td>S.No.</td><td>Lot No.</td><td>Range</td><td>Unit</td><td>Forests</td><td>Name of LSM</td><td>Date of Allotment(dd-mm-yy)</td><td>Working from date(dd-mm-yyyy)</td><td>Forest Division</td></tr>";
$i = 1;
while ($row = mysql_fetch_array($datan)) {
    $lotno = $row['lotno'];
    $currlot = addslashes($lotno);
    $frange = $row['frange'];
    $divi = $row['division'];
    $lsmname = getLSMname($currlot, $divi, $kapa);
    $fromdate = getlsmDateStart($currlot, $divi, $kapa) == '0000-00-00' ? "NOT STARTED YET" : getDDMMYY(getlsmDateStart($currlot, $divi, $kapa));
    $alotdate = getlsmDateAlot($currlot, $divi, $kapa);
    echo "<tr><td>" . $i . "</td><td>" . $lotno . "/" . $kapa . "(" . getExten($currlot, $divi) . ")</td><td>" . $frange . "</td><td>" . getUnit($currlot, $divi) . "</td><td>" . getForests($currlot, $divi, $kapa) . "</td><td>" . $lsmname . "</td><td>" . getDDMMYY($alotdate) . "</td><td>" . $fromdate . "</td><td>" . $divi . "</td></tr>";
    $i++;
}
echo "</table>";
?>
 <br>
<br>
<br>
<br>
<h3>Divisional Manager &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp Divisional Forest Officer<br>
Forest Working Division, <?php 
echo strtoupper($_SESSION['fwd']);
Пример #6
0
function getParentalDashboardContents($connection2, $guid, $gibbonPersonID)
{
    $return = FALSE;
    $alert = getAlert($connection2, 02);
    $entryCount = 0;
    //PREPARE PLANNER SUMMARY
    $plannerOutput = "<span style='font-size: 85%; font-weight: bold'>" . _('Today\'s Classes') . "</span> . <span style='font-size: 70%'><a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Planner/planner.php&search=" . $gibbonPersonID . "'>" . _('View Planner') . "</a></span>";
    if (isset($_GET["updateReturn"])) {
        $updateReturn = $_GET["updateReturn"];
    } else {
        $updateReturn = "";
    }
    $updateReturnMessage = "";
    $class = "error";
    if (!($updateReturn == "")) {
        if ($updateReturn == "fail0") {
            $updateReturnMessage = _("Your request failed because you do not have access to this action.");
        } else {
            if ($updateReturn == "fail1") {
                $updateReturnMessage = _("Your request failed because your inputs were invalid.");
            } else {
                if ($updateReturn == "fail2") {
                    $updateReturnMessage = _("Your request failed due to a database error.");
                } else {
                    if ($updateReturn == "success0") {
                        $updateReturnMessage = _("Your request was completed successfully.");
                        $class = "success";
                    }
                }
            }
        }
        $plannerOutput .= "<div class='{$class}'>";
        $plannerOutput .= $updateReturnMessage;
        $plannerOutput .= "</div>";
    }
    $classes = FALSE;
    $date = date("Y-m-d");
    if (isSchoolOpen($guid, $date, $connection2) == TRUE and isActionAccessible($guid, $connection2, "/modules/Planner/planner.php") and $_SESSION[$guid]["username"] != "") {
        try {
            $data = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "date" => $date, "gibbonPersonID" => $gibbonPersonID, "date2" => $date, "gibbonPersonID2" => $gibbonPersonID);
            $sql = "(SELECT gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, gibbonPlannerEntryStudentHomework.homeworkDueDateTime AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourseClassPerson ON (gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) LEFT JOIN gibbonPlannerEntryStudentHomework ON (gibbonPlannerEntryStudentHomework.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID AND gibbonPlannerEntryStudentHomework.gibbonPersonID=gibbonCourseClassPerson.gibbonPersonID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND date=:date AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND NOT role='Student - Left' AND NOT role='Teacher - Left') UNION (SELECT gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonHookID, gibbonPlannerEntry.gibbonCourseClassID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkSubmission, homeworkCrowdAssess, role, date, summary, NULL AS myHomeworkDueDateTime FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonPlannerEntryGuest ON (gibbonPlannerEntryGuest.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE date=:date2 AND gibbonPlannerEntryGuest.gibbonPersonID=:gibbonPersonID2) ORDER BY date, timeStart";
            $result = $connection2->prepare($sql);
            $result->execute($data);
        } catch (PDOException $e) {
            $plannerOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        if ($result->rowCount() > 0) {
            $classes = TRUE;
            $plannerOutput .= "<table cellspacing='0' style='margin: 3px 0px; width: 100%'>";
            $plannerOutput .= "<tr class='head'>";
            $plannerOutput .= "<th>";
            $plannerOutput .= _("Class") . "<br/>";
            $plannerOutput .= "</th>";
            $plannerOutput .= "<th>";
            $plannerOutput .= _("Lesson") . "<br/>";
            $plannerOutput .= "<span style='font-size: 85%; font-weight: normal; font-style: italic'>" . _("Summary") . "</span>";
            $plannerOutput .= "</th>";
            $plannerOutput .= "<th>";
            $plannerOutput .= _("Homework");
            $plannerOutput .= "</th>";
            $plannerOutput .= "<th>";
            $plannerOutput .= _("Like");
            $plannerOutput .= "</th>";
            $plannerOutput .= "<th>";
            $plannerOutput .= _("Action");
            $plannerOutput .= "</th>";
            $plannerOutput .= "</tr>";
            $count2 = 0;
            $rowNum = "odd";
            while ($row = $result->fetch()) {
                if ($count2 % 2 == 0) {
                    $rowNum = "even";
                } else {
                    $rowNum = "odd";
                }
                $count2++;
                //Highlight class in progress
                if (date("H:i:s") > $row["timeStart"] and date("H:i:s") < $row["timeEnd"] and $date == date("Y-m-d")) {
                    $rowNum = "current";
                }
                //COLOR ROW BY STATUS!
                $plannerOutput .= "<tr class={$rowNum}>";
                $plannerOutput .= "<td>";
                $plannerOutput .= "<b>" . $row["course"] . "." . $row["class"] . "</b><br/>";
                $plannerOutput .= "</td>";
                $plannerOutput .= "<td>";
                $plannerOutput .= $row["name"] . "<br/>";
                $unit = getUnit($connection2, $row["gibbonUnitID"], $row["gibbonHookID"], $row["gibbonCourseClassID"]);
                if (isset($unit[0])) {
                    $plannerOutput .= $unit[0];
                    if ($unit[1] != "") {
                        $plannerOutput .= "<br/><i>" . $unit[1] . " " . _('Unit') . "</i><br/>";
                    }
                }
                $plannerOutput .= "<span style='font-size: 85%; font-weight: normal; font-style: italic'>";
                $plannerOutput .= $row["summary"];
                $plannerOutput .= "</span>";
                $plannerOutput .= "</td>";
                $plannerOutput .= "<td>";
                if ($row["homework"] == "N" and $row["myHomeworkDueDateTime"] == "") {
                    $plannerOutput .= _("No");
                } else {
                    if ($row["homework"] == "Y") {
                        $plannerOutput .= _("Yes") . ": " . _("Teacher Recorded") . "<br/>";
                        if ($row["homeworkSubmission"] == "Y") {
                            $plannerOutput .= "<span style='font-size: 85%; font-style: italic'>+" . _("Submission") . "</span><br/>";
                            if ($row["homeworkCrowdAssess"] == "Y") {
                                $plannerOutput .= "<span style='font-size: 85%; font-style: italic'>+" . _("Crowd Assessment") . "</span><br/>";
                            }
                        }
                    }
                    if ($row["myHomeworkDueDateTime"] != "") {
                        $plannerOutput .= _("Yes") . ": " . _("Student Recorded") . "</br>";
                    }
                }
                $plannerOutput .= "</td>";
                $plannerOutput .= "<td>";
                $likesGiven = countLikesByContextAndGiver($connection2, "Planner", "gibbonPlannerEntryID", $row["gibbonPlannerEntryID"], $_SESSION[$guid]["gibbonPersonID"]);
                if ($likesGiven != 1) {
                    $plannerOutput .= "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/modules/Planner/plannerProcess.php?gibbonPlannerEntryID=" . $row["gibbonPlannerEntryID"] . "&address=/modules/Planner/planner.php&viewBy=date&date={$date}&gibbonPersonID=" . $gibbonPersonID . "&returnToIndex=Y'><img src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_off.png'></a>";
                } else {
                    $plannerOutput .= "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/modules/Planner/plannerProcess.php?gibbonPlannerEntryID=" . $row["gibbonPlannerEntryID"] . "&address=/modules/Planner/planner.php&viewBy=date&date={$date}&gibbonPersonID=" . $gibbonPersonID . "&returnToIndex=Y'><img src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_on.png'></a>";
                }
                $plannerOutput .= "</td>";
                $plannerOutput .= "<td>";
                $plannerOutput .= "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Planner/planner_view_full.php&search=" . $gibbonPersonID . "&viewBy=date&gibbonPlannerEntryID=" . $row["gibbonPlannerEntryID"] . "&date={$date}&width=1000&height=550'><img title='" . _('View') . "' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/plus.png'/></a> ";
                $plannerOutput .= "</td>";
                $plannerOutput .= "</tr>";
            }
            $plannerOutput .= "</table>";
        }
    }
    if ($classes == FALSE) {
        $plannerOutput .= "<div style='margin-top: 2px' class='warning'>";
        $plannerOutput .= _("There are no records to display.");
        $plannerOutput .= "</div>";
    }
    //PREPARE RECENT GRADES
    $gradesOutput = "<div style='margin-top: 20px'><span style='font-size: 85%; font-weight: bold'>" . _('Recent Grades') . "</span> . <span style='font-size: 70%'><a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Markbook/markbook_view.php&search=" . $gibbonPersonID . "'>" . _('View Markbook') . "</a></span></div>";
    $grades = FALSE;
    //Get alternative header names
    $attainmentAlternativeName = getSettingByScope($connection2, "Markbook", "attainmentAlternativeName");
    $attainmentAlternativeNameAbrev = getSettingByScope($connection2, "Markbook", "attainmentAlternativeNameAbrev");
    $effortAlternativeName = getSettingByScope($connection2, "Markbook", "effortAlternativeName");
    $effortAlternativeNameAbrev = getSettingByScope($connection2, "Markbook", "effortAlternativeNameAbrev");
    try {
        $dataEntry = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $gibbonPersonID);
        $sqlEntry = "SELECT *, gibbonMarkbookColumn.comment AS commentOn, gibbonMarkbookColumn.uploadedResponse AS uploadedResponseOn, gibbonMarkbookEntry.comment AS comment FROM gibbonMarkbookEntry JOIN gibbonMarkbookColumn ON (gibbonMarkbookEntry.gibbonMarkbookColumnID=gibbonMarkbookColumn.gibbonMarkbookColumnID) JOIN gibbonCourseClass ON (gibbonMarkbookColumn.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonPersonIDStudent=:gibbonPersonID AND complete='Y' AND completeDate<='" . date("Y-m-d") . "' AND viewableParents='Y' ORDER BY completeDate DESC LIMIT 0, 3";
        $resultEntry = $connection2->prepare($sqlEntry);
        $resultEntry->execute($dataEntry);
    } catch (PDOException $e) {
        $gradesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
    }
    if ($resultEntry->rowCount() > 0) {
        $showParentAttainmentWarning = getSettingByScope($connection2, "Markbook", "showParentAttainmentWarning");
        $showParentEffortWarning = getSettingByScope($connection2, "Markbook", "showParentEffortWarning");
        $grades = TRUE;
        $gradesOutput .= "<table cellspacing='0' style='margin: 3px 0px; width: 100%'>";
        $gradesOutput .= "<tr class='head'>";
        $gradesOutput .= "<th style='width: 120px'>";
        $gradesOutput .= _("Assessment");
        $gradesOutput .= "</th>";
        $gradesOutput .= "<th style='width: 75px'>";
        if ($attainmentAlternativeName != "") {
            $gradesOutput .= $attainmentAlternativeName;
        } else {
            $gradesOutput .= _('Attainment');
        }
        $gradesOutput .= "</th>";
        $gradesOutput .= "<th style='width: 75px'>";
        if ($effortAlternativeName != "") {
            $gradesOutput .= $effortAlternativeName;
        } else {
            $gradesOutput .= _('Effort');
        }
        $gradesOutput .= "</th>";
        $gradesOutput .= "<th>";
        $gradesOutput .= _("Comment");
        $gradesOutput .= "</th>";
        $gradesOutput .= "<th style='width: 75px'>";
        $gradesOutput .= _("Submission");
        $gradesOutput .= "</th>";
        $gradesOutput .= "</tr>";
        $count3 = 0;
        while ($rowEntry = $resultEntry->fetch()) {
            if ($count3 % 2 == 0) {
                $rowNum = "even";
            } else {
                $rowNum = "odd";
            }
            $count3++;
            $gradesOutput .= "<a name='" . $rowEntry["gibbonMarkbookEntryID"] . "'></a>";
            $gradesOutput .= "<tr class={$rowNum}>";
            $gradesOutput .= "<td>";
            $gradesOutput .= "<span title='" . htmlPrep($rowEntry["description"]) . "'>" . $rowEntry["name"] . "</span><br/>";
            $gradesOutput .= "<span style='font-size: 90%; font-style: italic; font-weight: normal'>";
            $gradesOutput .= _("Marked on") . " " . dateConvertBack($guid, $rowEntry["completeDate"]) . "<br/>";
            $gradesOutput .= "</span>";
            $gradesOutput .= "</td>";
            if ($rowEntry["attainment"] == "N" or $rowEntry["gibbonScaleIDAttainment"] == "" and $rowEntry["gibbonRubricIDAttainment"] == "") {
                $gradesOutput .= "<td class='dull' style='color: #bbb; text-align: center'>";
                $gradesOutput .= _('N/A');
                $gradesOutput .= "</td>";
            } else {
                $gradesOutput .= "<td style='text-align: center'>";
                $attainmentExtra = "";
                try {
                    $dataAttainment = array("gibbonScaleID" => $rowEntry["gibbonScaleIDAttainment"]);
                    $sqlAttainment = "SELECT * FROM gibbonScale WHERE gibbonScaleID=:gibbonScaleID";
                    $resultAttainment = $connection2->prepare($sqlAttainment);
                    $resultAttainment->execute($dataAttainment);
                } catch (PDOException $e) {
                }
                if ($resultAttainment->rowCount() == 1) {
                    $rowAttainment = $resultAttainment->fetch();
                    $attainmentExtra = "<br/>" . _($rowAttainment["usage"]);
                }
                $styleAttainment = "style='font-weight: bold'";
                if ($rowEntry["attainmentConcern"] == "Y" and $showParentAttainmentWarning == "Y") {
                    $styleAttainment = "style='color: #" . $alert["color"] . "; font-weight: bold; border: 2px solid #" . $alert["color"] . "; padding: 2px 4px; background-color: #" . $alert["colorBG"] . "'";
                } else {
                    if ($rowEntry["attainmentConcern"] == "P" and $showParentAttainmentWarning == "Y") {
                        $styleAttainment = "style='color: #390; font-weight: bold; border: 2px solid #390; padding: 2px 4px; background-color: #D4F6DC'";
                    }
                }
                $gradesOutput .= "<div {$styleAttainment}>" . $rowEntry["attainmentValue"];
                if ($rowEntry["gibbonRubricIDAttainment"] != "") {
                    $gradesOutput .= "<a class='thickbox' href='" . $_SESSION[$guid]["absoluteURL"] . "/fullscreen.php?q=/modules/Markbook/markbook_view_rubric.php&gibbonRubricID=" . $rowEntry["gibbonRubricIDAttainment"] . "&gibbonCourseClassID=" . $rowEntry["gibbonCourseClassID"] . "&gibbonMarkbookColumnID=" . $rowEntry["gibbonMarkbookColumnID"] . "&gibbonPersonID=" . $gibbonPersonID . "&mark=FALSE&type=attainment&width=1100&height=550'><img style='margin-bottom: -3px; margin-left: 3px' title='View Rubric' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/rubric.png'/></a>";
                }
                $gradesOutput .= "</div>";
                if ($rowEntry["attainmentValue"] != "") {
                    $gradesOutput .= "<div class='detailItem' style='font-size: 75%; font-style: italic; margin-top: 2px'><b>" . htmlPrep(_($rowEntry["attainmentDescriptor"])) . "</b>" . _($attainmentExtra) . "</div>";
                }
                $gradesOutput .= "</td>";
            }
            if ($rowEntry["effort"] == "N" or $rowEntry["gibbonScaleIDEffort"] == "" and $rowEntry["gibbonRubricIDEffort"] == "") {
                $gradesOutput .= "<td class='dull' style='color: #bbb; text-align: center'>";
                $gradesOutput .= _('N/A');
                $gradesOutput .= "</td>";
            } else {
                $gradesOutput .= "<td style='text-align: center'>";
                $effortExtra = "";
                try {
                    $dataEffort = array("gibbonScaleID" => $rowEntry["gibbonScaleIDEffort"]);
                    $sqlEffort = "SELECT * FROM gibbonScale WHERE gibbonScaleID=:gibbonScaleID";
                    $resultEffort = $connection2->prepare($sqlEffort);
                    $resultEffort->execute($dataEffort);
                } catch (PDOException $e) {
                }
                if ($resultEffort->rowCount() == 1) {
                    $rowEffort = $resultEffort->fetch();
                    $effortExtra = "<br/>" . _($rowEffort["usage"]);
                }
                $styleEffort = "style='font-weight: bold'";
                if ($rowEntry["effortConcern"] == "Y" and $showParentEffortWarning == "Y") {
                    $styleEffort = "style='color: #" . $alert["color"] . "; font-weight: bold; border: 2px solid #" . $alert["color"] . "; padding: 2px 4px; background-color: #" . $alert["colorBG"] . "'";
                }
                $gradesOutput .= "<div {$styleEffort}>" . $rowEntry["effortValue"];
                if ($rowEntry["gibbonRubricIDEffort"] != "") {
                    $gradesOutput .= "<a class='thickbox' href='" . $_SESSION[$guid]["absoluteURL"] . "/fullscreen.php?q=/modules/Markbook/markbook_view_rubric.php&gibbonRubricID=" . $rowEntry["gibbonRubricIDEffort"] . "&gibbonCourseClassID=" . $rowEntry["gibbonCourseClassID"] . "&gibbonMarkbookColumnID=" . $rowEntry["gibbonMarkbookColumnID"] . "&gibbonPersonID=" . $gibbonPersonID . "&mark=FALSE&type=effort&width=1100&height=550'><img style='margin-bottom: -3px; margin-left: 3px' title='View Rubric' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/rubric.png'/></a>";
                }
                $gradesOutput .= "</div>";
                if ($rowEntry["effortValue"] != "") {
                    $gradesOutput .= "<div class='detailItem' style='font-size: 75%; font-style: italic; margin-top: 2px'><b>" . htmlPrep(_($rowEntry["effortDescriptor"])) . "</b>" . _($effortExtra) . "</div>";
                }
                $gradesOutput .= "</td>";
            }
            if ($rowEntry["commentOn"] == "N" and $rowEntry["uploadedResponseOn"] == "N") {
                $gradesOutput .= "<td class='dull' style='color: #bbb; text-align: left'>";
                $gradesOutput .= _('N/A');
                $gradesOutput .= "</td>";
            } else {
                $gradesOutput .= "<td>";
                if ($rowEntry["comment"] != "") {
                    if (strlen($rowEntry["comment"]) > 50) {
                        $gradesOutput .= "<script type='text/javascript'>";
                        $gradesOutput .= "\$(document).ready(function(){";
                        $gradesOutput .= "\$(\".comment-{$entryCount}-{$gibbonPersonID}\").hide();";
                        $gradesOutput .= "\$(\".show_hide-{$entryCount}-{$gibbonPersonID}\").fadeIn(1000);";
                        $gradesOutput .= "\$(\".show_hide-{$entryCount}-{$gibbonPersonID}\").click(function(){";
                        $gradesOutput .= "\$(\".comment-{$entryCount}-{$gibbonPersonID}\").fadeToggle(1000);";
                        $gradesOutput .= "});";
                        $gradesOutput .= "});";
                        $gradesOutput .= "</script>";
                        $gradesOutput .= "<span>" . substr($rowEntry["comment"], 0, 50) . "...<br/>";
                        $gradesOutput .= "<a title='" . _('View Description') . "' class='show_hide-{$entryCount}-{$gibbonPersonID}' onclick='return false;' href='#'>" . _('Read more') . "</a></span><br/>";
                    } else {
                        $gradesOutput .= $rowEntry["comment"];
                    }
                    $gradesOutput .= "<br/>";
                }
                if ($rowEntry["response"] != "") {
                    $gradesOutput .= "<a title='" . _('Uploaded Response') . "' href='" . $_SESSION[$guid]["absoluteURL"] . "/" . $rowEntry["response"] . "'>" . _('Uploaded Response') . "</a><br/>";
                }
                $gradesOutput .= "</td>";
            }
            if ($rowEntry["gibbonPlannerEntryID"] == 0) {
                $gradesOutput .= "<td class='dull' style='color: #bbb; text-align: left'>";
                $gradesOutput .= _('N/A');
                $gradesOutput .= "</td>";
            } else {
                try {
                    $dataSub = array("gibbonPlannerEntryID" => $rowEntry["gibbonPlannerEntryID"]);
                    $sqlSub = "SELECT * FROM gibbonPlannerEntry WHERE gibbonPlannerEntryID=:gibbonPlannerEntryID AND homeworkSubmission='Y'";
                    $resultSub = $connection2->prepare($sqlSub);
                    $resultSub->execute($dataSub);
                } catch (PDOException $e) {
                    $gradesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
                }
                if ($resultSub->rowCount() != 1) {
                    $gradesOutput .= "<td class='dull' style='color: #bbb; text-align: left'>";
                    $gradesOutput .= _('N/A');
                    $gradesOutput .= "</td>";
                } else {
                    $gradesOutput .= "<td>";
                    $rowSub = $resultSub->fetch();
                    try {
                        $dataWork = array("gibbonPlannerEntryID" => $rowEntry["gibbonPlannerEntryID"], "gibbonPersonID" => $gibbonPersonID);
                        $sqlWork = "SELECT * FROM gibbonPlannerEntryHomework WHERE gibbonPlannerEntryID=:gibbonPlannerEntryID AND gibbonPersonID=:gibbonPersonID ORDER BY count DESC";
                        $resultWork = $connection2->prepare($sqlWork);
                        $resultWork->execute($dataWork);
                    } catch (PDOException $e) {
                        $gradesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
                    }
                    if ($resultWork->rowCount() > 0) {
                        $rowWork = $resultWork->fetch();
                        if ($rowWork["status"] == "Exemption") {
                            $linkText = _("Exemption");
                        } else {
                            if ($rowWork["version"] == "Final") {
                                $linkText = _("Final");
                            } else {
                                $linkText = _("Draft") . " " . $rowWork["count"];
                            }
                        }
                        $style = "";
                        $status = "On Time";
                        if ($rowWork["status"] == "Exemption") {
                            $status = _("Exemption");
                        } else {
                            if ($rowWork["status"] == "Late") {
                                $style = "style='color: #ff0000; font-weight: bold; border: 2px solid #ff0000; padding: 2px 4px'";
                                $status = _("Late");
                            }
                        }
                        if ($rowWork["type"] == "File") {
                            $gradesOutput .= "<span title='" . $rowWork["version"] . ". {$status}. " . sprintf(_('Submitted at %1$s on %2$s'), substr($rowWork["timestamp"], 11, 5), dateConvertBack($guid, substr($rowWork["timestamp"], 0, 10))) . "' {$style}><a href='" . $_SESSION[$guid]["absoluteURL"] . "/" . $rowWork["location"] . "'>{$linkText}</a></span>";
                        } else {
                            if ($rowWork["type"] == "Link") {
                                $gradesOutput .= "<span title='" . $rowWork["version"] . ". {$status}. " . sprintf(_('Submitted at %1$s on %2$s'), substr($rowWork["timestamp"], 11, 5), dateConvertBack($guid, substr($rowWork["timestamp"], 0, 10))) . "' {$style}><a target='_blank' href='" . $rowWork["location"] . "'>{$linkText}</a></span>";
                            } else {
                                $gradesOutput .= "<span title='{$status}. " . sprintf(_('Recorded at %1$s on %2$s'), substr($rowWork["timestamp"], 11, 5), dateConvertBack($guid, substr($rowWork["timestamp"], 0, 10))) . "' {$style}>{$linkText}</span>";
                            }
                        }
                    } else {
                        if (date("Y-m-d H:i:s") < $rowSub["homeworkDueDateTime"]) {
                            $gradesOutput .= "<span title='Pending'>" . _('Pending') . "</span>";
                        } else {
                            if ($row["dateStart"] > $rowSub["date"]) {
                                $gradesOutput .= "<span title='" . _('Student joined school after assessment was given.') . "' style='color: #000; font-weight: normal; border: 2px none #ff0000; padding: 2px 4px'>" . _('NA') . "</span>";
                            } else {
                                if ($rowSub["homeworkSubmissionRequired"] == "Compulsory") {
                                    $gradesOutput .= "<div style='color: #ff0000; font-weight: bold; border: 2px solid #ff0000; padding: 2px 4px; margin: 2px 0px'>" . _('Incomplete') . "</div>";
                                } else {
                                    $gradesOutput .= _("Not submitted online");
                                }
                            }
                        }
                    }
                    $gradesOutput .= "</td>";
                }
            }
            $gradesOutput .= "</tr>";
            if (strlen($rowEntry["comment"]) > 50) {
                $gradesOutput .= "<tr class='comment-{$entryCount}-{$gibbonPersonID}' id='comment-{$entryCount}-{$gibbonPersonID}'>";
                $gradesOutput .= "<td colspan=6>";
                $gradesOutput .= $rowEntry["comment"];
                $gradesOutput .= "</td>";
                $gradesOutput .= "</tr>";
            }
            $entryCount++;
        }
        $gradesOutput .= "</table>";
    }
    if ($grades == FALSE) {
        $gradesOutput .= "<div style='margin-top: 2px' class='warning'>";
        $gradesOutput .= _("There are no records to display.");
        $gradesOutput .= "</div>";
    }
    //PREPARE UPCOMING DEADLINES
    $deadlinesOutput = "<div style='margin-top: 20px'><span style='font-size: 85%; font-weight: bold'>" . _('Upcoming Deadlines') . "</span> . <span style='font-size: 70%'><a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Planner/planner_deadlines.php&search=" . $gibbonPersonID . "'>" . _('View All Deadlines') . "</a></span></div>";
    $deadlines = FALSE;
    try {
        $data = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $gibbonPersonID);
        $sql = "\n\t\t(SELECT 'teacherRecorded' AS type, gibbonPlannerEntryID, gibbonUnitID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, date, timeStart, timeEnd, viewableStudents, viewableParents, homework, homeworkDueDateTime, role FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourseClassPerson ON (gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND NOT role='Student - Left' AND NOT role='Teacher - Left' AND homework='Y' AND (role='Teacher' OR (role='Student' AND viewableStudents='Y')) AND homeworkDueDateTime>'" . date("Y-m-d H:i:s") . "' AND ((date<'" . date("Y-m-d") . "') OR (date='" . date("Y-m-d") . "' AND timeEnd<='" . date("H:i:s") . "')))\n\t\tUNION\n\t\t(SELECT 'studentRecorded' AS type, gibbonPlannerEntry.gibbonPlannerEntryID, gibbonUnitID, gibbonCourse.nameShort AS course, gibbonCourseClass.nameShort AS class, gibbonPlannerEntry.name, date, timeStart, timeEnd, 'Y' AS viewableStudents, 'Y' AS viewableParents, 'Y' AS homework, gibbonPlannerEntryStudentHomework.homeworkDueDateTime, role FROM gibbonPlannerEntry JOIN gibbonCourseClass ON (gibbonPlannerEntry.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourseClassPerson ON (gibbonCourseClass.gibbonCourseClassID=gibbonCourseClassPerson.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonPlannerEntryStudentHomework ON (gibbonPlannerEntryStudentHomework.gibbonPlannerEntryID=gibbonPlannerEntry.gibbonPlannerEntryID AND gibbonPlannerEntryStudentHomework.gibbonPersonID=gibbonCourseClassPerson.gibbonPersonID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonCourseClassPerson.gibbonPersonID=:gibbonPersonID AND NOT role='Student - Left' AND NOT role='Teacher - Left' AND (role='Teacher' OR (role='Student' AND viewableStudents='Y')) AND gibbonPlannerEntryStudentHomework.homeworkDueDateTime>'" . date("Y-m-d H:i:s") . "' AND ((date<'" . date("Y-m-d") . "') OR (date='" . date("Y-m-d") . "' AND timeEnd<='" . date("H:i:s") . "')))\n\t\tORDER BY homeworkDueDateTime, type";
        $result = $connection2->prepare($sql);
        $result->execute($data);
    } catch (PDOException $e) {
        $deadlinesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
    }
    if ($result->rowCount() > 0) {
        $deadlines = TRUE;
        $deadlinesOutput .= "<ol style='margin-left: 15px'>";
        while ($row = $result->fetch()) {
            $diff = (strtotime(substr($row["homeworkDueDateTime"], 0, 10)) - strtotime(date("Y-m-d"))) / 86400;
            $style = "style='padding-right: 3px;'";
            if ($diff < 2) {
                $style = "style='padding-right: 3px; border-right: 10px solid #cc0000'";
            } else {
                if ($diff < 4) {
                    $style = "style='padding-right: 3px; border-right: 10px solid #D87718'";
                }
            }
            $deadlinesOutput .= "<li {$style}>";
            $deadlinesOutput .= "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Planner/planner_view_full.php&search=" . $gibbonPersonID . "&gibbonPlannerEntryID=" . $row["gibbonPlannerEntryID"] . "&viewBy=date&date={$date}&width=1000&height=550'>" . $row["course"] . "." . $row["class"] . "</a> ";
            $deadlinesOutput .= "<span style='font-style: italic'>" . sprintf(_('Due at %1$s on %2$s'), substr($row["homeworkDueDateTime"], 11, 5), dateConvertBack($guid, substr($row["homeworkDueDateTime"], 0, 10)));
            $deadlinesOutput .= "</li>";
        }
        $deadlinesOutput .= "</ol>";
    }
    if ($deadlines == FALSE) {
        $deadlinesOutput .= "<div style='margin-top: 2px' class='warning'>";
        $deadlinesOutput .= _("There are no records to display.");
        $deadlinesOutput .= "</div>";
    }
    //PREPARE TIMETABLE
    $timetable = FALSE;
    $timetableOutput = "";
    if (isActionAccessible($guid, $connection2, "/modules/Timetable/tt_view.php")) {
        $date = date("Y-m-d");
        if (isset($_POST["ttDate"])) {
            $date = dateConvert($guid, $_POST["ttDate"]);
        }
        $params = "";
        if ($classes != FALSE or $grades != FALSE or $deadlines != FALSE) {
            $params = "&tab=1";
        }
        $timetableOutputTemp = renderTT($guid, $connection2, $gibbonPersonID, NULL, NULL, dateConvertToTimestamp($date), "", $params, TRUE);
        if ($timetableOutputTemp != FALSE) {
            $timetable = TRUE;
            $timetableOutput .= $timetableOutputTemp;
        }
    }
    //PREPARE ACTIVITIES
    $activities = FALSE;
    $activitiesOutput = FALSE;
    if (!isActionAccessible($guid, $connection2, "/modules/Activities/activities_view.php")) {
        $activitiesOutput .= "<div class='error'>";
        $activitiesOutput .= _("Your request failed because you do not have access to this action.");
        $activitiesOutput .= "</div>";
    } else {
        $activities = TRUE;
        $activitiesOutput .= "<div class='linkTop'>";
        $activitiesOutput .= "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Activities/activities_view.php'>" . _('View Available Activities') . "</a>";
        $activitiesOutput .= "</div>";
        $dateType = getSettingByScope($connection2, 'Activities', 'dateType');
        if ($dateType == "Term") {
            $maxPerTerm = getSettingByScope($connection2, 'Activities', 'maxPerTerm');
        }
        try {
            $dataYears = array("gibbonPersonID" => $gibbonPersonID);
            $sqlYears = "SELECT * FROM gibbonStudentEnrolment JOIN gibbonSchoolYear ON (gibbonStudentEnrolment.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID) WHERE gibbonSchoolYear.status='Current' AND gibbonPersonID=:gibbonPersonID ORDER BY sequenceNumber DESC";
            $resultYears = $connection2->prepare($sqlYears);
            $resultYears->execute($dataYears);
        } catch (PDOException $e) {
            $activitiesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        if ($resultYears->rowCount() < 1) {
            $activitiesOutput .= "<div class='error'>";
            $activitiesOutput .= _("There are no records to display.");
            $activitiesOutput .= "</div>";
        } else {
            $yearCount = 0;
            while ($rowYears = $resultYears->fetch()) {
                $yearCount++;
                try {
                    $data = array("gibbonPersonID" => $gibbonPersonID, "gibbonSchoolYearID" => $rowYears["gibbonSchoolYearID"]);
                    $sql = "SELECT gibbonActivity.*, gibbonActivityStudent.status, NULL AS role FROM gibbonActivity JOIN gibbonActivityStudent ON (gibbonActivity.gibbonActivityID=gibbonActivityStudent.gibbonActivityID) WHERE gibbonActivityStudent.gibbonPersonID=:gibbonPersonID AND gibbonSchoolYearID=:gibbonSchoolYearID AND active='Y' ORDER BY name";
                    $result = $connection2->prepare($sql);
                    $result->execute($data);
                } catch (PDOException $e) {
                    $activitiesOutput .= "<div class='error'>" . $e->getMessage() . "</div>";
                }
                if ($result->rowCount() < 1) {
                    $activitiesOutput .= "<div class='error'>";
                    $activitiesOutput .= _("There are no records to display.");
                    $activitiesOutput .= "</div>";
                } else {
                    $activitiesOutput .= "<table cellspacing='0' style='width: 100%'>";
                    $activitiesOutput .= "<tr class='head'>";
                    $activitiesOutput .= "<th>";
                    $activitiesOutput .= _("Activity");
                    $activitiesOutput .= "</th>";
                    $options = getSettingByScope($connection2, "Activities", "activityTypes");
                    if ($options != "") {
                        $activitiesOutput .= "<th>";
                        $activitiesOutput .= _("Type");
                        $activitiesOutput .= "</th>";
                    }
                    $activitiesOutput .= "<th>";
                    if ($dateType != "Date") {
                        $activitiesOutput .= _("Term");
                    } else {
                        $activitiesOutput .= _("Dates");
                    }
                    $activitiesOutput .= "</th>";
                    $activitiesOutput .= "<th>";
                    $activitiesOutput .= _("Status");
                    $activitiesOutput .= "</th>";
                    $activitiesOutput .= "</tr>";
                    $count = 0;
                    $rowNum = "odd";
                    while ($row = $result->fetch()) {
                        if ($count % 2 == 0) {
                            $rowNum = "even";
                        } else {
                            $rowNum = "odd";
                        }
                        $count++;
                        //COLOR ROW BY STATUS!
                        $activitiesOutput .= "<tr class={$rowNum}>";
                        $activitiesOutput .= "<td>";
                        $activitiesOutput .= $row["name"];
                        $activitiesOutput .= "</td>";
                        if ($options != "") {
                            $activitiesOutput .= "<td>";
                            $activitiesOutput .= trim($row["type"]);
                            $activitiesOutput .= "</td>";
                        }
                        $activitiesOutput .= "<td>";
                        if ($dateType != "Date") {
                            $terms = getTerms($connection2, $_SESSION[$guid]["gibbonSchoolYearID"], true);
                            $termList = "";
                            for ($i = 0; $i < count($terms); $i = $i + 2) {
                                if (is_numeric(strpos($row["gibbonSchoolYearTermIDList"], $terms[$i]))) {
                                    $termList .= $terms[$i + 1] . "<br/>";
                                }
                            }
                            $activitiesOutput .= $termList;
                        } else {
                            if (substr($row["programStart"], 0, 4) == substr($row["programEnd"], 0, 4)) {
                                if (substr($row["programStart"], 5, 2) == substr($row["programEnd"], 5, 2)) {
                                    $activitiesOutput .= date("F", mktime(0, 0, 0, substr($row["programStart"], 5, 2))) . " " . substr($row["programStart"], 0, 4);
                                } else {
                                    $activitiesOutput .= date("F", mktime(0, 0, 0, substr($row["programStart"], 5, 2))) . " - " . date("F", mktime(0, 0, 0, substr($row["programEnd"], 5, 2))) . "<br/>" . substr($row["programStart"], 0, 4);
                                }
                            } else {
                                $activitiesOutput .= date("F", mktime(0, 0, 0, substr($row["programStart"], 5, 2))) . " " . substr($row["programStart"], 0, 4) . " -<br/>" . date("F", mktime(0, 0, 0, substr($row["programEnd"], 5, 2))) . " " . substr($row["programEnd"], 0, 4);
                            }
                        }
                        $activitiesOutput .= "</td>";
                        $activitiesOutput .= "<td>";
                        if ($row["status"] != "") {
                            $activitiesOutput .= $row["status"];
                        } else {
                            $activitiesOutput .= "<i>" . _('NA') . "</i>";
                        }
                        $activitiesOutput .= "</td>";
                        $activitiesOutput .= "</tr>";
                    }
                    $activitiesOutput .= "</table>";
                }
            }
        }
    }
    //GET HOOKS INTO DASHBOARD
    $hooks = array();
    try {
        $dataHooks = array();
        $sqlHooks = "SELECT * FROM gibbonHook WHERE type='Parental Dashboard'";
        $resultHooks = $connection2->prepare($sqlHooks);
        $resultHooks->execute($dataHooks);
    } catch (PDOException $e) {
        print "<div class='error'>" . $e->getMessage() . "</div>";
    }
    if ($resultHooks->rowCount() > 0) {
        $count = 0;
        while ($rowHooks = $resultHooks->fetch()) {
            $options = unserialize($rowHooks["options"]);
            //Check for permission to hook
            try {
                $dataHook = array("gibbonRoleIDCurrent" => $_SESSION[$guid]["gibbonRoleIDCurrent"], "sourceModuleName" => $options["sourceModuleName"]);
                $sqlHook = "SELECT gibbonHook.name, gibbonModule.name AS module, gibbonAction.name AS action FROM gibbonHook JOIN gibbonModule ON (gibbonHook.gibbonModuleID=gibbonModule.gibbonModuleID) JOIN gibbonAction ON (gibbonAction.gibbonModuleID=gibbonModule.gibbonModuleID) JOIN gibbonPermission ON (gibbonPermission.gibbonActionID=gibbonAction.gibbonActionID) WHERE gibbonAction.gibbonModuleID=(SELECT gibbonModuleID FROM gibbonModule WHERE gibbonPermission.gibbonRoleID=:gibbonRoleIDCurrent AND name=:sourceModuleName) AND gibbonHook.type='Parental Dashboard'  AND gibbonAction.name='" . $options["sourceModuleAction"] . "' AND gibbonModule.name='" . $options["sourceModuleName"] . "' ORDER BY name";
                $resultHook = $connection2->prepare($sqlHook);
                $resultHook->execute($dataHook);
            } catch (PDOException $e) {
            }
            if ($resultHook->rowCount() == 1) {
                $rowHook = $resultHook->fetch();
                $hooks[$count]["name"] = $rowHooks["name"];
                $hooks[$count]["sourceModuleName"] = $rowHook["module"];
                $hooks[$count]["sourceModuleInclude"] = $options["sourceModuleInclude"];
                $count++;
            }
        }
    }
    if ($classes == FALSE and $grades == FALSE and $deadlines == FALSE and $timetable == FALSE and $activities == FALSE and count($hooks) < 1) {
        $return .= "<div class='warning'>";
        $return .= _("There are no records to display.");
        $return .= "</div>";
    } else {
        $defaultTab = 0;
        if (isset($_GET["tab"])) {
            $defaultTab = $_GET["tab"];
        }
        $return .= "<script type='text/javascript'>";
        $return .= "\$(function() {";
        $return .= "\$( \"#" . $gibbonPersonID . "tabs\" ).tabs({";
        $return .= "active: " . $defaultTab . ",";
        $return .= "ajaxOptions: {";
        $return .= "error: function( xhr, status, index, anchor ) {";
        $return .= "\$( anchor.hash ).html(";
        $return .= "\"Couldn't load this tab.\" );";
        $return .= "}";
        $return .= "}";
        $return .= "});";
        $return .= "});";
        $return .= "</script>";
        $return .= "<div id='" . $gibbonPersonID . "tabs' style='margin: 0 0'>";
        $return .= "<ul>";
        if ($classes != FALSE or $grades != FALSE or $deadlines != FALSE) {
            $return .= "<li><a href='#tabs1'>" . _('Learning Overview') . "</a></li>";
        }
        if ($timetable != FALSE) {
            $return .= "<li><a href='#tabs2'>" . _('Timetable') . "</a></li>";
        }
        if ($activities != FALSE) {
            $return .= "<li><a href='#tabs3'>" . _('Activities') . "</a></li>";
        }
        $tabCountExtra = 3;
        foreach ($hooks as $hook) {
            $tabCountExtra++;
            $return .= "<li><a href='#tabs" . $tabCountExtra . "'>" . _($hook["name"]) . "</a></li>";
        }
        $return .= "</ul>";
        if ($classes != FALSE or $grades != FALSE or $deadlines != FALSE) {
            $return .= "<div id='tabs1'>";
            $return .= $plannerOutput;
            $return .= $gradesOutput;
            $return .= $deadlinesOutput;
            $return .= "</div>";
        }
        if ($timetable != FALSE) {
            $return .= "<div id='tabs2'>";
            $return .= $timetableOutput;
            $return .= "</div>";
        }
        if ($activities != FALSE) {
            $return .= "<div id='tabs3'>";
            $return .= $activitiesOutput;
            $return .= "</div>";
        }
        $tabCountExtra = 3;
        foreach ($hooks as $hook) {
            $tabCountExtra++;
            $return .= "<div style='min-height: 100px' id='tabs" . $tabCountExtra . "'>";
            $include = $_SESSION[$guid]["absolutePath"] . "/modules/" . $hook["sourceModuleName"] . "/" . $hook["sourceModuleInclude"];
            if (!file_exists($include)) {
                $return .= "<div class='error'>";
                $return .= _("The selected page cannot be displayed due to a hook error.");
                $return .= "</div>";
            } else {
                $return .= (include $include);
            }
            $return .= "</div>";
        }
        $return .= "</div>";
    }
    return $return;
}
Пример #7
0
<?php

require_once dirname(__FILE__) . '/../function/func_addorder.php';
if ($_GET['q'] > 0) {
    $idproduct = $_GET['q'];
    $getUnit = getUnit($idproduct);
    echo "<option>กรุณาเลือกหน่วยขาย</option>";
    foreach ($getUnit as $value) {
        $val_idunit = $value['idunit'];
        $val_name_unit = $value['name_unit'];
        $val_price_unit = $value['price_unit'];
        $val_type_unit = $value['type_unit'];
        $val_idunitsub = $val_idunit + 1;
        echo "<option value={$val_idunit}>{$val_name_unit}</option>";
    }
}
                </div>
            </div>
            <div class="form-group col-xs-12" style="float:left;width:50%;">
                <label for="name_unit">หน่วยสินค้า</label><label class="text-danger">*</label>
                <div class="form-group input-group">
                    <span class="input-group-addon"><i class="fa fa-circle-o-notch"  ></i></span>
                    <select class="form-control" id="name_unit" name="name_unit" onchange="LoadData(this.value)" required >
                        <option selected value="<?php 
echo $val_idunit;
?>
"><?php 
echo $val_name_unit;
?>
</option>
                        <?php 
$getUnit = getUnit($val_idproduct, $val_idunit);
foreach ($getUnit as $value) {
    $val_idunit = $value['idunit'];
    $val_name_unit = $value['name_unit'];
    ?>
                            <option value="<?php 
    echo $val_idunit;
    ?>
"><?php 
    echo $val_name_unit;
    ?>
</option><?php 
}
?>
                    </select>
                </div>
Пример #9
0
<?php

/**
 * @api {GET} /unit/:id 			Fetch a Unit by Id
 * @apiName fetchUnitById
 * @apiGroup Unit
 *
 * @apiParam {Number} id 			Units unique ID.
 * @apiParam {Number} channeldId 	Id of Parent Channel.
 *
 * @apiSuccess {Unit} 				Unit 	Unit and its Overlays
 *
 */
$app->get('/unit/:id(/:channelId)', function ($id, $channelId = 0) {
    include_once 'libs/unit.php';
    echo json_encode(getUnit($id, $channelId));
});
/**
 * @api {POST} /unit	 	Create a Unit
 * @apiName createUnit
 * @apiGroup Unit
 *
 *
 * @apiSuccess {Unit} Unit 	Unit
 * @apiPermission Author of the Unit
 *
 */
$app->post('/unit', function () use($app) {
    include_once 'libs/unit.php';
    echo json_encode(createUnit($app->request->getBody()));
});
Пример #10
0
function GraphPie($chart, $id_chart, $id_plan, $id_item, $tag, $from, $low, $mid, $max, $dir)
{
    $dt = getDates($from);
    $plan = getPlan($id_plan);
    $item = getItem($id_item);
    $unit = getUnit($id_item);
    $from = $dt[0];
    $to = $dt[1];
    $sum = $low + $mid + $max;
    if ($sum == 0) {
        $sum = 1.0E+18;
    }
    if ($dir == 0) {
        $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red');
        $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03');
        $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green');
    } else {
        $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red');
        $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03');
        $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green');
    }
    $title = '% de results for "' . $item . '" on plan "' . $plan . '"';
    $subtitle = 'From ' . $from . ' to ' . $to;
    $chart = chartHeader($chart, $id_chart, $title, $subtitle, 'Quantity', null);
    $chart->plotOptions->series->pointPadding = -0.333333;
    $chart->series[0]->type = 'pie';
    $chart->series[0]->data = $data0;
    $chart->series[0]->tooltip->valueSuffix = '%';
    $chart->series[0]->name = 'Number of occurencies';
    $chart->series[0]->dataLabels->enabled = true;
    $chart->series[0]->dataLabels->crop = false;
    $chart->series[0]->dataLabels->align = 'center';
    $chart->series[0]->dataLabels->y = -6;
    $chart->series[0]->dataLabels->color = 'black';
    //'#000000';
    $chart->series[0]->dataLabels->style->fontSize = '13px';
    $chart->series[0]->dataLabels->style->fontFamily = 'Verdana, sans-serif';
    $chart->series[0]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.') + '%';}");
    return $chart;
}
Пример #11
0
$datan = mysql_query("SELECT DISTINCT lotno, division, frange,rsd FROM verify where division='{$divi}' and  year='{$kapa}' order by lotno") or die("No table");
$i = 1;
$ttl = 0;
$ttl1 = 0;
$ttl2 = 0;
echo "<table width=900px border=1><tr><td>S.No.</td><td>Lot No.</td><td>Unit</td><td>Range</td><td>Forests</td><td>Name of RSD</td><td>Forest Division</td><td>Actual No. of Blazes</td><td>No. of Blazes Declared Fit after Verification</td><td>No. of Blazes Declared Unfit</td></tr>";
while ($row = mysql_fetch_array($datan)) {
    $lotno = $row['lotno'];
    $currlot = addslashes($lotno);
    $divi = $row['division'];
    $frange = $row['frange'];
    $rsd = $row['rsd'];
    $totBlaze = getTotBlazes($currlot, $divi, $kapa);
    $fitBlaze = getFitBlazes($currlot, $divi, $kapa);
    $unfitBlaze = $totBlaze - $fitBlaze;
    echo "<tr><td>" . $i . "</td><td>" . $lotno . "/" . $kapa . "(" . getExten($currlot, $divi) . ")</td><td>" . getUnit($currlot, $divi) . "</td><td>" . $frange . "</td><td>" . getForests($currlot, $divi, $kapa) . "</td><td>" . $rsd . "</td><td>" . $divi . "</td><td>" . $totBlaze . "</td><td>" . $fitBlaze . "</td><td>" . $unfitBlaze . "</td></tr>";
    $ttl += $totBlaze;
    $ttl1 += $fitBlaze;
    $ttl2 += $unfitBlaze;
    $i++;
}
echo "<tr><td colspan=7><b><font color=red>Total</td><td><b><font color=red>" . $ttl . "</td><td><b><font color=red>" . $ttl1 . "</td><td><b><font color=red>" . $ttl2 . "</td></tr>";
echo "</table>";
?>
 <br>
<br>
<br>
<br>
<h3>Divisional Manager &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
/* Load css */
$tpl->addCss('angled-headers.css');
/* Get Param */
$params = $this->getWidgetParams();
/* Get DB */
$dbM = $this->getMonitoringDb();
$db = $this->getConfigurationDb();
/* Init Params */
$data = array();
/* Get Data */
$query = "SELECT host_name, service_description, service_id, host_id, size.current_value AS size, used.current_value AS used, (used.current_value/size.current_value*100) AS percent FROM index_data, metrics used, metrics size WHERE service_description LIKE 'Disk%' AND used.index_id = id AND size.index_id = id AND size.metric_name = 'size' AND used.metric_name = 'used' ORDER BY percent DESC LIMIT 10";
$stmt = $dbM->prepare($query);
$stmt->execute();
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
    $row["percent"] = round($row["percent"]);
    $unit = getUnit($row['size']);
    $row['used'] = formatData($row['used'], $unit);
    $row['size'] = formatData($row['size'], $unit);
    $data[] = $row;
}
function getUnit($value)
{
    $unit = array('o', 'Ko', 'Mo', 'Go', 'To', 'Po');
    $i = 0;
    while ($value > 1024) {
        $value = $value / 1024;
        $i++;
    }
    return array($i, $unit[$i]);
}
function formatData($value, $unit)
Пример #13
0
    if ($unit == "paragraphs") {
        $tableName = "paragraph";
        $field = "text";
        $index = "start_sentence";
    }
    $query = "SELECT * from " . $tableName . " where number = " . $number . " AND narrative_id =" . $narrative . ";";
    $results = mysql_query($query);
    $row = mysql_fetch_array($results);
    $results = array();
    $sent = $row[$field];
    $sent = str_replace("-LRB-", "(", $sent);
    $sent = str_replace("-RRB-", ")", $sent);
    $results['sentence'] = utf8_encode($sent);
    $results['narrative'] = $row['narrative_id'];
    $results['sentence_id'] = $row[$index];
    return $results;
}
//if used as a script
if ($_GET['narrative']) {
    include 'dbsetup.php';
    include 'util.php';
    $narrative = $_GET['narrative'];
    $unit = $_GET['unit'];
    $sentenceNumbers = explode(" ", $_GET['numbers']);
    $sentences = array();
    foreach ($sentenceNumbers as $number) {
        $sent = getUnit($unit, $narrative, $number);
        array_push($sentences, $sent);
    }
    echo json_encode($sentences);
}
Пример #14
0
 print "<td {$style}>";
 print "<b>" . dateConvertBack($guid, $lesson["1"]) . "</b><br/>";
 print date("l", dateConvertToTimestamp($lesson["1"])) . "<br/>";
 print date("F", dateConvertToTimestamp($lesson["1"])) . "<br/>";
 if ($lesson[8] == "Timing Change") {
     print "<u>" . $lesson[8] . "</u><br/><i>(" . substr($lesson[9], 0, 5) . "-" . substr($lesson[10], 0, 5) . ")</i>";
 }
 print "</td>";
 print "<td {$style}>";
 print $lesson["4"] . "<br/>";
 print "<span style='font-size: 85%; font-style: italic'>" . substr($lesson["2"], 0, 5) . " - " . substr($lesson["3"], 0, 5) . "</span>";
 print "</td>";
 print "<td {$style}>";
 if ($lesson["0"] == "Planned") {
     print "<b>" . $lesson["5"] . "</b><br/>";
     $unit = getUnit($connection2, $lesson[11], $lesson[13], $lesson[14]);
     if (isset($unit[0])) {
         print "<span style='font-size: 85%; font-style: italic'>";
         print $unit[0];
         if (isset($unit[1])) {
             if ($unit[1] != "") {
                 print "<br/><i>" . $unit[1] . " Unit</i>";
             }
         }
         print "</span>";
     }
 }
 print "</td>";
 print "<td {$style}>";
 if ($lesson["0"] == "Unplanned") {
     print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/" . $_SESSION[$guid]["module"] . "/planner_add.php&viewBy={$viewBy}&gibbonCourseClassID={$gibbonCourseClassID}&date=" . $lesson[1] . "&timeStart=" . $lesson[2] . "&timeEnd=" . $lesson[3] . "&subView={$subView}'><img style='margin-bottom: -4px' title='" . _('Add') . "' src='./themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/page_new.png'/></a>";
Пример #15
0
     getItemGroup($conn);
     break;
 case 'getItemList':
     getItemList($conn);
     break;
 case 'getShipmentStatus':
     getShipmentStatus($conn);
     break;
 case "getFundingSource":
     getFundingSource($conn);
     break;
 case "getYearList":
     getYearList($conn);
     break;
 case "getUnit":
     getUnit($conn);
     break;
 case "getDosesForm":
     getDosesForm($conn);
     break;
 case "getFormulation":
     getFormulation($conn);
     break;
 case "getFacilityType":
     getFacilityType($conn);
     break;
 case "getFacilityLevel":
     getFacilityLevel($conn);
     break;
 case "getRegionList":
     getRegionList($conn);
Пример #16
0
 }
 $data = array();
 foreach ($fields as $k) {
     $data[$k] = $obj[$k];
 }
 if ($obj['date_entered']) {
     $data['bdate'] = date('Y-m-d', strtotime($obj['date_entered']));
     $tmp = mysql_fetch_assoc(query("select date_format(date_buy,'%H') as bhour, date_format(date_buy,'%i') as bminute from panelie_user_check where user_id=" . $obj['user_id'] . ' and check_number=' . intval($obj['check_id']) . " and date_format(date_buy,'%Y-%m-%d')='" . $data['bdate'] . "'"));
     if ($tmp && ($tmp['bhour'] != 0 || $tmp['bminute'] != 0)) {
         $data['bhour'] = $tmp['bhour'];
         $data['bminute'] = $tmp['bminute'];
     }
 }
 $data['first_date'] = getFirstDate($obj['user_id']);
 $data = array_merge($data, getShop($obj['user_id'], $obj['shop_id']));
 $data = array_merge($data, getUnit($obj['unit_id']));
 $data = array_merge($data, getCity($obj['city_id']));
 $data = array_merge($data, getDistance($obj['user_id'], $obj['shop_id']));
 $data = array_merge($data, getBarcode($obj['barcode_value']));
 if (!$data['product_name']) {
     $data['product_name'] = $obj['corrected_name'];
     if (!$data['product_name']) {
         unset($data['product_name']);
     }
 }
 $data = array_merge($data, calcWeight($data));
 $data = array_merge($data, getRange($obj['date_entered']));
 $data = array_merge($data, getNoPurchases($obj['date_entered']));
 $data = array_merge($data, getFamilyDetails($obj['user_id']));
 $data['discount'] = countDiscount($obj['price'], $obj['discount']);
 if ($obj['id']) {
Пример #17
0
function graphCompare($chart, $item, $min, $max, $ch)
{
    echo '<div class="col-xs-2"><select class="form-control" name="' . $item . '" id="' . $item . '">';
    if (!isset($_POST[$item])) {
        $_POST[$item] = '';
        echo '<option selected value="Seleccione">Select</option>';
    } else {
        echo '<option value="Seleccione">Select</option>';
    }
    $itemsSelected = '';
    $monitors = readMonitors();
    foreach ($monitors as $items) {
        if (isset($_POST) && $_POST[$item] == $items['id_item']) {
            $itemsSelected = $items['descriptionLong'];
            echo '<option selected value="' . $items['id_item'] . '">' . $items['descriptionLong'] . '</option>';
        } else {
            echo '<option value="' . $items['id_item'] . '">' . $items['descriptionLong'] . '</option>';
        }
        $itemsArry[$items['id_item']] = array("unit" => $items['unit'], "name" => $items['descriptionLong']);
    }
    echo '</select></div>';
    $index = 0;
    if (isset($_POST['date1'])) {
        $days = Days($_POST['date1'], $_POST['date2']);
    }
    if (!isset($_POST['avg'])) {
        $_POST['avg'] = '4 Hours';
    }
    $divide = getAverage($_POST['avg']);
    $divide = $divide[1];
    /*
    	$days = 1;
    	$days = Days($_POST['date1'], $_POST['date2']);
    	
    	if ($days > 7 * 1) $format = '%Y/%m/%d %H:00:00';
    	if ($days > 7 * 2) $divide = 3600 * 4;
    	if ($days > 7 * 4) $divide = 3600 * 6;
    	if ($days > 7 * 5) $format = '%Y/%m/%d';
    	if ($days > 7 * 8) $divide = 3600 * 24 * 7;
    	if ($days > 7 * 16) $format = '%Y/%m';
    */
    $col = 0;
    $timeStart = strtotime($_POST['date1'] . ' 00:00:00');
    $timeFinish = strtotime($_POST['date2'] . ' 23:59:59');
    $hosts = readHosts(0);
    foreach ($hosts as $r) {
        $unit = getUnit($_POST[$item]);
        $div = 1;
        if ($unit == 'bps') {
            $div = 1024;
            ///BUGS BGS009
            $unit = 'Mbps';
        }
        $sonda = $r['host'];
        $id_host = $r['id_host'];
        $id_item = $_POST[$item];
        if ($id_item > 0) {
            $rawData = loadRAWData($_POST['date1'], 0, $id_item, $_POST['date2'], $id_host);
            $history = $rawData['historyList'][$id_host];
            unset($finalData);
            unset($data2);
            if (isset($history)) {
                foreach ($history as $ddata) {
                    $tk = round($ddata['clock'] / $divide, 0) * $divide;
                    if (!isset($finalData[$tk])) {
                        $finalData[$tk] = array('clock' => $tk, 'sum' => 0, 'cnt' => 0);
                    }
                    $sum = $finalData[$tk]['sum'];
                    $cnt = $finalData[$tk]['cnt'];
                    $x = $sum + $ddata['value'];
                    $y = $cnt + 1;
                    $finalData[$tk] = array('clock' => $tk, 'sum' => $x, 'cnt' => $y);
                }
                $data2[] = array($timeStart * 1000, null);
                foreach ($finalData as $row) {
                    if ($row['cnt'] != 0) {
                        $v = round($row['sum'] / $row['cnt'] * 1 / $div, 2);
                    }
                    $data2[] = array($row['clock'] * 1000, $v * 1 / $div, 2);
                    if (!isset($minClock)) {
                        $minClock = $row['clock'];
                        $maxClock = $row['clock'];
                        $maxClockIndex = $index;
                    } else {
                        if ($minClock > $row['clock']) {
                            $minClock = $row['clock'];
                        }
                        if ($maxClock < $row['clock']) {
                            $maxClock = $row['clock'];
                            $maxClockIndex = $index;
                        }
                    }
                }
            }
            if (isset($data2)) {
                $data2[] = array($timeFinish * 1000, null);
                $chart->yAxis->title->text = $unit;
                $chart->series[]->name = $sonda;
                $chart->series[$index]->type = 'spline';
                $chart->series[$index]->data = $data2;
                $chart->series[$index]->color = getColor($col);
                $index++;
            }
            unset($rawData);
            unset($history);
            $col++;
        }
    }
    if (!isset($maxClock)) {
        $maxClock = 0;
        $minClock = 0;
    }
    if (!isset($unit)) {
        $unit = "";
    }
    $title = getItem($_POST[$item]);
    $subtitle = 'From ' . $_POST['date1'] . ' to ' . $_POST['date2'];
    $chart = chartHeader($chart, 'c_' . $item, $title, $subtitle, $unit, null);
    $chart->xAxis->type = 'datetime';
    //$chart->plotOptions->series->animation->complete = new HighchartJsExpr(" function () {redraw" . $ch . "();}");
    $chart->tooltip->formatter = new HighchartJsExpr("\n            function() {\n                var s = '<b>'+ Highcharts.dateFormat('%e. %b %H:%M',this.x) +'</b>';    \n                \$.each(this.points, function(i, point) {\n                    s += '<br/><span style=\"color:'+point.series.color+'\">'+ point.series.name +': '+ point.y +' " . $unit . "</span><b>';\n                });\n                return s;\n            }");
    //echo "\n" . '<script> function redraw' . $ch . '() { ' . $ch . '.xAxis['.$maxClockIndex.'].setExtremes(' . $minClock* 1000 . ', ' . $maxClock* 1000 . ');}  </script>';
    return $chart;
}