Ejemplo n.º 1
0
 /**
  * Cria uma instância do provedor de dados com consulta de pesquisa aplicada
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TipoEquip::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // Descomentar a seguinte linha se você não quer devolver quaisquer registos quando a validação falhar
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['idtipoequip' => $this->idtipoequip, 'fl_delete' => $this->fl_delete]);
     $query->andFilterWhere(['like', 'nome', $this->nome]);
     // Filtra os registros que são diferentes de fl_delete=0, pois significa que foram deletados
     $query->andFilterWhere(['fl_delete' => 0]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\TipoEquip;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\Equipamento */
/* @var $form yii\widgets\ActiveForm */
$tipoequip = TipoEquip::findBySql("SELECT idtipoequip, nome FROM tb_tipoequip WHERE fl_delete = 0;")->all();
$listData = ArrayHelper::map($tipoequip, 'idtipoequip', 'nome');
?>

<div class="equipamento-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'descricao')->textInput(['maxlength' => true]);
?>

<!--     <?php 
//= $form->field($model, 'idtipoequip')->textInput(['maxlength' => true])
?>
 -->
    
    <?php 
echo $form->field($model, 'dtcompra')->widget(\yii\widgets\MaskedInput::className(), ['mask' => '99/99/9999']);
?>
Ejemplo n.º 3
0
 /**
  * Finds the TipoEquip model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return TipoEquip the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TipoEquip::findOne($id)) !== null && $model->fl_delete == 0) {
         return $model;
     } else {
         throw new NotFoundHttpException('O registro solicitado não foi encontrado.');
     }
 }