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));'; } } } } } } }
while ($task->has_parent) { $task = Task::model()->findByPk($task->parent_id); $links = array_merge(array($task->title => array('task/view', 'id' => $task->id)), $links); } $links = array_merge(array($model->project->name => array('project/view', 'id' => $model->project_id)), $links); $links = array_merge(array('Projects' => array('project/index')), $links); // Displaying breadcrumbs $this->widget('booster.widgets.TbBreadcrumbs', array('links' => $links)); $this->menu = array(array('label' => 'See my projects', 'url' => array('project/myProjects')), array('label' => 'See all projects', 'url' => array('project/index')), array('label' => 'Add task', 'url' => array('task/create', 'id' => $model->project_id)), array('label' => 'Update task', 'url' => array('task/update', 'id' => $model->id))); ?> <h2 class="page-header">Task Detail : <?php echo $model->title; ?> </h2> <?php $this->widget('booster.widgets.TbDetailView', array('id' => 'task-detail', 'data' => $model, 'attributes' => array('project.name', array('label' => 'Parent Task', 'value' => $model->has_parent == 0 ? '-' : $model->parent->title), array('label' => 'Creator', 'value' => $model->creator->username), array('label' => 'Assigned to', 'value' => TaskAssignment::model()->find(array('condition' => 'task_id=' . $model->id . ' AND deleted=0')) ? TaskAssignment::model()->find(array('condition' => 'task_id=' . $model->id . ' AND deleted=0'))->member->username : '******'), array('label' => 'Start date', 'value' => date('d-m-Y', strtotime($model->start_date))), array('label' => 'Due date', 'value' => date('d-m-Y', strtotime($model->due_date))), array('label' => 'Status', 'value' => $model->status)))); ?> <!-- Display current status --> <!--<h4> <b>Current Status :</b> <?php /*$model->status=="New" ? $this->widget('booster.widgets.TbLabel', array('context' => 'default','label' => 'NEW')) : ($model->status=="On progress" ? $this->widget('booster.widgets.TbLabel', array('context' => 'primary','label' => 'ON PROGRESS')) : $this->widget('booster.widgets.TbLabel', array('context' => 'success','label' => 'COMPLETE')))*/ ?> </h4>--> <div class="span-24"><hr> <!-- List of subtask(s) --> <i class="glyphicon glyphicon-th-list"></i><b> List of Subtask(s) : <div class="right"><?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> <span><strong> My projects</strong></span> </div>
/** * 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) { if (!Yii::app()->user->checkAccess('Manager') && !Yii::app()->user->checkAccess('Admin')) { throw new CHttpException(403, 'You are not authorized to perform this action.'); } // Check whether this user is the owner of the projects $ownerid = Task::model()->findByPk($id)->project->creator_id; if ($this->loadModel($id)->deleted == 1) { throw new CHttpException(403, 'The page you are requested are invalid'); } if (Yii::app()->user->id != $ownerid) { throw new CHttpException(403, 'You are not authorized to perform this action.'); } $model = $this->loadModel($id); $model->scenario = 'update'; // Load the parent task_assignment (if exist) $assignment = TaskAssignment::model()->find(array('condition' => 'task_id=' . $model->id . ' AND deleted=0')); if (!$assignment) { $assignment = new TaskAssignment(); } if (isset($_POST['Task']) && isset($_POST['TaskAssignment'])) { $model->attributes = $_POST['Task']; // Synchronize due date with project $project = Project::model()->findByPk($model->project_id); if ($project->due_date < $model->due_date) { $project->due_date = $model->due_date; $project->save(); } // Synchronize due date with parent task $parent = Task::model()->findByPk($id); while ($parent->has_parent) { if ($parent->due_date < $model->due_date) { $parent->due_date = $model->due_date; $parent->save(); } $parent = Task::model()->findByPk($parent->parent_id); } if ($parent->due_date < $model->due_date) { $parent->due_date = $model->due_date; $parent->save(); } if ($model->save()) { if ($_POST['TaskAssignment']['member_id'] != null) { $assignment->task_id = $model->id; $assignment->member_id = $_POST['TaskAssignment']['member_id']; $assignment->save(); $this->redirect(array('view', 'id' => $model->id)); } else { $assignment->task_id = $model->id; $assignment->deleted = 1; $assignment->save(); $this->redirect(array('view', 'id' => $model->id)); } } } $this->render('update', array('model' => $model, 'assignment' => $assignment)); }
public function actionCalendarEventsStaff() { $items = array(); $model = TaskAssignment::model()->findAll(array('condition' => 'member_id=' . Yii::app()->user->id . ' AND deleted=0')); foreach ($model as $value) { //echo $value->task->title; $items[] = array('title' => $value->task->title, 'start' => $value->task->start_date, 'end' => date('Y-m-d', strtotime('+1 day', strtotime($value->task->due_date))), 'color' => $value->task->status == "Not complete" ? '#fe6e6e' : 'default', 'idevent' => $value->task->id); } echo CJSON::encode($items); Yii::app()->end(); }
<?php /* @var $this TaskLogController */ /* @var $model TaskLog */ /* @var $form CActiveForm */ $task_list = CHtml::listData(TaskAssignment::model()->with('task')->findAll(array('condition' => 'task.deleted=0 AND task.status != "Complete" AND t.deleted=0')), 'id', 'task.concatened'); ?> <div class="form"> <script> $(document).ready(function(){ if(document.getElementById('type').value === "Non-project") { $("#task_assignment_id").val(null); $("#task_assignment_id").prop('disabled', true); $("#task_title").prop('disabled', false); } else if(document.getElementById('type').value === "Project") { $("#task_title").val(null); $("#task_assignment_id").prop('disabled', false); $("#task_title").prop('disabled', true); } $("#type").change(function(){ if(this.value === "Non-project") { $("#task_assignment_id").val(null); $("#task_assignment_id").prop('disabled', true); $("#task_title").prop('disabled', false); } else if(this.value === "Project") { $("#task_title").val(null); $("#task_assignment_id").prop('disabled', false);