Beispiel #1
0
 /**
  * 提交任务
  *
  * @param $projectId 没有projectId则显示列表
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     // 为了方便用户更改表名,避免表名直接定死
     $projectTable = Project::tableName();
     $groupTable = Group::tableName();
     if (!$projectId) {
         // 显示所有项目列表
         $projects = Project::find()->leftJoin(Group::tableName(), "`{$groupTable}`.`project_id` = `{$projectTable}`.`id`")->where(["`{$projectTable}`.status" => Project::STATUS_VALID, "`{$groupTable}`.`user_id`" => $this->uid])->asArray()->all();
         return $this->render('select-project', ['projects' => $projects]);
     }
     $task = new Task();
     $conf = Project::getConf($projectId);
     if (!$conf) {
         throw new \Exception(yii::t('task', 'unknown project'));
     }
     if (\Yii::$app->request->getIsPost()) {
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('@web/task/');
             }
         }
     }
     $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
     return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
 }
Beispiel #2
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $course_id = Yii::$app->request->get('course_id');
     $model = new Task();
     if ($model->load(Yii::$app->request->post())) {
         $model = $model->validateAttr($model);
         if (empty($model->errors)) {
             $resourceModel = new Resource();
             $model = $resourceModel->uploadImg($model, 'image');
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     $model->course_id = $course_id;
     if (!json_decode($model->answer_json)) {
         $model->answer_json = '';
     }
     $chapterName = $courseName = null;
     if (!empty($course_id)) {
         $chapterName = Course::findModel($course_id)->name;
         $courseName = Course::findRoot($course_id)->name;
     }
     return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]);
 }
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Task();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->getAjaxResponse();
     }
 }
Beispiel #4
0
 /**
  * 提交任务
  *
  * @param $projectId
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     $task = new Task();
     if ($projectId) {
         $conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
     }
     if (\Yii::$app->request->getIsPost()) {
         if (!$conf) {
             throw new \Exception(yii::t('task', 'unknown project'));
         }
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('/task/');
             }
         }
     }
     if ($projectId) {
         $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
         return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
     }
     // 成员所属项目
     $projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
     return $this->render('select-project', ['projects' => $projects]);
 }
 public function actionCreate()
 {
     $task = new Task();
     if ($task->load(Yii::$app->request->post()) && $task->save()) {
         Yii::$app->getSession()->setFlash("success", 'The record was saved.');
         return $this->redirect(["task/"]);
     }
     return $this->render("create", ["models" => ["task" => $task]]);
 }
Beispiel #6
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Task();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Task();
     $modelDevice = new Device();
     $modelAction = new Action();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'from_device_ids' => ArrayHelper::map($modelDevice->getDeviceMaster(), 'id', 'name'), 'to_device_ids' => ArrayHelper::map($modelDevice->getDeviceAll(), 'id', 'name'), 'action_ids' => ArrayHelper::map($modelAction->getActionAll(), 'id', 'name')]);
     }
 }
Beispiel #8
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed test
  */
 public function actionCreate()
 {
     $model = new Task();
     $categories = Category::find()->all();
     $units = DicUnit::find()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'categories' => $categories, 'units' => $units]);
     }
 }
Beispiel #9
0
 /**
  * 提交任务
  *
  * @param $projectId
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     $task = new Task();
     if ($projectId) {
         // svn下无trunk
         $nonTrunk = false;
         $conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
         $conf = Project::getConf($projectId);
         // 第一次可能会因为更新而耗时,但一般不会,第一次初始化会是在检测里
         if ($conf->repo_type == Project::REPO_SVN && !file_exists(Project::getDeployFromDir())) {
             $version = Repo::getRevision($conf);
             $version->updateRepo();
         }
         // 为了简化svn无trunk, branches时,不需要做查看分支,直接就是主干
         $svnTrunk = sprintf('%s/trunk', Project::getDeployFromDir());
         // svn下无trunk目录
         if (!file_exists($svnTrunk)) {
             $nonTrunk = true;
         }
     }
     if (\Yii::$app->request->getIsPost()) {
         if (!$conf) {
             throw new \Exception(yii::t('task', 'unknown project'));
         }
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 return $this->redirect('/task/');
             }
         }
     }
     if ($projectId) {
         $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
         return $this->render($tpl, ['task' => $task, 'conf' => $conf, 'nonTrunk' => $nonTrunk]);
     }
     // 成员所属项目
     $projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
     return $this->render('select-project', ['projects' => $projects]);
 }
Beispiel #10
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  * @throws UserException
  */
 public function actionCreate()
 {
     $goalId = (int) Yii::$app->request->get('goal_id', 0);
     if (!$goalId) {
         throw new UserException('Goal id is not provided');
     }
     $goal = Goal::findOne($goalId);
     if (!$goal) {
         throw new UserException("Goal [{$goalId}] not found");
     }
     $model = new Task(['goal_id' => $goalId]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Yii::$app->request->post('referrer') ?: $model->goal->urlTaskList());
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #11
0
 /**
  * Updates an existing Task model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id = null, $partner_id = null)
 {
     if ($id) {
         $model = $this->findModel($id);
     } else {
         $model = new Task();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
         return $this->redirect(['index']);
     } else {
         if (!$id) {
             $model->timestamp = Yii::$app->formatter->asDate(time());
             $model->user_id = Yii::$app->user->id;
             if ($partner_id) {
                 $model->select_partner = Partner::findOne($partner_id);
             }
         }
         return $this->renderAjax('update', ['model' => $model]);
     }
 }
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Task();
     if ($model->load(Yii::$app->request->post())) {
         $model->attachment = UploadedFile::getInstance($model, 'attachment');
         $model->task_start = date('Y-m-d', strtotime($model->task_start));
         $model->task_end = date('Y-m-d', strtotime($model->task_end));
         if ($model->attachment) {
             $fileName = sprintf('%s.%s', $model->task_to . time(), $model->attachment->extension);
             $model->attachment->saveAs('uploads/' . $fileName);
             $model->attachment = $fileName;
         } else {
             $model->attachment = '';
         }
         if ($model->validate() && $model->save()) {
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Data Permintaan Tugas Berhasil Disimpan'));
             return $this->redirect(['index']);
         } else {
             Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Data Permintaan Tugas Gagal Disimpan'));
         }
     }
     return $this->render('create', ['model' => $model]);
 }
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $projectId
  * @return mixed
  */
 public function actionCreate($projectId)
 {
     $model = new Task();
     if ($model->load(Yii::$app->request->post())) {
         if (strtotime($model->delivery_date) >= strtotime(Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'))) {
             $students = $_POST['Task']['students'];
             $model->status = Task::NEW_TASK;
             $model->project_id = $projectId;
             $model->save();
             foreach ($students as $value) {
                 Yii::$app->db->createCommand()->insert('student_evidence', ['task_id' => $model->id, 'project_id' => $model->project_id, 'evidence_id' => null, 'student_id' => $value, 'status' => Task::NEW_TASK])->execute();
                 $this->setNotification($value, $model->id, $model->project_id, Notification::NEW_TASK);
             }
             Yii::$app->getSession()->setFlash('success', 'Petición creada exitosamente');
             return $this->redirect(['student-evidence/index']);
         } else {
             Yii::$app->getSession()->setFlash('danger', 'La fecha de entrega no puede ser anterior a la fecha actual');
             return $this->render('create', ['model' => $model, 'projectId' => $projectId]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (($role = priviledge::getRole()) == 'Admin') {
         $model = new Task();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             $model->url = strtolower($model->url);
             $model->status = 'Pending';
             //$model->user_id = \Yii::$app->user->identity;
             $mode = new LoginForm();
             $mode->username = \Yii::$app->user->identity->username;
             $user = new User();
             if ($user = $mode->getUser()) {
                 $model->user_id = $user->id;
             }
             $listsocmed = $_POST['Task']['socmed'];
             $model->facebook = 'No';
             $model->twitter = 'No';
             foreach ($listsocmed as $value) {
                 if ($value == 'Facebook') {
                     $model->facebook = 'Yes';
                 }
                 if ($value == 'Twitter') {
                     $model->twitter = 'Yes';
                 }
             }
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->task_id]);
             } else {
                 return $this->render('create', ['model' => $model]);
             }
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
 public function actionTaskEdit()
 {
     if (isset($_GET['task_id'])) {
         $task = Task::findOne($_GET['task_id']);
     } else {
         $task = new Task();
     }
     /**
      * @var Task $task
      */
     $post = \Yii::$app->request->post();
     if ($task->load($post) && $task->validate()) {
         $task = TaskManager::editTask($task, $post['Task']['time'], $post['Task']['command'], $post['Task']['status'], $post['Task']['comment']);
         \Yii::$app->response->redirect('/?r=tasks/task-edit&task_id=' . $task->task_id);
     }
     return $this->render('task_edit', array('task' => $task, 'methods' => TaskLoader::getAllMethods(self::$tasks_controllers_folder, self::$tasks_namespace)));
 }
 public function actionCreate()
 {
     $model = new Task();
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         if ($model->save()) {
             return 'ok';
         }
     } elseif (Yii::$app->request->isAjax) {
         $date = new \DateTime();
         $model->start = $date->format('Y-m-d');
         $model->end = $date->format('Y-m-d');
         $model->family_id = \Yii::$app->user->identity->family_id;
         $model->member_id = \Yii::$app->user->identity->family_member_id;
         $model->description = '';
         $model->done = 0;
         $model->status = \app\enum\TaskStatus::__default;
         $model->task_type = \app\enum\TaskType::__default;
         $modelMembers = \Yii::$app->user->identity->familyMembers;
         $modelAssigned = TaskAssign::findAll(['task_id' => 0]);
         return json_encode($this->renderAjax('_user', ['model' => $model, 'modelMembers' => $modelMembers, 'modelAssigned' => $modelAssigned]));
     }
     return false;
 }
Beispiel #17
0
 public function actionReplyTask($id)
 {
     $parentTask = $this->findModelReplyTask($id);
     if (!empty($parentTask)) {
         $model = new Task();
         $searchModel = new TaskDetailSearch();
         $dataProvider = $searchModel->search($parentTask->id);
         if (Yii::$app->request->isPost) {
             if ($model->load(Yii::$app->request->post())) {
                 $model->task_title = $parentTask->task_title;
                 $model->task_to = Yii::$app->user->id;
                 $model->task_from = $parentTask->task_from;
                 $model->parent_task_id = $id;
                 $model->attachment = UploadedFile::getInstance($model, 'attachment');
                 $model->task_start = date('Y-m-d', strtotime($model->task_start));
                 $model->task_end = date('Y-m-d', strtotime($model->task_end));
                 $model->period = $parentTask->period;
                 if ($model->attachment) {
                     $fileName = sprintf('%s.%s', $model->task_to . time(), $model->attachment->extension);
                     $model->attachment->saveAs('uploads/' . $fileName);
                     $model->attachment = $fileName;
                 } else {
                     $model->attachment = '';
                 }
                 if ($model->validate() && $model->save()) {
                     Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Data Tugas Berhasil Disimpan'));
                     return $this->redirect(['reply-task', 'id' => $id]);
                 } else {
                     Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Data Tugas Gagal Disimpan'));
                 }
             }
         }
         return $this->render('task-create-detail', ['model' => $model, 'parentTask' => $parentTask, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     }
 }