public function actionCreate()
 {
     $model = new Tema();
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->save()) {
             return ['status' => true, 'errors' => []];
         } else {
             return ['status' => false, 'errors' => $model->errors];
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 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);
         }
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdTemas()
 {
     return $this->hasMany(Tema::className(), ['id' => 'id_tema'])->viaTable('tema_audiencia', ['id_audiencia' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdTema()
 {
     return $this->hasOne(Tema::className(), ['id' => 'id_tema']);
 }
Example #5
0
 public function destroyTema($id)
 {
     try {
         $tema = Tema::find($id);
         $temasCategoria = TemasCategoria::where('tema', '=', $id)->first();
         $temasCategoria->delete();
         $tema->delete();
         return JsonResponse::create(array('message' => "Eliminado Correctamente", "request" => null), 201);
     } catch (Exception $exc) {
         return JsonResponse::create(array('message' => "No se pudo Eliminar el Tema", "exception" => $exc->getMessage(), "request" => json_encode($data)), 401);
     }
 }
 /**
  * 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.');
     }
 }
 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()];
         }
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTema()
 {
     return $this->hasOne(Tema::className(), ['id' => 'tema_id']);
 }