Exemplo n.º 1
0
 public function getGroups($idContato)
 {
     $model = Contato::model()->findByPk($idContato);
     $print = '';
     foreach ($model->grupos as $value) {
         $print .= $value->nome . ' ';
     }
     return $print;
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     date_default_timezone_set('UTC');
     $data = date('m-d');
     $criteria = new CDbCriteria();
     $criteria->condition = "aniversario = :data and id = :id";
     $criteria->params = array(':data' => $data, ':id' => Yii::app()->user->id);
     $aniversariantes = Contato::model()->findAll($criteria);
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', array('aniversariantes' => $aniversariantes));
 }
Exemplo n.º 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Contato::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * JSON Test
  */
 public function actionJson()
 {
     $this->layout = false;
     header('Content-type: application/json');
     $criteria = new CDbCriteria();
     //$criteria->select = array('nome');
     $criteria->order = 'nome';
     $criteria->limit = 20;
     if (isset($_GET['q'])) {
         $term = CHtml::encode($_GET['q']);
         $criteria->addCondition("nome ILIKE '%{$term}%'", 'AND');
     }
     $pessoas = Pessoa::model()->findAll($criteria);
     $tokens = PessoaToken::model()->findAll($criteria);
     $contatos = Contato::model()->findAll($criteria);
     $results = array();
     foreach ($pessoas as $p) {
         $results[$p->nome] = array('name' => $p->nome, 'id' => $p->cod_pessoa);
     }
     foreach ($tokens as $p) {
         $results[$p->nome] = array('name' => $p->nome, 'id' => $p->cod_token);
     }
     foreach ($contatos as $p) {
         $results[$p->nome] = array('name' => $p->nome, 'id' => $p->cod_contato);
     }
     //echo json_encode($results);
     $arr = array();
     foreach ($results as $r) {
         $arr[] = $r;
     }
     echo json_encode($arr);
     Yii::app()->end();
 }