コード例 #1
0
ファイル: Acdenroll.php プロジェクト: henrique-r-luz/portal
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAcdevaluationenrolls()
 {
     return $this->hasMany(Acdevaluationenroll::className(), ['enrollid' => 'enrollid']);
 }
コード例 #2
0
 public function salvaNotasCara($param)
 {
     //  $transaction = Yii::$app->db->beginTransaction();
     //    try {
     $cont = 0;
     $resp = "";
     foreach ($param as $key => $notas) {
         if ($key != "_csrf") {
             $intenNota = new Acdevaluationenroll();
             $intenNotaAux = null;
             $index = explode("_", $key);
             if (!$index[2] == null && !$index[2] == "") {
                 $intenNotaAux = Acdevaluationenroll::findOne(['evaluationenrollid' => $index[2]]);
             }
             if ($intenNotaAux == null) {
                 if ($this->itensSalva($notas, $index, $intenNota) == 1) {
                     //ok
                 } else {
                     //  $transaction->rollback();
                     $cont++;
                     $resp .= $index[0] . "_" . $index[1] . "&";
                     //  throw $e;
                     // return 0 ;
                 }
             } else {
                 if ($intenNotaAux->note != $notas) {
                     if ($this->itensSalva($notas, $index, $intenNota) == 1) {
                         //ok
                         //    echo 1;
                     } else {
                         //erro
                         // $transaction->rollback();
                         $resp .= $index[0] . "_" . $index[1] . "&";
                         $cont++;
                         //    throw "erro ao salvar um registro, provavelmente validação";
                         // return 0;
                     }
                 }
             }
         }
     }
     if ($cont == 0) {
         echo 1;
     } else {
         echo $resp;
     }
     // $transaction->commit();
     // echo 1;
     /*    } catch (\Exception $e) {
           $transaction->rollback();
           echo 0;
           throw $e;
           } */
 }
コード例 #3
0
 public function objNota($params)
 {
     $groupid = (int) Yii::$app->session['groupid'];
     $degreeid = null;
     $vetAlunos = [];
     $vetAvaliacao = [];
     $whereAlunos = [];
     $whereAvaliacao = [];
     //  print_r($param);
     if (isset($params['grau'])) {
         $degreeid = $params['grau'];
     }
     if (isset($params['alunos']['item'])) {
         if (!empty($params['alunos']['item'])) {
             $vetAlunos = $params['alunos']['item'];
             if (!empty($vetAlunos)) {
                 $whereAlunos = ['in', 'enrollid', $vetAlunos];
             }
         }
     }
     if (isset($params['avaliacao']['item'])) {
         if (!empty($params['avaliacao']['item'])) {
             $vetAvaliacao = $params['avaliacao']['item'];
             if (!empty($vetAvaliacao)) {
                 $aux = [];
                 foreach ($vetAvaliacao as $i => $id) {
                     $aux[$i] = (int) $id;
                 }
                 $vetAvaliacao = $aux;
                 $whereAvaliacao = ['in', 'evaluationid', $vetAvaliacao];
             }
             // echo '>>>'.print_r($whereAvaliacao);
             // exit();
         }
     }
     if ($degreeid != null || $degreeid != "") {
         $this->avaliacao = Acdevaluation::find()->andwhere(['groupid' => $groupid])->andwhere(['degreeid' => $degreeid])->andwhere($whereAvaliacao)->all();
         $alunos = Acdenroll::find()->joinWith(['contract.person'])->where(['groupid' => $groupid])->andwhere($whereAlunos)->orderBy('name')->all();
         $vetEvaluation = [];
         $vetEnrollid = [];
         $vetLabel = [];
         foreach ($alunos as $itemAluno) {
             array_push($vetEnrollid, $itemAluno->enrollid);
             $vet[$itemAluno->enrollid]['alunos'] = $itemAluno->contract->person->name;
             foreach ($this->avaliacao as $item) {
                 //  $str = $itemAluno->enrollid.','.$item->degreeid.','.$item->evaluationid;
                 array_push($vetEvaluation, $item->evaluationid);
                 $vetLabel[$item->evaluationid] = $item->description;
                 $vet[$itemAluno->enrollid][$item->evaluationid] = 'nota';
             }
         }
         $result = array_unique($vetEvaluation);
         $vetEvaluation = $result;
         $this->nota = Acdevaluationenroll::find()->andwhere(['in', 'enrollid', $vetEnrollid])->andwhere(['in', 'evaluationid', $vetEvaluation])->orderBy(['recorddate' => SORT_DESC])->all();
         //  echo 'num>>>'.print_r($vetEnrollid);
         // exit();
         $dataProvider = new ArrayDataProvider(['allModels' => $vet]);
         $coluna = [];
         if (!empty($vet)) {
             foreach ($vet as $linhas) {
                 $this->cont = 0;
                 foreach ($linhas as $chave => $colunas) {
                     if ($chave == 'alunos') {
                         $coluna[$chave] = ['type' => TabularForm::INPUT_RAW, 'label' => 'Alunos', 'value' => function ($model, $key, $index, $widget) {
                             return Html::label($model['alunos'], null, ['style' => 'min-width:200px;font-weight: lighter;']);
                         }];
                     } else {
                         $coluna[$chave] = ['type' => TabularForm::INPUT_RAW, 'label' => $vetLabel[$chave], 'options' => ['class' => 'form-control text-center', 'style' => 'min-width:80px'], 'value' => function ($model, $key, $index, $widget) {
                             if ($this->cont == count($this->avaliacao)) {
                                 $this->cont = 0;
                             }
                             $ava = $this->avaliacao[$this->cont];
                             $ava->evaluationid;
                             $valorNota = [];
                             $valorNota['val'] = 0;
                             $valorNota['id'] = null;
                             foreach ($this->nota as $values) {
                                 if ($values->enrollid == $key && $values->evaluationid == $ava->evaluationid) {
                                     $valorNota['val'] = $values->note;
                                     $valorNota['id'] = $values->evaluationenrollid;
                                     break;
                                 }
                             }
                             $this->cont++;
                             return '<div class="form-group field-' . $key . '_' . $ava->evaluationid . ' required">' . Html::textInput($key . '_' . $ava->evaluationid . '_' . $valorNota['id'], $valorNota['val'], ['class' => 'form-control text-center nota-grid', 'style' => 'min-width:80px', "id" => $key . '_' . $ava->evaluationid]) . '<div class="help-block"></div>' . '</div>';
                         }];
                     }
                 }
             }
             $result = [];
             $result['coluna'] = $coluna;
             $result['dataProvider'] = $dataProvider;
             return $result;
         }
     } else {
         $result = [];
         $result['coluna'] = ['Pesquise as notas' => ['type' => TabularForm::INPUT_STATIC]];
         $result['dataProvider'] = $dataProvider = new ArrayDataProvider(['allModels' => []]);
         return $result;
     }
 }