コード例 #1
0
 /**
  * Finds the Tema model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tema the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tema::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
 public function getTemaTextos()
 {
     $temas = "";
     if (($temasActuales = Tema_Acervo::find()->andWhere("acervo_id = {$this->id}")->asArray()->all()) !== null) {
         $temasActuales = ArrayHelper::getColumn($temasActuales, 'tema_id');
         foreach ($temasActuales as $tema) {
             $r = Tema::findOne(['id' => $tema]);
             if (strlen($temas) > 40) {
                 $temas .= "...";
                 return $temas;
             } else {
                 if (isset($r)) {
                     $temas .= $r->nombre;
                     $temas .= ", ";
                 } else {
                     $temas .= "no tiene";
                     $temas .= ", ";
                 }
             }
         }
     }
     if (strlen($temas) === 0) {
         return $temas;
     } else {
         if (strlen($temas) < 40) {
             return substr($temas, 0, -2);
         }
     }
 }
コード例 #3
0
 public function actionAddmarcacao()
 {
     if ($getParams = Yii::$app->request->get()) {
         $arrTema = [];
         $arrPessoa = [];
         /*
             		 * Já deixei pronto caso precise implementar suporte a multiplos temas e pessoas
             		foreach($getParams['id_tema'] as $idTema)
             		{
             			$arrTema[] = Tema::findOne($idTema)->dsc_tema;
             		}
             	
             		foreach($getParams['id_pessoa'] as $idPessoa)
             		{
             			$pessoa = Pessoa::findOne($idPessoa);
             			$tipoPessoa = $pessoa->getIdTipoPessoa()->one();
             			$arrPessoa[] = $pessoa->dsc_pessoa . ' - ' .$tipoPessoa->dsc_tipo_pessoa;
             		}*/
         $arrTema[] = Tema::findOne($getParams['id_tema'])->dsc_tema;
         $pessoa = Pessoa::findOne($getParams['id_pessoa']);
         $tipoPessoa = $pessoa->getIdTipoPessoa()->one();
         $arrPessoa[] = $pessoa->dsc_pessoa . ' - ' . $tipoPessoa->dsc_tipo_pessoa;
         $arrTempo[] = gmdate("H:i:s", $getParams['tempo']);
         $ulTema = Html::ul($arrTema, ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item']]);
         $ulPessoa = Html::ul($arrPessoa, ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item']]);
         $ulTempo = Html::ul($arrTempo, ['class' => 'list-group', 'itemOptions' => ['class' => 'list-group-item']]);
         return ['ultema' => $ulTema, 'ulpessoa' => $ulPessoa, 'ultempo' => $ulTempo];
     }
     if ($postParams = Yii::$app->request->post()) {
         $anotacao = new Anotacao();
         $anotacao->id_tema = $postParams['id_tema'];
         $anotacao->id_pessoa = $postParams['id_pessoa'];
         $anotacao->id_audiencia = $postParams['id_audiencia'];
         $anotacao->num_tempo = $postParams['tempo'];
         $anotacao->id_usuario = Yii::$app->user->identity->id;
         if ($anotacao->save()) {
             $anotacao->refresh();
             return ['li' => $anotacao->getLi()];
         }
     }
 }