/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Naturezaocorrencia::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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(['idNatureza' => $this->idNatureza]);
     $query->andFilterWhere(['like', 'Nome', $this->Nome]);
     return $dataProvider;
 }
 /**
  * Finds the Naturezaocorrencia model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Naturezaocorrencia the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Naturezaocorrencia::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
 public function emAberto($params)
 {
     $query = Ocorrencia::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     $idCategoriabkp = $this->idCategoria;
     $idNaturezabkp = $this->idNatureza;
     $periodobkp = $this->periodo;
     $databkp = $this->data;
     if ($this->data != null) {
         list($dia, $mes, $ano) = split('[/]', $this->data);
         $this->data = $ano . '-' . $mes . '-' . $dia;
     }
     if ($this->dataConclusao != null) {
         list($dia, $mes, $ano) = split('[/]', $this->dataConclusao);
         $this->dataConclusao = $ano . '-' . $mes . '-' . $dia;
     }
     if ($this->periodo != null) {
         if (strcmp($this->periodo, 'Manhã') == 0) {
             $this->periodo = 1;
         } elseif (strcmp($this->periodo, 'Tarde') == 0) {
             $this->periodo = 2;
         } elseif (strcmp($this->periodo, 'Noite') == 0) {
             $this->periodo = 3;
         } elseif (strcmp($this->periodo, 'Madrugada') == 0) {
             $this->periodo = 4;
         }
     }
     $Natureza = Naturezaocorrencia::find()->where(['nome' => $this->idNatureza])->One();
     if ($Natureza != null) {
         $this->idNatureza = $Natureza->idNatureza;
     }
     $Categoria = Categoria::find()->where(['nome' => $this->idCategoria])->One();
     if ($Categoria != null) {
         $this->idCategoria = $Categoria->idCategoria;
     }
     //$this->idCategoria = Categoria::findOne($this->idCategoria)->Nome;
     $query->andFilterWhere(['idOcorrencia' => $this->idOcorrencia, 'status' => 1, 'data' => $this->data, 'hora' => $this->hora, 'dataConclusao' => $this->dataConclusao, 'idCategoria' => $this->idCategoria, 'idSubLocal' => $this->idSubLocal, 'idNatureza' => $this->idNatureza]);
     $query->andFilterWhere(['like', 'periodo', $this->periodo])->andFilterWhere(['like', 'detalheLocal', $this->detalheLocal])->andFilterWhere(['like', 'descricao', $this->descricao])->andFilterWhere(['like', 'procedimento', $this->procedimento])->andFilterWhere(['like', 'cpfUsuario', $this->cpfUsuario]);
     $this->idCategoria = $idCategoriabkp;
     $this->idNatureza = $idNaturezabkp;
     $this->periodo = $periodobkp;
     $this->data = $databkp;
     return $dataProvider;
 }
예제 #4
0
 public function afterFind()
 {
     list($ano, $mes, $dia) = split('[-]', $this->data);
     $this->data = $dia . '/' . $mes . '/' . $ano;
     if ($this->dataConclusao != null) {
         list($ano, $mes, $dia) = split('[-]', $this->dataConclusao);
         $this->dataConclusao = $dia . '/' . $mes . '/' . $ano;
     }
     if ($this->hora != null) {
         list($hora, $minuto, $segundos) = split('[:]', $this->hora);
         $this->hora = $hora . ':' . $minuto;
     }
     $foto = FotoController::getFotoOcorrencia($this->idOcorrencia);
     if ($foto != null) {
         $this->comentarioFoto = $foto[0]->comentario;
     }
     $this->idCategoriabkp = $this->idCategoria;
     //    echo "Categoria bkp".$this->idCategoriabkp;
     $this->idSubLocalbkp = $this->idSubLocal;
     $this->idNaturezabkp = $this->idNatureza;
     $sublocal = Sublocal::findOne($this->idSubLocal);
     $this->idLocal = $sublocal->idLocal;
     $this->cpfbkp = $this->cpfUsuario;
     $this->idSubLocal = Sublocal::findOne($this->idSubLocal)->Nome;
     $this->cpfUsuario = User::findOne($this->cpfUsuario)->nome;
     $this->idNatureza = Naturezaocorrencia::findOne($this->idNatureza)->Nome;
     $this->idCategoria = Categoria::findOne($this->idCategoria)->Nome;
     if ($this->status == 1) {
         $this->status = 'Aberto';
     } elseif ($this->status == 2) {
         $this->status = 'Solucionado';
     } elseif ($this->status == 3) {
         $this->status = 'Não Solucionado';
     }
     if ($this->periodo == 1) {
         $this->periodo = 'Manhã';
     } elseif ($this->periodo == 2) {
         $this->periodo = 'Tarde';
     } elseif ($this->periodo == 3) {
         $this->periodo = 'Noite';
     } elseif ($this->periodo == 4) {
         $this->periodo = 'Madrugada';
     }
 }