public function actionStatistics() { $churchcnt = Church::model()->count(); $rschcnt = ChurchSupplies::model()->count(); $usercnt = AppUsers::model()->count(); $this->render('statistics', array('churchcnt' => $churchcnt, 'rsccnt' => $rschcnt, 'usercnt' => $usercnt)); }
public function loadModel($id) { $model = AppUsers::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
//array que ir� receber os sados selecionados $selected_category = array(); //para cada plataforma foreach ($model->appUsers as $cat) { array_push($selected_category, $cat->id); } ?> <div class="group-div"> <div> <?php echo TbHtml::label($model->getAttributeLabel('appUsers'), 'AppUsers'); ?> <p> <div class="portlet-content"> <?php echo TbHtml::CheckBoxList('AppUsers', $selected_category, CHtml::listData(AppUsers::model()->findAll(), 'id', 'name'), array('template' => '{input} {label}')); ?> <?php echo $form->error($model, 'appUsers'); ?> </div> </p> </div> <?php echo CHtml::link(CHtml::encode('Remove'), array('appUsers/delete', 'id' => $model->id), array('submit' => array('appUsers/delete', 'id' => $model->id), 'class' => 'delete btn btn-danger', 'confirm' => 'This will remove the image. Are you sure?')); ?> </div> </div></div>*/ </div></div></div></div>
/** * 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(); $userId = Yii::app()->user->id; //$userLevel = Users::model()->level; // $sql = AppUsers::model ()->findBySql ( 'SELECT id_users from app_users WHERE id_users ='.$userId ); // $sql = 'SELECT level from users WHERE id ='.$userId ; /* $connection=Yii::app()->db; $sql = 'SELECT id_users FROM app_users WHERE id_users ='.$userId; $command=$connection->createCommand($sql); $tenta=$command->query();*/ // $modelApp = AppUsers::model()->findB(array('id_users'=>$userId)); // var_dump($modelApp); // $criteria->compare('app_users.id_users', $this->id_users, true); // $posts= AppUsers::model()->findAllBySql("select id_app from app_users where id_users = ".$userId); // $criteria->addCondition(array("condtion"=>"id_users = $userId")); // $criteria->addInCondition('id',$value); $results = AppUsers::model()->findAll('id_users=:v', array(':v' => $userId)); $values = array(); foreach ($results as $r) { $values[] = $r->id_app; } $criteria->addInCondition('id', $values); // $criteria->addCondition(array("condtion"=>"$userId = id_users"), 'OR'); $criteria->compare('id', $this->id); $criteria->compare('name', $this->name, true); $criteria->compare('description', $this->description, true); $criteria->compare('developer', $this->developer, true); //$criteria->compare('id_users',$this->id_users); return new CActiveDataProvider($this, array('criteria' => $criteria)); }