Esempio n. 1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  *
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  *
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('email', $this->email, true);
     $criteria->compare('nome', $this->nome, true);
     $criteria->compare('cpf', $this->cpf, true);
     $criteria->compare('sexo', $this->sexo, true);
     $criteria->compare('telefone_fixo', $this->telefone_fixo, true);
     $criteria->compare('celular', $this->celular, true);
     $criteria->compare('endereco', $this->endereco, true);
     $criteria->compare('numero', $this->numero);
     $criteria->compare('complemento', $this->complemento, true);
     $criteria->compare('data_cadastro', $this->data_cadastro, true);
     if (!empty($this->placa)) {
         $oClientesCarros = ClienteCarro::model()->findAll(array('condition' => 'placa like "%' . $this->placa . '%"'));
         $criteria->addCondition('t.id in (' . implode(',', CHtml::listData($oClientesCarros, 'id', 'id')) . ')');
     }
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
Esempio n. 2
0
 public function actionGetDataJson()
 {
     $array = array();
     $oModels = ClienteCarro::model()->naoExcluido()->ordenarPlaca()->findAllByAttributes(array('cliente_id' => $_POST['clienteId']));
     $i = 0;
     if (!empty($oModels)) {
         foreach ($oModels as $model) {
             $array[$i]['id'] = intval($model->id);
             $array[$i]['text'] = strtoupper($model->placa);
             $i++;
         }
     }
     echo json_encode($array);
 }