Beispiel #1
0
 /**
  * @url GET user/{userId}
  */
 protected function getAllUserOrder($userId)
 {
     if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
         $statement = 'SELECT * FROM `order` WHERE userId = :userId ORDER BY status DESC';
         $bind = array('userId' => $userId);
         return \Db::getResult($statement, $bind);
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }
Beispiel #2
0
 /**
  * @url GET user/{userId}
  */
 protected function getAllUserSection($userId, $courseId)
 {
     $statement = '
   SELECT * 
     FROM section AS S
    WHERE S.courseId = :courseId
 ';
     $bind = array('courseId' => $courseId);
     return \Db::getResult($statement, $bind);
 }
Beispiel #3
0
   /**
    * @url GET allcourseitem/{courseId}
    */
   protected function getAllCourseItem($courseId)
   {
       $statement = '
 		SELECT * 
 		FROM view_course_item AS VCI
 		WHERE VCI.courseId = :courseId 
 	';
       $bind = array('courseId' => $courseId);
       return \Db::getResult($statement, $bind);
   }
Beispiel #4
0
function RouteReport()
{
    $varResult = Db::getResult('SELECT * FROM routes ORDER BY rtcode');
    echo '<div id="RouteReport" class="RouteReport">' . "\n";
    echo '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
    echo '<tr><th><h3>Route</h3></th><th><h3>Assignment</h3></th></tr>';
    foreach ($varResult as $varRouteReport) {
        echo '<tr><td>' . $varRouteReport['rtcode'] . ' - ' . $varRouteReport['description'] . '</td>';
        echo '<td>' . $varRouteReport['assignment'] . '</td></tr>';
    }
    echo '</table>';
    echo '</div>';
}
Beispiel #5
0
   /**
    * @url GET allcommentdetail/{commenHeaderId}
    */
   protected function getAllCommentDetail($commenHeaderId)
   {
       $statement = '
 		SELECT CD.*, U.nickname, U.avatarId
 		FROM comment_detail AS CD
 		INNER JOIN user AS U
 		   ON U.userId = C.userId
 		WHERE commentHeaderId = :commentHeaderId
 		ORDER BY CD.timestamp
 	';
       $bind = array('commentHeaderId' => $commentHeaderId);
       return \Db::getResult($statement, $bind);
   }
Beispiel #6
0
 /**
  * @url GET item/{courseSectionId}
  */
 protected function getItem($courseSectionId)
 {
     if (\TTO::getRole() == 'admin') {
         $statement = '
 	  		SELECT *
 	  		FROM view_course_item AS CI
 	  		WHERE CI.courseSectionId = :courseSectionId
 	  		ORDER BY CI.courseItemId DESC
 	  	';
         $bind = array('courseSectionId' => $courseSectionId);
         return \Db::getResult($statement, $bind);
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }
Beispiel #7
0
   /**
    * @url GET allnotification/{userId}
    */
   protected function getAllNotification($userId)
   {
       $statement = '
 		SELECT N.*, U.nickname, FU.nickname AS fromNickname
 		FROM notification AS N
 		INNER JOIN user AS U
 		   ON U.userId = N.userId
     INNER JOIN user AS FU
        ON FU.userId = N.fromUserId
 		WHERE N.userId = :userId
 		ORDER BY N.timestamp DESC
 	';
       $bind = array('userId' => $userId);
       return \Db::getResult($statement, $bind);
   }
Beispiel #8
0
    /**
     * @url GET usercourselist/{userId}
     */
    protected function getUserCourseList($userId)
    {
        if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
            $statement = '
	  		SELECT * 
	  		  FROM user_course AS UC
	  		 INNER JOIN  course AS C
	  	      ON UC.courseId = C.courseId
	  		 WHERE UC.userId = :userId 
	  	';
            $bind = array('userId' => $userId);
            return \Db::getResult($statement, $bind);
        } else {
            throw new RestException(401, 'No Authorize or Invalid request !!!');
        }
    }
Beispiel #9
0
 /**
  * @url GET /user/{userId}
  */
 protected function getAllUserItem($userId, $taskId)
 {
     if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
         $statement = '
     SELECT I.*, UI.userId, UI.status, UI.point, UI.userContent
     FROM item AS I
     LEFT OUTER JOIN user_item AS UI
     ON UI.itemId = I.itemId
     AND UI.userId = :userId
     WHERE I.taskId = :taskId
   ';
         $bind = array('userId' => $userId, 'taskId' => $taskId);
         return \Db::getResult($statement, $bind);
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }
Beispiel #10
0
 /**
  * @url GET by-course-section/{userId}/{courseSectionId}
  */
 protected function getByCourseSection($userId, $courseSectionId)
 {
     if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
         $statement = '
 	  		SELECT *
 	  		FROM view_course_item AS CI
 	  		LEFT OUTER JOIN user_course_item AS UCI
 	  		ON CI.courseItemId = UCI.courseItemId
 	  		AND UCI.userId = :userId
 	  		WHERE CI.courseSectionId = :courseSectionId
 	  		ORDER BY CI.courseItemId
 	  	';
         $bind = array('userId' => $userId, 'courseSectionId' => $courseSectionId);
         return \Db::getResult($statement, $bind);
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }
Beispiel #11
0
 /**
  * @url GET user/{userId}
  */
 protected function getAllUserTask($userId, $sectionId)
 {
     if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
         $statement = '
     SELECT T.*, TT.name AS taskTypeName, TT.theme 
     FROM task AS T
     INNER JOIN task_type AS TT
     ON TT.taskTypeId = T.taskTypeId
     LEFT OUTER JOIN user_task AS UT
     ON UT.taskId = T.taskId
     AND UT.userId = :userId
     WHERE sectionId = :sectionId
   ';
         $bind = array('userId' => $userId, 'sectionId' => $sectionId);
         return \Db::getResult($statement, $bind);
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }
Beispiel #12
0
    /**
     * @url GET by-course-item/{userId}/{courseItemId}
     */
    protected function getByCourseItem($userId, $courseItemId)
    {
        if ($userId == \TTO::getUserId() || \TTO::getRole() == 'admin') {
            $statement = '
    			SELECT UCI.*, CI.*, I.code, I.content, I.itemGroupId
    			FROM course_item AS CI
    			INNER JOIN item AS I
    			ON CI.itemId = I.itemId
    			LEFT OUTER JOIN user_course_item AS UCI
    			ON UCI.courseItemId = CI.courseItemId
    			AND UCI.userId = :userId
    			WHERE CI.courseItemId = :courseItemId
    	  	';
            $bind = array('courseItemId' => $courseItemId, 'userId' => $userId);
            $response = \Db::getRow($statement, $bind);
            $itemId = $response['itemId'];
            $userCourseItemId = $response['userCourseItemId'];
            $response += array('allItemDetail' => array());
            $statement = '
                SELECT UCID.*, ID.*
                FROM item_detail AS ID
                LEFT OUTER JOIN user_course_item_detail AS UCID
                ON UCID.itemDetailId = ID.itemDetailId
                AND UCID.userCourseItemId = :userCourseItemId
                WHERE itemId = :itemId 
                ORDER BY seq
			';
            $bind = array('itemId' => $itemId, 'userCourseItemId' => $userCourseItemId);
            $allItemDetail = \Db::getResult($statement, $bind);
            foreach ($allItemDetail as $itemDetail) {
                if ($itemDetail['itemTypeId'] == 1) {
                    if ($itemDetail['status'] == 'done') {
                        $statement = '
							SELECT itemRadioId FROM user_course_item_radio 
							 WHERE userCourseItemId = :userCourseItemId
							   AND itemDetailId     = :itemDetailId
						';
                        $bind = array('userCourseItemId' => $userCourseItemId, 'itemDetailId' => $itemDetail['itemDetailId']);
                        $userItemRadioId = \Db::getValue($statement, $bind);
                        $itemDetail += array('userItemRadioId' => $userItemRadioId);
                    }
                    $statement = 'SELECT * FROM item_radio WHERE itemDetailId = :itemDetailId';
                    $bind = array('itemDetailId' => $itemDetail['itemDetailId']);
                    $allItemRadio = \Db::getResult($statement, $bind);
                    $itemDetail += array('allItemRadio' => $allItemRadio);
                }
                if ($itemDetail['itemTypeId'] == 3) {
                    $statement = '
						SELECT IDS.*, UCIS.userIsAnswer
						  FROM item_select AS IDS
						LEFT OUTER JOIN user_course_item_select AS UCIS
						    ON IDS.itemSelectId = UCIS.itemSelectId
						   AND IDS.itemDetailId = UCIS.itemDetailId
						   AND UCIS.userCourseItemId = :userCourseItemId
						 WHERE IDS.itemDetailId = :itemDetailId
					';
                    $bind = array('itemDetailId' => $itemDetail['itemDetailId'], 'userCourseItemId' => $userCourseItemId);
                    $allItemSelect = \Db::getResult($statement, $bind);
                    $itemDetail += array('allItemSelect' => $allItemSelect);
                }
                if ($itemDetail['itemTypeId'] == 4) {
                    $statement = '
						SELECT II.*, UCII.userAnswer
						  FROM item_input AS II
						LEFT OUTER JOIN user_course_item_input AS UCII
						    ON II.itemInputId  = UCII.itemInputId
						   AND II.itemDetailId = UCII.itemDetailId
						   AND UCII.userCourseItemId = :userCourseItemId
						 WHERE II.itemDetailId = :itemDetailId
					';
                    $bind = array('itemDetailId' => $itemDetail['itemDetailId'], 'userCourseItemId' => $userCourseItemId);
                    $allItemInput = \Db::getResult($statement, $bind);
                    $itemDetail += array('allItemInput' => $allItemInput);
                }
                $response['allItemDetail'][] = $itemDetail;
            }
            return $response;
        } else {
            throw new RestException(401, 'No Authorize or Invalid request !!!');
        }
    }
Beispiel #13
0
 /**
  * @url GET allitemgroup
  */
 protected function getAllItemGroup()
 {
     $statement = 'SELECT * FROM item_group';
     $response = \Db::getResult($statement);
     return $response;
 }
Beispiel #14
0
<?php

/**
 * Created by JetBrains PhpStorm.
 * User: jwfoxjr
 * Date: 8/28/11
 * Time: 12:29 AM
 * To change this template use File | Settings | File Templates.
 */
require_once 'Db.php';
/*** Setup our Connection */
//
Db::setConnectionInfo('fundsmaster', 'root', '#--5ql4dm1n--#', 'mysql', 'localhost');
$q = $_GET['q'];
/*** prepare the SQL statement ***/
$sql = 'SELECT house, street, apt, id FROM address WHERE street="' . $q . '" ORDER BY house,apt ASC';
$result = Db::getResult($sql);
echo '<select size="5">';
/*** loop of the results ***/
foreach ($result as $key => $house) {
    echo '<option name="' . $house['id'] . '" value="' . $house['id'] . '">' . $house['house'] . ' ' . $house['street'] . ' ' . $house['apt'] . '</option>';
}
Beispiel #15
0
 /**
  * @url GET
  * @url GET allpackage
  */
 protected function getAllPackage()
 {
     $statement = 'SELECT * FROM coin WHERE status = :status ORDER BY amount';
     $bind = array('status' => 'active');
     return \Db::getResult($statement, $bind);
 }
Beispiel #16
0
<link href="<?php 
echo $config['baseurl'];
?>
/assets/css/card.css" type="text/css" rel="stylesheet" />
<?php 
$projectId = intval($_GET['id']);
$statusNames = getStatusNames();
$cardTypes = getCardTypes();
$project = getProject($projectId);
if ($project) {
    $cards = Db::getResult('SELECT * FROM cards WHERE project_id = ?', $projectId);
    ?>
<div id="page-header">
    <h2><?php 
    echo $project['name'];
    ?>
 </h2>
    <div class="add-form-holder">
        <a id="create-card" href="#create-card"  class="ui-link ui-state-default ui-corner-all">
            <span class="ui-icon ui-icon-plusthick"></span>Add New Card
        </a>
        <form id="card-form" name="card-form" onsubmit="return createCard()" class="invisible">
            <label>Card Title</label>
            <input type="text" name="title" id="title" size="70"/>
            <label>type</label>
            <select name="card_type" id="card_type">
                <?php 
    foreach ($cardTypes as $cardType) {
        ?>
                <option value="<?php 
        echo $cardType['id'];
Beispiel #17
0
 /**
  * @smart-auto-routing false
  * @url getallbank
  * @url GET
  */
 protected function getAllBank()
 {
     $statement = 'SELECT * FROM bank WHERE status = :status';
     $bind = array('status' => 'active');
     return \Db::getResult($statement, $bind);
 }
Beispiel #18
0
 /**  
  * @url GET allAvatar
  */
 function getAllAvatar()
 {
     $statement = 'SELECT * FROM avatar';
     return \Db::getResult($statement);
 }
Beispiel #19
0
function getCardTypes()
{
    return Db::getResult('SELECT * FROM card_types');
}
Beispiel #20
0
 /**
  * @url GET /
  */
 protected function getConvertItem()
 {
     if (\TTO::getRole() == 'admin') {
         $response = new \stdClass();
         $statement = 'SELECT itemId, code, content, itemTypeId FROM item';
         //$bind = array('itemTypeId' => $itemTypeId);
         $allItem = \Db::getResult($statement);
         foreach ($allItem as &$item) {
             $newItem = new \stdClass();
             switch ($item['itemTypeId']) {
                 case 1:
                     $newItem->question = $item['content'];
                     $statement = 'SELECT content, isAnswer, point FROM item_radio WHERE itemId = :itemId';
                     $bind = array('itemId' => $item['itemId']);
                     $newItem->allRadio = \Db::getResult($statement, $bind);
                     foreach ($newItem->allRadio as &$radio) {
                         if ($radio['isAnswer']) {
                             $radio['isAnswer'] = true;
                         } else {
                             $radio['isAnswer'] = false;
                         }
                     }
                     break;
                 case 3:
                     $newItem->question = $item['content'];
                     $statement = 'SELECT content, isAnswer, point FROM item_select WHERE itemId = :itemId';
                     $bind = array('itemId' => $item['itemId']);
                     $newItem->allSelect = \Db::getResult($statement, $bind);
                     foreach ($newItem->allSelect as &$select) {
                         if ($select['isAnswer']) {
                             $select['isAnswer'] = true;
                         } else {
                             $select['isAnswer'] = false;
                         }
                     }
                     break;
                 case 4:
                     $newItem->question = $item['content'];
                     $statement = 'SELECT question, answer, answerType, point FROM item_input WHERE itemId = :itemId';
                     $bind = array('itemId' => $item['itemId']);
                     $newItem->allInput = \Db::getResult($statement, $bind);
                     break;
                 default:
                     break;
             }
             if ($item['itemTypeId'] == 1 || $item['itemTypeId'] == 3 || $item['itemTypeId'] == 4) {
                 $content2 = json_encode($newItem, JSON_UNESCAPED_UNICODE);
             } else {
                 $content2 = $item['content'];
             }
             $statement = '
       UPDATE item
       SET content2 = :content2
       WHERE itemId = :itemId
     ';
             $bind = array('itemId' => $item['itemId'], 'content2' => $content2);
             \Db::execute($statement, $bind);
             $item['content2'] = $content2;
         }
         return $allItem;
     } else {
         throw new RestException(401, 'No Authorize or Invalid request !!!');
     }
 }