示例#1
0
 /**
  * Returns registration's associated scorecard. Creates one if none exists.
  *
  * @param boolean $detailed Whether to create hole detail score for scorecard
  *
  * return common\models\Scorecard
  */
 public function getScorecard($detailed = false)
 {
     if (!($scorecard = $this->getScorecards()->one())) {
         // Scorecard::findOne(['registration_id'=>$registration->id])
         $scorecard = new ScorecardForCompetition(['scorecard_type' => Scorecard::TYPE_COMPETITION, 'registration_id' => $this->id, 'status' => Scorecard::STATUS_OPEN]);
         $scorecard->save();
         if ($detailed) {
             $scorecard->makeScores();
         }
     }
     return $scorecard;
 }
示例#2
0
 /**
  * Bulk update status or delete for PJAXed gridview.
  */
 public function actionBulkStatus()
 {
     $ids = (array) Yii::$app->request->post('ids');
     // Array or selected records primary keys
     $status = Yii::$app->request->post('status');
     if (!$ids) {
         // Preventing extra unnecessary query
         return;
     }
     foreach (ScorecardForCompetition::find()->andWhere(['id' => $ids])->each() as $r) {
         $r->status = $status;
         $r->save();
     }
 }