Example #1
0
/**
 * Fills template with headers and cells array
 * @param $headers - array of column headers
 * @param $cells - array of cell values
 * @param $caption - caption of table
 * @param $rows - number of rows
 * @param $cols - caption of columns
 */
function fillTable($headers, $cells, $caption, $rows, $cols)
{
    // initializing of fasttemplate
    $ft = new FastTemplate("./templates/");
    $ft->define(array('table' => "flextable.html"));
    $ft->define_dynamic("header", "table");
    $ft->define_dynamic("rows", "table");
    $ft->define_dynamic("cols", "table");
    //handling headers (column names)
    foreach ($headers as $head) {
        $ft->assign(array('header' => $head));
        $ft->parse('HEADERS', ".header");
    }
    // handling cells
    foreach ($cells as $row) {
        foreach ($row as $cell) {
            $ft->assign(array('cellvalue' => $cell));
            $ft->parse('COLS', ".cols");
        }
        $ft->parse('ROWS', ".rows");
        $ft->clear("COLS");
    }
    $ft->assign("caption", $caption);
    $ft->assign("rows", $rows);
    $ft->assign("cols", $cols);
    $ft->parse('MAIN', "table");
    $ft->FastPrint('MAIN');
}
Example #2
0
function displayIndex($userID)
{
    $tpl = new FastTemplate("templates/");
    $tpl->define(array("web_main" => "web_main.html", "web_header" => "web_header.html", "head_script" => "index/head_script.html", "user" => "index/user.html", "department" => "index/department.html", "list_item" => "index/list_item.html", "group" => "index/group.html", "comment" => "index/comment.html", "link" => "index/link.html", "image" => "index/image.html", "invitation" => "index/invitation.html", "group_option" => "index/group_option.html", "body" => "index/body.html", "web_nav" => "web_nav.html", "web_footer" => "web_footer.html"));
    $userDAO = new UserDAO();
    $user = $userDAO->getUserByID($userID);
    //initial owner group
    $groupDAO = new GroupDAO();
    $groups = $groupDAO->getGroupsByOwner($user);
    if ($groups === null) {
        $tpl->assign("INDEX_GROUP_OPTION", "");
    } else {
        foreach ($groups as $ownerGroup) {
            $tpl->assign("INDEX_GROUP_OPTIONID", $ownerGroup->getGroupID());
            $tpl->assign("INDEX_GROUP_OPTIONNAME", $ownerGroup->getGroupName());
            $tpl->parse("INDEX_GROUP_OPTION", ".group_option");
        }
    }
    //initial list item
    $gmDAO = new GroupMemberDAO();
    $gms = $gmDAO->getGroupMembersByUser($user);
    if ($gms !== null) {
        $i = 1;
        $hasoneaccept = false;
        foreach ($gms as $gm) {
            if ($gm->getAcceptStatus() == "2") {
                continue;
            }
            $group = $gm->getGroup();
            $tpl->assign("INDEX_LIST_ITEM_GROUPID", $group->getGroupID());
            if ($i == 1) {
                $tpl->assign("INDEX_GROUP_HEADER", $group->getGroupName());
                $tpl->assign("INDEX_LIST_ITEM_ACTIVE", "active");
            } else {
                $tpl->assign("INDEX_LIST_ITEM_ACTIVE", "");
            }
            $tpl->assign("INDEX_LIST_ITEM_SEQ", $i);
            $tpl->assign("INDEX_LIST_ITEM_GROUPNAME", $group->getGroupName());
            $tpl->parse("INDEX_LIST_ITEM_LI", ".list_item");
            $hasoneaccept = true;
            $i++;
        }
        if ($hasoneaccept == false) {
            $tpl->assign("INDEX_LIST_ITEM_LI", "");
            $tpl->assign("INDEX_GROUP_HEADER", "");
        }
    } else {
        $tpl->assign("INDEX_LIST_ITEM_LI", "");
        $tpl->assign("INDEX_GROUP_HEADER", "");
    }
    //initial comments
    $recordDAO = new RecordDAO();
    if ($gms !== null) {
        $hasGMSflag = false;
        $i = 1;
        foreach ($gms as $gm) {
            if ($gm->getAcceptStatus() == "2") {
                continue;
            }
            $group = $gm->getGroup();
            if ($i == 1) {
                $tpl->assign("INDEX_GROUP_HIDE", "");
            } else {
                $tpl->assign("INDEX_GROUP_HIDE", "hide");
            }
            $tpl->assign("INDEX_GROUP_SEQ", $i);
            $records = $recordDAO->getRecordsByGroup($group);
            if ($records === null) {
                $tpl->assign("INDEX_GROUP_COMMENT", "");
            } else {
                $hasOneFlag = false;
                $tpl->clear("INDEX_GROUP_COMMENT");
                foreach ($records as $rec) {
                    if ($rec->getDisplayStatus() === "2") {
                        continue;
                    }
                    $commentUser = $rec->getUser();
                    $tpl->assign("INDEX_GROUP_COMMENT_USERPHOTO", $commentUser->getPhotoURL());
                    $tpl->assign("INDEX_GROUP_COMMENT_USERNAME", $commentUser->getFirstName() . " " . $commentUser->getLastName());
                    $tpl->assign("INDEX_GROUP_COMMENT_TIME", $rec->getTime());
                    $type = $rec->getMessageType();
                    $con = $rec->getContent();
                    if ($type == "1") {
                        $tpl->assign("INDEX_GROUP_COMMENT_CONTENT", htmlentities($con));
                    } else {
                        if ($type == "2") {
                            $tpl->assign("INDEX_CONTENT_IMGURL", $con);
                            $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "image");
                        } else {
                            if ($type == "3") {
                                $tpl->assign("INDEX_GROUP_CONTENT_LINKURL", $con);
                                $baseName = pathinfo($con, PATHINFO_BASENAME);
                                $pos = strpos($baseName, "_");
                                $oriName = substr($baseName, $pos + 1);
                                $tpl->assign("INDEX_GROUP_CONTENT_LINKNAME", htmlentities($oriName));
                                $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "link");
                            } else {
                                if ($type == "4") {
                                    $tpl->assign("INDEX_GROUP_CONTENT_LINKURL", "http://" . rawurlencode($con));
                                    $tpl->assign("INDEX_GROUP_CONTENT_LINKNAME", htmlentities($con));
                                    $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "link");
                                }
                            }
                        }
                    }
                    $tpl->parse("INDEX_GROUP_COMMENT", ".comment");
                    $hasOneFlag = true;
                }
                if ($hasOneFlag == false) {
                    $tpl->assign("INDEX_GROUP_COMMENT", "");
                }
            }
            $tpl->parse("INDEX_GROUP", ".group");
            $hasGMSflag = true;
            $i++;
        }
        if ($hasGMSflag == false) {
            $tpl->assign("INDEX_GROUP_COMMENT", "");
            $tpl->parse("INDEX_GROUP", "group");
        }
    } else {
        $tpl->assign("INDEX_GROUP_COMMENT", "");
        $tpl->parse("INDEX_GROUP", "group");
    }
    //initial department and user
    $result = findDepartAndUser(1, $userID);
    if (count($result) === 0) {
        $tpl->assign("INDEX_DEPART_USER", "");
    } else {
        foreach ($result as $node) {
            if ($node["type"] == 1) {
                $tpl->assign("INDEX_DEPARTID", $node["id"]);
                $tpl->assign("INDEX_DEPART_NAME", $node["name"]);
                $tpl->parse("INDEX_DEPART_USER", ".department");
            } elseif ($node["type"] == 2) {
                $tpl->assign("INDEX_USERID", $node["id"]);
                $tpl->assign("INDEX_USER_NAME", $node["name"]);
                $tpl->parse("INDEX_DEPART_USER", ".user");
            }
        }
    }
    //initial annocement
    $flag = false;
    $gmArr = $gmDAO->getGroupMembersByUser($user);
    if ($gmArr !== null) {
        foreach ($gmArr as $gmPend) {
            if ($gmPend->getAcceptStatus() == "2") {
                $gmGroup = $gmPend->getGroup();
                $gmOwner = $gmGroup->getOwner();
                $tpl->assign("INDEX_INVITATION_OWNER", $gmOwner->getFirstName() . " " . $gmOwner->getLastName());
                $tpl->assign("INDEX_INVITATION_GROUPNAME", $gmGroup->getGroupName());
                $tpl->assign("INDEX_INVITATION_GROUPID", $gmGroup->getGroupID());
                $tpl->parse("INDEX_INVITATION", ".invitation");
                $flag = true;
            }
        }
    }
    if ($flag === false) {
        $tpl->assign("INDEX_INVITATION", "");
    }
    $tpl->assign("TITLE", "Home");
    $tpl->parse("WEB_HEADER", "web_header");
    $tpl->parse("HEAD_SCRIPT", "head_script");
    $tpl->parse("WEB_NAV", "web_nav");
    $tpl->parse("BODY", ".body");
    $tpl->parse("WEB_FOOTER", "web_footer");
    $tpl->parse("MAIN", "web_main");
    $tpl->FastPrint();
}
Example #3
0
<?php

session_start();
error_reporting(E_ALL ^ E_WARNING);
include_once '../commons.php';
include 'checkResultOperation.php';
header('Cache-control: private, must-revalidate');
//support page back
$template = new FastTemplate("../../view/html/templates/reciteWord");
$template->define(array("main" => "checkResult.html", "ol" => "ol.html", "li" => "li.html"));
$template->assign("OL", "");
$template->assign("ACCURANCY", "");
$template->assign("USER_NAME", $_SESSION['username']);
$template->assign("USER_IMG", $_SESSION['userimg']);
$template->assign("USER_ID", $_SESSION['userID']);
if (isset($_POST["checkAns"])) {
    $class = $_SESSION['class'];
    //echo "class  = ".$class;
    $userID = $_SESSION['userID'];
    $trueNo = showTrueIDs($userID, $class);
    //echo "<BR> trueNo = ".$trueNo;
    $template->clear("OL");
    $wrongNo = showWrongIDs($userID, $class);
    //echo "<BR> wrongNo = ".$wrongNo;
    $acc = intval($trueNo / ($trueNo + $wrongNo) * 100);
    $template->assign("ACCURANCY", $acc . "%");
    saveAcc($userID, $acc);
}
$template->parse("CONTENT", "main");
$template->FastPrint();
include "Includes/class.FastTemplate.php";
$tpl = new FastTemplate("Templates");
$tpl->define(array("WorkoutHistoryPage" => "workoutHistory.html", "WorkoutTable" => "workoutTable.html", "WorkoutRow" => "workoutRow.html", "exerciseData" => "exerciseData.html"));
if (isset($_SESSION["username"])) {
    $allCategoriesDetails = json_decode(getAllCategoriesDetails(), TRUE);
    $db = new database();
    $db->pick_db("workoutlog");
    $userId = getUserIdFromUsername($_SESSION["username"]);
    $query = "SELECT WorkoutDate, WorkoutId FROM tbl_workoutlog_workout WHERE UserId = " . $userId . " ORDER BY WorkoutDate DESC";
    $res = $db->send_sql($query);
    $workouts = $res->fetch_all(MYSQLI_ASSOC);
    if (count($workouts) == 0) {
        $tpl->assign("WORKOUTTABLES", "<p>You haven't recorded any workouts yet!</p>");
    } else {
        foreach ($workouts as $workout) {
            $tpl->clear("EXERCISEROW");
            $query = "SELECT ExerciseId, ExerciseNameId FROM tbl_workoutlog_exercise WHERE WorkoutId = " . $workout['WorkoutId'];
            $res = $db->send_sql($query);
            $exercises = $res->fetch_all(MYSQLI_ASSOC);
            //Find maximum number of sets for any exercise
            $exerciseIds = "(";
            foreach ($exercises as $exercise) {
                $exerciseIds = $exerciseIds . $exercise['ExerciseId'] . ",";
            }
            $exerciseIds = substr($exerciseIds, 0, -1) . ")";
            $query = "SELECT MAX(cnt) as max\n                            FROM\n                            (\n                                SELECT COUNT(*) AS cnt\n                                FROM tbl_workoutlog_exercise e ";
            foreach ($allCategoriesDetails as $category => $details) {
                $query .= "LEFT JOIN tbl_workoutlog_category_" . $category . " `" . $category . "` ON e.ExerciseId = `" . $category . "`.ExerciseId ";
            }
            $query .= "WHERE e.WorkoutId = " . $workout['WorkoutId'] . " \n                                AND e.ExerciseId IN " . $exerciseIds . " \n                                GROUP BY e.ExerciseId\n                            ) AS tbl";
            $res = $db->send_sql($query);