示例#1
0
function print_task($tasks)
{
    $id = 1;
    foreach ($tasks as $task) {
        $childcount = Task::model()->count(array('condition' => 'parent_id=' . $task->id . ' AND deleted=0'));
        $assignment = TaskAssignment::model()->find(array('condition' => 'task_id=' . $task->id . ' AND deleted=0'));
        if ($childcount > 0) {
            $childtasks = Task::model()->findAll(array('condition' => 'parent_id=' . $task->id . ' AND deleted=0'));
            echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '", "' . $task->title . '", "' . date('m/d/Y', strtotime($task->start_date)) . '", "' . date('m/d/Y', strtotime($task->due_date)) . '", "659af7", "#", 0, "' . (isset($assignment) ? $assignment->member->username : '') . '", 0, 1, ' . ($task->has_parent ? $task->parent_id : 0) . ', 0));';
            print_task($childtasks);
        } else {
            echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '", "' . $task->title . '", "' . date('m/d/Y', strtotime($task->start_date)) . '", "' . date('m/d/Y', strtotime($task->due_date)) . '", "659af7", "#", 0, "' . (isset($assignment) ? $assignment->member->username : '') . '", 0, 0, ' . ($task->has_parent ? $task->parent_id : 0) . ', 0));';
            // set criteria for tasklog
            $criteria = new CDbCriteria();
            $criteria->with = array('taskAssignment.task');
            $criteria->order = 'date ASC';
            $criteria->condition = 'type="Project" AND task.id=' . $task->id . ' AND t.deleted=0 and task.deleted=0';
            $criteria2 = new CDbCriteria();
            $criteria2->with = array('taskAssignment.task');
            $criteria2->condition = 'type="Non-project" AND t.member_id=' . $assignment->member_id . ' AND t.deleted=0 AND t.date BETWEEN "' . $task->start_date . '" AND "' . $task->due_date . '"';
            $criteria3 = new CDbCriteria();
            $criteria3->with = array('taskAssignment.task');
            $criteria3->condition = 'type="Project" AND t.member_id=' . $assignment->member_id . ' AND t.deleted=0 AND t.date BETWEEN "' . $task->start_date . '" AND "' . $task->due_date . '"';
            // Merge criteria
            $criteria->mergeWith($criteria2, 'OR');
            $criteria->mergeWith($criteria3, 'OR');
            // Get tasklog based on criteria
            $tasklog = TaskLog::model()->findAll($criteria);
            if ($tasklog) {
                echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '.1", "' . $task->title . ' - REAL", "", "", "fe7e7e", "#", 0, "-", 0, 1, ' . ($task->has_parent ? $task->parent_id : 0) . ', 0));';
                foreach ($tasklog as $item) {
                    if ($item->type == "Non-project") {
                        echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '.' . $item->id . '", "' . $item->date . ' - ' . $item->task_title . ' (Non-project)", "' . date('m/d/Y', strtotime($item->date)) . '", "' . date('m/d/Y', strtotime($item->date)) . '", "737070", "#", 0, "' . $item->member->username . '", 0, 0, "' . $task->id . '.1", "' . $task->title . '-REAL", 0));';
                    } else {
                        if ($item->type == "Project" && $item->taskAssignment->task->id != $task->id) {
                            echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '.' . $item->id . '", "' . $item->date . ' - ' . $item->taskAssignment->task->title . ' (Different project)", "' . date('m/d/Y', strtotime($item->date)) . '", "' . date('m/d/Y', strtotime($item->date)) . '", "737070", "#", 0, "' . $item->member->username . '", 0, 0, "' . $task->id . '.1", "' . $task->title . '-REAL", 0));';
                        } else {
                            echo 'g.AddTaskItem(new JSGantt.TaskItem("' . $task->id . '.' . $item->id . '", "' . $item->date . '", "' . date('m/d/Y', strtotime($item->date)) . '", "' . date('m/d/Y', strtotime($item->date)) . '", "fe7e7e", "#", 0, "' . $item->member->username . '", 0, 0, "' . $task->id . '.1", "' . $task->title . '-REAL", 0));';
                        }
                    }
                }
            }
        }
    }
}
示例#2
0
<?php

/* @var $this SiteController */
$this->widget('booster.widgets.TbBreadcrumbs', array('links' => array('Dashboard')));
// Retrieve user project info
$my_upcomingprojects = Project::model()->count(array('condition' => 'status="Upcoming" AND deleted=0 AND creator_id=' . Yii::app()->user->id));
$my_activeprojects = Project::model()->count(array('condition' => 'status="Active" AND deleted=0 AND creator_id=' . Yii::app()->user->id));
$my_completedprojects = Project::model()->count(array('condition' => 'status="Complete" AND deleted=0 AND creator_id=' . Yii::app()->user->id));
$my_expiredprojects = Project::model()->count(array('condition' => 'status="Expired" AND deleted=0 AND creator_id=' . Yii::app()->user->id));
// Retrieve all projects info
$all_upcomingprojects = Project::model()->count(array('condition' => 'status="Upcoming" AND deleted=0'));
$all_activeprojects = Project::model()->count(array('condition' => 'status="Active" AND deleted=0'));
$all_completedprojects = Project::model()->count(array('condition' => 'status="Complete" AND deleted=0'));
$all_expiredprojects = Project::model()->count(array('condition' => 'status="Expired" AND deleted=0'));
// Retrieve last activity
$recentlogs = TaskLog::model()->findAll(array('order' => 'timestamp DESC', 'limit' => 3, 'condition' => 'deleted=0 AND type="Project"'));
$recentprojects = Project::model()->findAll(array('order' => 'timestamp DESC', 'limit' => 3, 'condition' => 'deleted=0'));
$recentassignments = TaskAssignment::model()->findAll(array('order' => 'timestamp DESC', 'limit' => 3, 'condition' => 'deleted=0'));
//$recentcompletions = SubtaskCompletion::model()->findAll(array('order'=>'timestamp DESC', 'limit'=>3, 'condition'=>'deleted=0'));
?>

<!-- HEADER -->
<h2 class="page-header">Dashboard</h2>

<!-- PROJECTS PANEL -->
<div class="span-6">
    <!-- MY PROJECTS -->
    <div class="panel panel-primary">
        <!-- heading -->
        <div class="panel-heading">
            <span class="glyphicon glyphicon-folder-open"></span>
示例#3
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 $id the ID of the model to be loaded
  * @return TaskLog the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TaskLog::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }