/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Acdenroll::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => '100']]);
     $query->where(['groupid' => (int) Yii::$app->session['groupid']]);
     $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(['datetime' => $this->datetime, 'enrollid' => $this->enrollid, 'contractid' => $this->contractid, 'groupid' => $this->groupid, 'curriculumid' => $this->curriculumid, 'dateenroll' => $this->dateenroll, 'hourenroll' => $this->hourenroll, 'datecancellation' => $this->datecancellation, 'hourcancellation' => $this->hourcancellation, 'reasoncancellationid' => $this->reasoncancellationid, 'note' => $this->note, 'examnote' => $this->examnote, 'finalnote' => $this->finalnote, 'frequency' => $this->frequency, 'exploitationinstitutionid' => $this->exploitationinstitutionid, 'numberhourexploitation' => $this->numberhourexploitation, 'creditsexploitation' => $this->creditsexploitation, 'isshowdocumentendcourse' => $this->isshowdocumentendcourse, 'statusid' => $this->statusid, 'isinternet' => $this->isinternet, 'isconfirm' => $this->isconfirm, 'issetfree' => $this->issetfree, 'isexploitation' => $this->isexploitation, 'learningperiodid' => $this->learningperiodid, 'detailenrollstatusid' => $this->detailenrollstatusid, 'preenrollconsumevacant' => $this->preenrollconsumevacant, 'unitid' => $this->unitid, 'sectorid' => $this->sectorid, 'centerid' => $this->centerid, 'examiningboard' => $this->examiningboard]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'ipaddress', $this->ipaddress])->andFilterWhere(['like', 'concept', $this->concept])->andFilterWhere(['like', 'textevaluation', $this->textevaluation])->andFilterWhere(['like', 'obsexploitation', $this->obsexploitation])->andFilterWhere(['like', 'frequencyalertemail', $this->frequencyalertemail])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'complement', $this->complement])->andFilterWhere(['like', 'exploitationtype', $this->exploitationtype])->andFilterWhere(['like', 'process', $this->process])->andFilterWhere(['like', 'subclassid', $this->subclassid])->andFilterWhere(['like', 'finalexaminationtheme', $this->finalexaminationtheme])->andFilterWhere(['like', 'originenroll', $this->originenroll]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEnroll()
 {
     return $this->hasOne(Acdenroll::className(), ['enrollid' => 'enrollid']);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function objNota()
 {
     $groupid = (int) Yii::$app->session['groupid'];
     $degreeid = 975;
     $this->avaliacao = Acdevaluation::find()->andwhere(['groupid' => $groupid])->andwhere(['degreeid' => $degreeid])->all();
     $alunos = Acdenroll::find()->joinWith(['contract.person'])->where(['groupid' => $groupid])->all();
     // $vet = [];
     //$vet = [];
     $vetLabel = [];
     foreach ($alunos as $itemAluno) {
         $vet[$itemAluno->enrollid]['alunos'] = $itemAluno->contract->person->name;
         foreach ($this->avaliacao as $item) {
             //  $str = $itemAluno->enrollid.','.$item->degreeid.','.$item->evaluationid;
             $vetLabel[$item->evaluationid] = $item->description;
             $vet[$itemAluno->enrollid][$item->evaluationid] = 'nota';
         }
         //array_push($vet, $vetAux);
         //$vet[$str] = [$vetAux];
         //$vet = [$vetAux];
         //$vetAux = [];
     }
     //  print_r($vet);
     //  exit();
     $dataProvider = new ArrayDataProvider(['allModels' => $vet]);
     $coluna = [];
     if (!empty($vet)) {
         foreach ($vet as $linhas) {
             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->scheduleprofessorcontentid);
                         return Html::label($model['alunos'], null, ['style' => 'min-width:200px;font-weight: lighter;']);
                         // return Html::label($model->timeid);
                     }];
                 } else {
                     $coluna[$chave] = ['type' => TabularForm::INPUT_RAW, '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;
                         $this->cont++;
                         return $model[$ava->evaluationid];
                         // return Html::label($model->scheduleprofessorcontentid);
                         // return Html::label($model['alunos'], null, ['style' => 'min-width:200px;font-weight: lighter;']);
                         // return Html::label($model->timeid);
                     }];
                     /*  $coluna[$chave] = ['type' => TabularForm::INPUT_TEXT,
                         //'type'=> $form->field($model, 'last_updated')->textInput(),
                         //'label'=>$vetLabel[$chave],
                         //'value'=> 'nota',
                         'options' => ['class' => 'form-control text-center', 'style' => 'min-width:80px']
                         ]; */
                 }
             }
         }
         $result = [];
         $result['coluna'] = $coluna;
         $result['dataProvider'] = $dataProvider;
         return $result;
     }
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAcdenrolls()
 {
     return $this->hasMany(Acdenroll::className(), ['centerid' => 'centerid']);
 }
 /**
  * Creates a new Acdfrequenceenroll model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionPesquisafrequencia()
 {
     $search = new FrequenciaPesquisa();
     $groupid = Yii::$app->session['groupid'];
     $professor = Yii::$app->session['idprofessor'];
     if ($search->load(Yii::$app->request->post())) {
         $dataInicial = $search->dataInicial;
         $dataFinal = $search->dataFinal;
         $compareInicial = str_replace('-', '', $dataInicial);
         $compareFinal = str_replace('-', '', $dataFinal);
         if ($compareInicial > $compareFinal) {
             // echo
             echo 0;
         } else {
             $filtroMat = array('groupid' => $groupid);
             $idEnroll = array();
             $idTime = array();
             if (!empty($search->alunos)) {
                 foreach ($search->alunos as $matricula) {
                     array_push($idEnroll, $matricula);
                 }
                 $filtroMat = array('in', 'enrollid', $idEnroll);
             }
             if (!empty($search->horas)) {
                 foreach ($search->horas as $hora) {
                     array_push($idTime, $hora);
                 }
                 /// $filtroMat = array('in', 'enrollid', $idEnroll);
             }
             $aluno = Acdenroll::find()->joinWith(['contract.person'])->where(['groupid' => $groupid])->where($filtroMat)->orderBy('name')->all();
             $tabela = $this->criaFrequencia($groupid, $dataInicial, $dataFinal, $idTime, $professor);
             $dataFrequencia = array();
             $timeFrequencia = array();
             $schedulesFrequencia = array();
             $frequencia = array();
             foreach ($tabela['colunTab'] as $itens) {
                 array_push($dataFrequencia, $itens[0]);
                 array_push($timeFrequencia, $itens[1][1]);
                 array_push($schedulesFrequencia, $itens[1][2]);
             }
             $regFrequencia = Acdfrequenceenroll::find()->where(['in', 'timeid', $timeFrequencia])->where(['in', 'scheduleid', $schedulesFrequencia])->where(['in', 'occurrencedates', $dataFrequencia])->where(['in', 'enrollid', $this->getIdMatriculaAluno($aluno)])->all();
             foreach ($regFrequencia as $reg) {
                 $frequencia[$reg->scheduleid][$reg->enrollid][$reg->frequencydate][$reg->timeid] = $reg->frequency;
             }
             Yii::$app->TabelaFrequencia->populaTabela($aluno, $tabela['colunTab'], $frequencia, $tabela['contadorAula']);
             // Yii::$app->TabelaFrequencia->init();
         }
     }
 }
                    <?php 
$form = ActiveForm::begin(['id' => $search->formName(), 'action' => 'index.php?r=portal-professor/frequencia/pesquisafrequencia']);
?>

                    <?php 
echo $form->field($search, 'dataInicial')->widget(DateControl::classname(), ['type' => DateControl::FORMAT_DATE, 'ajaxConversion' => false, 'options' => ['pluginOptions' => ['autoclose' => true]]]);
?>

                    <?php 
echo $form->field($search, 'dataFinal')->widget(DateControl::classname(), ['type' => DateControl::FORMAT_DATE, 'ajaxConversion' => false, 'options' => ['pluginOptions' => ['autoclose' => true]]]);
?>
   


                    <?php 
echo $form->field($search, 'alunos')->widget(Select2::classname(), ['name' => 'state_2', 'value' => '', 'data' => ArrayHelper::map(Acdenroll::find()->where(['groupid' => $groupid])->all(), 'enrollid', 'contract.person.name'), 'id' => 'combo', 'pluginOptions' => [], 'options' => ['placeholder' => 'Seleciona os Alunos', 'multiple' => true]]);
?>
                    <div class="form-group">
                        <?php 
echo Html::submitButton('Pesquisa frequĂȘncia', ['class' => 'btn btn-primary']);
?>
                    </div>
                    <?php 
ActiveForm::end();
?>
                       </div>     

                           
<?php 
$js = <<<JS
// get the form id and set the event
 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;
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAcdenrolls()
 {
     return $this->hasMany(Acdenroll::className(), ['learningperiodid' => 'learningperiodid']);
 }