Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchDone($params)
 {
     $query = Assignment::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['create_time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'deadline' => $this->deadline, 'status' => $this->status, 'notify_status' => $this->notify_status, 'notify_times' => $this->notify_times, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['status' => R::ASSIGNMENT_DONE]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Try to find Assignment which not yet viewed by executer.
  * Calls when Executer run team/assignments
  */
 public function notifyAssignment()
 {
     $assignments = Assignment::find()->where(['user_id' => Yii::$app->user->identity->id, 'notify_status' => R::NOTIFY_ACTIVE])->all();
     foreach ($assignments as $assignment) {
         // if ($assignment->notify_times == 1) {
         $assignment->notify_status = R::NOTIFY_NOTIFIED;
         $assignment->save();
         // } else {
         // $assignment->notify_times += 1;
         // $assignment->save();
         // }
     }
 }
Example #3
0
 /**
  * Assignment Notification for Executer
  * If return true, RED CIRCLE will appear
  * runs in init() in each Controller
  */
 public function getAssignmentNotification()
 {
     if ($this->role == R::ADMIN) {
         //do nothing
     } elseif ($this->role == R::DESIGNER || $this->role == R::FRONTEND || $this->role == R::COPYRIGHTER || $this->role == R::PROTOTYPER || $this->role == R::TESTER || $this->role == R::BACKEND || $this->role == R::CONTENTER) {
         $stages = Assignment::find()->where(['user_id' => $this->id, 'status' => [R::ASSIGNMENT_CREATED, R::ASSIGNMENT_APPROVED, R::ASSIGNMENT_DONE], 'notify_status' => R::NOTIFY_ACTIVE])->count();
         if ($stages == 0) {
             return false;
         } else {
             return true;
         }
     }
 }