Inheritance: extends LaravelBook\Ardent\Ardent
function buildGoals($xml = "", $last = 0, $value = "")
{
    global $RESPONSE;
    $RESPONSE->Goals = "";
    if (STATS_ACTIVE) {
        if ($result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_GOALS . "` ORDER BY `ind` ASC")) {
            while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
                $goal = new Goal($row);
                $RESPONSE->Goals .= $goal->GetXML();
            }
        }
    }
}
Example #2
0
 public function checkOverlap($task = null)
 {
     if ($task == null && $this->task == null) {
         throw new Task_Not_Found();
     }
     if ($task == null) {
         $task = $this->task;
     }
     $goal = new Goal();
     $goal->where(array("start <=" => $this->start, "end >=" => $this->end))->get_by_related($task);
     if ($goal->exists()) {
         throw new Goal_Overlap();
     }
 }
Example #3
0
 /**
  * @param int $from
  * @param int $to
  * @throws Task_Not_Found
  */
 private function showGoals($from, $to)
 {
     $this->load->library("session");
     $goals = new Goal();
     $goals->where("user_id", $this->session->getStudentId());
     $goals->where("start >=", $from);
     $goals->where("end <=", $to);
     $goals->get();
     $goalsView = array();
     /** @var Goal $goal */
     foreach ($goals as $goal) {
         $goalsView[] = array("id" => $goal->getId(), "value" => $goal->getValue(), "done" => $goal->getDoneTime(), "task_name" => $goal->task->getName());
     }
     $this->load->view("goal/get", array("goals" => $goalsView));
 }
function buildGoals()
{
    global $RESPONSE, $INTERNAL;
    $RESPONSE->Goals = "";
    if ($INTERNAL[CALLER_SYSTEM_ID]->GetPermission(PERMISSION_REPORTS) == PERMISSION_NONE) {
        return;
    }
    if (STATS_ACTIVE) {
        if ($result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_GOALS . "` ORDER BY `ind` ASC")) {
            while ($row = DBManager::FetchArray($result)) {
                $goal = new Goal($row);
                $RESPONSE->Goals .= $goal->GetXML();
            }
        }
    }
}
Example #5
0
 public function action_delete()
 {
     RoutingEngine::setPage("runnDAILY", "PV__300");
     if (!isset($_POST["go_id"])) {
         Page::redirect("/goals");
     }
     Goal::deleteGoal($_POST["go_id"]);
     Page::redirect("/goals");
 }
Example #6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Project  $project
  * @return Response
  */
 public function edit($project)
 {
     $goals = Goal::where('project_id', '=', $project->id)->get();
     $tags_all = Tag::orderby('tag')->lists('tag', 'id');
     $tags = $project->tags()->lists('tag_id');
     $users = $project->users;
     $creator = User::find($project->user_id);
     /** format enum for expected time */
     switch ($project->expected_time) {
         case 'lessMonth':
             $project->expected_time = 1;
             break;
         case 'aMonth':
             $project->expected_time = 2;
             break;
         case 'fourMonths':
             $project->expected_time = 3;
             break;
         case 'eightMonths':
             $project->expected_time = 4;
             break;
         case 'ayear':
             $project->expected_time = 5;
             break;
         case 'moreYear':
             $project->expected_time = 6;
             break;
     }
     /** format enum for state */
     switch ($project->state) {
         case 'Application':
             $project->state = 1;
             break;
         case 'Available':
             $project->state = 2;
             break;
         case 'InProgress':
             $project->state = 3;
             break;
         case 'Complete':
             $project->state = 4;
             break;
         case 'Canceled':
             $project->state = 5;
             break;
         case 'NA':
             $project->state = 6;
             break;
     }
     return View::make('admin/projects/edit', compact('project', 'goals', 'tags_all', 'tags', 'users', 'creator'));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Activity'])) {
         $model->attributes = $_POST['Activity'];
         // Make sure the userid was not manipulated. We only allow users to update
         // their own goals.
         if ($model->userId != Yii::app()->user->id) {
             throw new CHttpException(404, 'You can only update your own activities.');
         }
         // Save the model.
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'goals' => Goal::model()->findAllByAttributes(array('userId' => $model->userId))));
 }
 public static function update_goal_by_id()
 {
     $userTitle = $_POST['title'];
     $userDescription = $_POST['description'];
     $userEmail = $_SESSION['Email'];
     $userStart = $_POST['startDate'];
     $userEnd = $_POST['endDate'];
     if (isset($_POST['completed'])) {
         $userCompleted = $_POST['completed'];
     }
     $Goal = new Goal($userTitle, $userDescription, $userEmail, $userStart, $userEnd);
     $Goal->goal_id = $_GET['goal_id'];
     if (isset($_POST['completed'])) {
         $Goal->completed = 1;
     } else {
         $Goal->completed = 0;
     }
     Goal::update_goal($Goal);
     header("Location: /public_html/goal?goal_id={$Goal->goal_id}&message=goal_updated");
 }
Example #9
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // Render 'index' view for guest users.
     if (Yii::app()->user->isGuest) {
         $this->render('index');
     } else {
         // Find an active goal for the current user.
         // @todo Currently assuming there is only one which the model logic does not enforce!
         // @todo I don't like the cleanup implementation!
         $models = Goal::model()->findAllByAttributes(array('active' => 1, 'userId' => Yii::app()->user->id));
         foreach ($models as $model) {
             $model->cleanUp();
         }
         $model = Goal::model()->findByAttributes(array('active' => 1, 'userId' => Yii::app()->user->id));
         // Redirect to current goal if exist.
         if ($model) {
             $this->redirect(array('goal/report', 'id' => $model->id));
         } else {
             $this->redirect(array('goal/workflow'));
         }
     }
 }
Example #10
0
<?php

$goal_id = $_GET['goal_id'];
$Goal = Goal::get_goal_by_id($goal_id);
if ($Goal->completed && $Goal->creator == $_SESSION['Email']) {
    $goal_classes = 'goal-complete';
} else {
    $goal_classes = 'goal-incomplete';
}
if (session_status() == PHP_SESSION_ACTIVE && $Goal->creator === $_SESSION['Email']) {
    include '../App/Views/partials/goal_edit.php';
} else {
    ?>
            <div class="container">
              <div class="row">
                <div class="col-md-6 col-md-offset-3">
                
                  <?php 
    include '../App/Views/goal_card.php';
    ?>
                  
                </div>
              </div>
            </div>
        <?php 
}
Example #11
0
    }
}
?>
          
              <?php 
$str = count($CompletedGoals) / $TotalGoals;
$percent = round($str * 100) . '%';
?>
        
            <p>Percentage of Total Goals Completed:</p><h3> <?php 
echo $percent;
?>
</h3>
        
            <?php 
$CurrentUserGoals = Goal::get_current_user_goals();
$TotalUserGoals = $CurrentUserGoals->rowCount();
$CompletedUserGoals = [];
while ($Goal = $CurrentUserGoals->fetchObject()) {
    if ($Goal->completed) {
        array_push($CompletedUserGoals, $Goal);
    }
}
if ($TotalUserGoals) {
    $strUser = count($CompletedUserGoals) / $TotalUserGoals;
    $percentUser = round($strUser * 100) . '%';
}
?>
            
        <?php 
if (!empty($percentUser)) {
Example #12
0
<div class="container">
	<div class="row">

		<?php 
include 'partials/add_goal_form.php';
?>
      
        <?php 
if (!isset($_SESSION)) {
    session_start();
}
if (isset($_SESSION['Email'])) {
    $sessionEmail = $_SESSION['Email'];
}
?>
		
		<div class="col-md-9">
          
			<?php 
$GoalIndex = new GoalIndex();
$Goals = Goal::get_current_user_goals();
$GoalIndex->print_goals($Goals);
?>
			
		</div>
	</div>
</div>
Example #13
0
 public function action_save()
 {
     RoutingEngine::setPage("runnDAILY Training Save", "PV__300");
     $t_item = new TrainingLog($_POST);
     if (array_safe($_POST, "t_rid") == "") {
         $t_item->rid = null;
     }
     if ($t_item->createItem()) {
         $affected_goals = Goal::getGoalIdsForUserInRange(User::$current_user->uid, $t_item->date);
         if ($affected_goals) {
             Goal::updatePercentForList($affected_goals);
         }
         Page::redirect("/training/");
     }
     Page::redirect("/training/");
 }
Example #14
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Goal::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #15
0
     // Edit file type form...:
     // Check permission:
     $current_User->check_perm('stats', 'edit', true);
     // Make sure we got an ftyp_ID:
     param('goal_ID', 'integer', true);
     break;
 case 'create':
     // Record new goal
 // Record new goal
 case 'create_new':
     // Record goal and create new
 // Record goal and create new
 case 'create_copy':
     // Record goal and create similar
     // Insert new file type...:
     $edited_Goal = new Goal();
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('goal');
     // Check permission:
     $current_User->check_perm('stats', 'edit', true);
     // load data from request
     if ($edited_Goal->load_from_Request()) {
         // We could load data from form without errors:
         // Insert in DB:
         $DB->begin();
         $q = $edited_Goal->dbexists();
         if ($q) {
             // We have a duplicate entry:
             param_error('goal_key', sprintf(T_('This goal already exists. Do you want to <a %s>edit the existing goal</a>?'), 'href="?ctrl=goals&amp;action=edit&amp;goal_ID=' . $q . '"'));
         } else {
             $edited_Goal->dbinsert();
 function test_create_goal_with_overlap()
 {
     try {
         $this->goal->create(+3600, time(), strtotime("+1 week"))->save($this->task);
         $goal = new Goal();
         $goal->create(+3600, time() + 1000, strtotime("+1 week") - 5000)->save($this->task);
         $this->_assert_false(1);
     } catch (Goal_Overlap $e) {
     }
 }
Example #17
0
<?php

include_once '../config.php';
include_once ROOT_PATH . '/App/Models/Database.class.php';
include_once ROOT_PATH . '/App/Models/Goal.class.php';
header('Content-Type: application/json');
Goal::echo_all_goals_json();
Example #18
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  Project  $project
  * @return Response
  */
 public function edit($project)
 {
     if (Auth::check() && Auth::user()->id == $project->user_id) {
         $goals = Goal::where('project_id', '=', $project->id)->get();
         $tags_all = Tag::orderby('tag')->lists('tag', 'id');
         $tags = $project->tags()->lists('tag_id');
         /** format enum for expected time */
         switch ($project->expected_time) {
             case 'lessMonth':
                 $project->expected_time = 1;
                 break;
             case 'aMonth':
                 $project->expected_time = 2;
                 break;
             case 'fourMonths':
                 $project->expected_time = 3;
                 break;
             case 'eightMonths':
                 $project->expected_time = 4;
                 break;
             case 'ayear':
                 $project->expected_time = 5;
                 break;
             case 'moreYear':
                 $project->expected_time = 6;
                 break;
         }
         return View::make('site/project/edit', compact('project', 'goals', 'tags_all', 'tags'));
     } else {
         return Redirect::to('/');
     }
 }
Example #19
0
 public static function updatePercentForList($goal_list)
 {
     foreach ($goal_list as $item) {
         $goal = Goal::getGoalById($item['go_id']);
         $goal->updatePercent();
     }
 }