public function actionMilestonesPending() { $Milestones = Milestones::model()->MilestoneWithPendingTasks(); foreach ($Milestones as $milestone) { $Tasks = Tasks::model()->findTaskByMilestone($milestone->milestone_id); $str = CBaseController::renderInternal(Yii::app()->params['templatesPath'] . '/milestones/overdueMilestones.php', array('user' => $milestone->Users->completeName, 'tasks' => $Tasks, 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://localhost/celestic/" . Yii::app()->request->baseUrl), true); $subject = Yii::t('email', 'overdueMilestone'); Yii::import('application.extensions.phpMailer.yiiPhpMailer'); $mailer = new yiiPhpMailer(); $mailer->pushMail($subject, $str, array('name' => $milestone->Users->CompleteName, 'email' => $milestone->Users->user_email), Emails::PRIORITY_NORMAL); } }
function actionUpdateScheduleTask() { if (isset($_POST['task_id'])) { $task_id = $_POST['task_id']; $task_start = $_POST['task_start']; $task_end = $_POST['task_end']; $model = Tasks::model()->updateSheduleTask($task_id, $task_start, $task_end); if ($model) { echo '{"status":"success"}'; } else { echo '{"status":"fail"}'; } } else { echo '{"status":"fail"}'; } }
/** * * Показывает для редактирования и сохраняет задание * * @param id * @return true * **/ public function actionEdit_task($id) { if (!Yii::app()->my->access("edit")) { return false; } $task = Tasks::model()->findByPk($id); if (isset($_REQUEST['Tasks'])) { foreach ($_REQUEST['Tasks'] as $key => $value) { $task->{$key} = $value; } if ($task->save()) { Yii::app()->notify->add("Задание сохранено. <a href='/task/" . $task->id . "' target='blank'>Перейти к заданию</a>"); } else { Yii::app()->notify->add("Не удалось сохранить", "danger"); print_r($task->getErrors()); } } $this->render("task", array("task" => $task)); }
public function fetchTaskByComplete($condition, $complete = 0, $pagesize = null) { if (!empty($condition)) { $condition .= " AND `allcomplete`=" . $complete; } else { $condition = "`allcomplete`=" . $complete; } if ($complete == 0) { $tasks = Tasks::model()->fetchAll(array("condition" => $condition, "order" => "sort ASC")); $data["todolist"] = CJSON::encode($tasks); } elseif ($complete == 1) { $tasks = $this->fetchAllAndPage($condition, $pagesize); foreach ($tasks["datas"] as $v) { $subTasks = $this->fetchAll("pid=:pid", array(":pid" => $v["id"])); $tasks["datas"] = array_merge($tasks["datas"], $subTasks); } $data = array("pages" => $tasks["pages"], "todolist" => CJSON::encode($tasks["datas"])); } return $data; }
public function getProjectDataEffort() { $criteria = new CDbCriteria(); $criteria->select = "COUNT(DISTINCT t.task_id) as total, Status.status_id"; $criteria->condition = "Projects.project_id = :project_id"; $criteria->params = array(':project_id' => Yii::app()->user->getState('project_selected')); $criteria->group = "Stage.taskStage_id"; $countStages = Tasks::model()->with('Projects', 'Stage')->together()->findAll($criteria); $totalTareas = 0; foreach ($countStages as $key) { $totalTareas += intval($key->total); } foreach ($countStages as $key) { $this->seriesStages[] = array($key->Stage->taskStage_name, round(intval($key->total) / $totalTareas * 100)); } /*echo "<pre>"; print_r($this->seriesStages); die("</pre>");*/ //return $this->seriesStages; }
/** * * @return int Иденификтор следующего задания * **/ public function getNext() { static $next = null; if (isset($next)) { return $next; } // $course = $this->course; $tasks = Tasks::model()->findAllByAttributes(array("track" => $course), array("order" => "t.order ASC")); if (count($tasks) == 0) { return 0; } $last = count($tasks) - 1; if ($tasks[$last]->id == $this->id) { $next = 0; return 0; } foreach ($tasks as $i => $task) { if ($task->id == $this->id) { $next = $tasks[$i + 1]->id; return $next; } } }
public function getActivity() { return Tasks::model()->findActivity(Yii::app()->user->id); }
<?php /* @var $this ProcessChecklistController */ /* @var $model ProcessChecklist */ ?> <!-- ================== TỔNG HỢP CÁC OPEN TASK ĐƯỢC GÁN VÀO NHÂN VIÊN ============== --> <?php $generalAP = Tasks::model()->generalAccountProject($account_id); $this->widget('bootstrap.widgets.TbGridView', array('id' => 'account-resource-report-grid', 'dataProvider' => $model, 'template' => "{items}", 'columns' => array(array('name' => 'project_name', 'type' => 'raw', 'value' => '$data->projects->project_name'), array('name' => 'End', 'type' => 'raw', 'value' => 'Tasks::model()->getStartTaskProject($data->project_id,$data->account_id, 0);', 'footer' => "<b>" . $generalAP['start'] . "</b>"), array('name' => 'Start', 'type' => 'raw', 'value' => 'Tasks::model()->getEndTaskProject($data->project_id,$data->account_id, 0);', 'footer' => "<b>" . $generalAP['end'] . "</b>"), array('name' => 'Total', 'type' => 'raw', 'value' => 'Tasks::model()->calculateTaskOneProject($data->project_id,$data->account_id, 0);', 'footer' => "<b>" . $generalAP['total_task'] . "<b>")))); ?> <!-------------------- END TỔNG HỢP CÁC OPEN TASK ĐƯỢC GÁN VÀO NHÂN VIÊN ---------------- --> <!-- ================== TỔNG HỢP KẾ HOACH CỦA NHÂN VIÊN CHO PROJECT ============== --> <?php $this->widget('bootstrap.widgets.TbGridView', array('id' => 'account-resource-report-grid', 'dataProvider' => $model, 'template' => "{items}", 'columns' => array(array('name' => 'project_name', 'type' => 'raw', 'value' => '$data->projects->project_name'), array('name' => 'Planned', 'type' => 'raw', 'value' => 'TaskResourcePlan::model()->calculatePlannedTask($data->project_id,$data->account_id);'), array('name' => 'Unplanned', 'type' => 'raw', 'value' => 'TaskResourcePlan::model()->calculateUnplannedTask($data->project_id,$data->account_id);')))); ?> <!-------------------- END TỔNG HỢP KẾ HOACH CỦA NHÂN VIÊN CHO PROJECT ---------------- -->
public function beforeAction($action) { switch ($action->id) { case "view": $response = Tasks::model()->countTasksByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false; break; case "update": $response = Tasks::model()->countTasksByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false; break; case "delete": $response = Tasks::model()->countTasksByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false; break; default: $response = true; break; } if (!$response) { throw new CHttpException(403, Yii::t('site', '403_Error')); } else { return $response; } }
/** * Get item numbers for each task status * By default project_id is selected * @return model list of task status counter */ public function getTaskCounter() { return Tasks::model()->TaskCounter(Yii::app()->user->id, Yii::app()->user->getState('project_selected')); }
public function actionTheory($id) { $track = Tracks::model()->with("Tasks")->findByPk($id); $tasks = Tasks::model()->findAllByAttributes(array("track" => $id), array("order" => "t.order")); $this->render('theory', array('track' => $track, 'tasks' => $tasks)); }
<?php $task = Tasks::model()->findByPk($task_id); $task_assignee = $task_assignee_arr = TaskAssignees::model()->findAll('task_id=' . intval($task_id)); $count_task_assignee = count($task_assignee); ?> <h3>Task Progress</h3> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" onclick="AddTaskProcess();return false;">Task Detail</button> <!-- Modal --> <div class="modal fade" id="myModal" style="z-index: 0;"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Task Details</h4> <input type="hidden" id="toal_assign_task" value="<?php echo $count_task_assignee; ?> " /> </div> <div class="modal-body" style="max-height: 500px;"> <!-- ==================== SCHEDULE ================================ --> <div id="tp-schedule" > <h4>Schedule</h4> Start: <?php echo CHtml::textField('tp-shedule-start', date('d-m-Y', strtotime($task->task_start_date)), array('class' => 'span2')); ?>
/** * % thời gian đã trãi qua của task * @param type $task_id * @return type */ public function calculateLapsed($task_id) { $lapsed = 0; $task = Tasks::model()->findByPk($task_id); $date_current = date('Y-m-d'); $date_start = $task->task_start_date; $date_end = $task->task_end_date; if ($date_end < $date_start || $date_start > $date_current) { $lapsed = 0; } elseif ($date_end == $date_start) { $lapsed = 100; } else { //Sô ngày đã làm. $actual = (strtotime($date_current) - strtotime($date_start)) / (60 * 60 * 24); //Số ngày dự kiến $est = (strtotime($date_end) - strtotime($date_start)) / (60 * 60 * 24); // % thoi gian da trai qua cua task $lapsed = $actual / $est; if ($lapsed > 1) { $lapsed = 100; } elseif ($lapsed < 0) { $lapsed = 0; } else { $lapsed = $lapsed * 100; } } return round($lapsed, 1); }
/** * Get all task waiting to solve * By default user_id and project_id * @return model list of task to solve */ public function getActivity() { return Tasks::model()->findActivity(Yii::app()->user->id, Yii::app()->user->getState('project_selected'), 10); }
/** * Tính tổng số task trong 1 dự án được gán cho nhân viên và chưa được lên kế hoạch * @param type $project_id * @param type $accout_id */ public function calculateUnplannedTask($project_id, $account_id) { $total_task = Tasks::model()->calculateTaskOneProject($project_id, $account_id); $total_plan = $this->calculatePlannedTask($project_id, $account_id); $total_unplan = $total_task - $total_plan; return $total_unplan; }
public function getProjectProgress($project_id) { // ( total_tasks_per_status / total_tasks ) / status_value $criteria = new CDbCriteria(); $criteria->select = '(ROUND((COUNT(t.task_id)/(SELECT COUNT(*) FROM tb_tasks tb WHERE tb.project_id = :project_id))*Status.status_value)) AS progress'; $criteria->condition = 't.project_id = :project_id AND 200=200'; $criteria->params = array(':project_id' => $project_id); $criteria->group = 't.status_id'; $criteria->order = 't.task_startDate ASC'; return Tasks::model()->with('Status')->together()->find($criteria); }
public function verifyTasksInProject($project_id, $task_id) { $count = Tasks::model()->count(array('condition' => 't.project_id = :project_id AND t.task_id = :task_id', 'params' => array(':project_id' => $project_id, ':task_id' => $task_id))); if ($count > 0) { return true; } return false; }
private function search() { $uid = $this->uid; $complete = $this->complete; $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } if ($type == "normal_search") { $keyword = EnvUtil::getRequest("keyword"); MainUtil::setCookie("keyword", $keyword, 10 * 60); $pTasks = Tasks::model()->fetchPTasks($uid, $complete, $keyword); $cTasks = Tasks::model()->fetchCTasks($uid, $complete, $keyword); $array = array(); foreach ($pTasks as $task) { $array[] = $task["id"]; } foreach ($cTasks as $task) { $array[] = $task["pid"]; } $pids = array_unique($array); $pidTemp = ""; foreach ($pids as $v) { $pidTemp .= "\"" . $v . "\","; } $pidStr = rtrim($pidTemp, ","); if (!empty($pidStr)) { $this->_condition = " uid='{$uid}' AND id IN({$pidStr}) AND allcomplete='{$complete}'"; } else { $this->_condition = " uid='{$uid}' AND id IN('') AND allcomplete='{$complete}'"; } } else { $this->_condition = $conditionCookie; } if ($this->_condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } }
public function actionRemove($id) { if (!Yii::app()->my->access("edit")) { return false; } if ($task = Tasks::model()->findByPk($id)) { if ($task->delete()) { Yii::app()->notify->add("Задание удалено"); } $this->render('/site'); } else { Yii::app()->notify->add("Задание не существует"); } }
public function updateSheduleTask($task_id, $task_start, $task_end) { $task = Tasks::model()->findByPk($task_id); $task->task_start_date = date('Y-m-d', strtotime($task_start)); $task->task_end_date = date('Y-m-d', strtotime($task_end)); if ($task->save()) { return true; } return false; }
/** * Creates a new model. */ public function actionCreate() { // create Comments Object $model = new Comments(); // if Comments form exist if (isset($_POST['Comments'])) { // set form elements to Comments model attributes $model->attributes = $_POST['Comments']; $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id))); // set module_id finded to model $model->module_id = $module->module_id; $project = Yii::app()->user->getState('project_selected'); $model->project_id = $project; // validate and save if ($model->save()) { // create an instance of file uploaded $image = CUploadedFile::getInstancesByName('Comment'); // if file upload exist if (count($image > 0)) { // for each file uploaded for ($i = 0; $i < count($image); $i++) { // create an Document object $modeldocs = new Documents(); $modeldocs->image = $image[$i]; if (!$modeldocs->image->getError()) { // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime()) $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime()); // set the extension file uploaded $extension = $modeldocs->image->getExtensionName(); // if no error saving file if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) { $modeldocs->project_id = $project; $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30); $modeldocs->document_description = $model->comment_text; $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension; $modeldocs->document_revision = '1'; $modeldocs->document_uploadDate = date("Y-m-d"); $modeldocs->document_type = $modeldocs->image->getType(); $modeldocs->document_baseRevision = date('dmYHis'); $modeldocs->user_id = Yii::app()->user->id; $modeldocs->comment_id = $model->primaryKey; // save file uploaded as document if ($modeldocs->save()) { Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk')); } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors()); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError')); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors')); } } } // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project); Logs::model()->saveLog($attributes); // find project managers to sent comment via mail $recipientsList = array(); $ProjectManagers = Projects::model()->findManagersByProject($project); $managersArray = array(); foreach ($ProjectManagers as $manager) { $managersArray['email'] = $manager->user_email; $managersArray['name'] = $manager->CompleteName; array_push($recipientsList, $managersArray); } // find task owners to send comment via mail if ($module->module_name == 'tasks') { $collaborators = Projects::model()->findAllUsersByProject($project); $ColaboratorsArray = array(); foreach ($collaborators as $colaborator) { $ColaboratorsArray['email'] = $colaborator->user_email; $ColaboratorsArray['name'] = $colaborator->CompleteName; // avoid to repeat email address if (!in_array($ColaboratorsArray, $recipientsList)) { array_push($recipientsList, $ColaboratorsArray); } } } // finding resource title switch ($module->module_name) { case "budgets": $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title; break; case "invoices": $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number; break; case "expenses": $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name; break; case "documents": $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name; break; case "milestones": $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title; break; case "cases": $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name; break; case "tasks": $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name; break; default: $resourceModelTitle = "{empty}"; break; } // get project information $project = Projects::model()->findByPk($project); // prepare template to send via email $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true); Yii::import('application.extensions.phpMailer.yiiPhpMailer'); $mailer = new yiiPhpMailer(); $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name); $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL); } else { Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment')); } } $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey))); }
/** * Displays a particular model. * @return string with success message */ public function actionView($id) { // check if user has permission to viewMilestones if (Yii::app()->user->checkAccess('viewMilestones')) { // get Invoice object model $model = $this->loadModel($id); // Tasks dataprovider $dataProviderTasks = Tasks::model()->findAll(array('condition' => 't.milestone_id = :milestone_id', 'params' => array(':milestone_id' => $model->milestone_id), 'order' => 't.status_id ASC, t.task_priority DESC')); // finding by status $criteria = new CDbCriteria(); $criteria->select = "count(t.status_id) as total"; $criteria->condition = "t.milestone_id = :milestone_id"; $criteria->params = array(':milestone_id' => $id); $criteria->group = "t.status_id"; $foundTasksStatus = Tasks::model()->with('Status')->together()->findAll($criteria); $TasksStatus = array(); foreach ($foundTasksStatus as $task) { $TasksStatus[] = array('name' => $task->Status->status_name, 'data' => intval($task->total)); } // finding by priority $criteria = new CDbCriteria(); $criteria->select = "t.task_priority, count(t.task_priority) as total"; $criteria->condition = "t.milestone_id = :milestone_id"; $criteria->params = array(':milestone_id' => $id); $criteria->group = "t.task_priority"; $foundTasksPriority = Tasks::model()->findAll($criteria); $TasksPriority = array(); foreach ($foundTasksPriority as $task) { $TasksPriority[] = array(Tasks::getNameOfTaskPriority($task->task_priority), intval($task->total)); } // output view $this->render('view', array('model' => $model, 'percent' => Milestones::model()->getMilestonePercent($model->milestone_id), 'dataProviderTasks' => $dataProviderTasks, 'TasksStatus' => $TasksStatus, 'TasksPriority' => $TasksPriority)); } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } }