Click here for EduSec Demo EduSec Screenshots
Register | Login
Jul 8, 2013 03:09:30 PM by itsmeskm99@gmail.com

Hello, I have Bootstrap filter enabled but it does not seem to work. Here is my view

<?php $this->widget('bootstrap.widgets.BootGridView', array(
    'id'=>'user-grid',
    'dataProvider'=>$model->search(),
       // 'dataProvider'=>$dataprovider,

    'filter'=>$model,
    'columns'=>array(
        'user_id',
        array('name'=>'user_type',
                    'value'=>'User::getType($data->user_type)',

                       ),
        'username',
        array('header'=>'Name',
                    'type'=>'raw',
                    'value'=>  'CHtml::link($data->firstname." ".$data->lastname, array("view", "id"=>$data->id))',
                    'filter' => true,
        ),
                array('name' => 'status',
            'type' => 'raw',
            'value' => '$data->status == 1 ? "Active" : CHtml::link("In Active", "javascript:void(0);", array("id" => "active_" . $data->id, "onClick"=>"js:activate($data->id)"))'
        ),
        /*
        'email',
        'dob',
        'profession',
        'hobby',
        'height',
        'weight',
        'weight_taken_on',
        'login_attempt',

        'registration_date',
        */
        array(
            'class'=>'bootstrap.widgets.BootButtonColumn',
        ),
    ),
)); ?>

But not working

Jul 9, 2013 04:25:35 AM by ravib@rudrasoftech.com

Hello, I am not geeting your problem. In which field, your filter is not working.?? Please put your model code also and try to explain your problem..

Jul 16, 2013 09:42:30 AM by itsmeskm99@gmail.com

SORRY FOR LATE RESPONSE, this is my user model. None of the search field works.

<?php

/**
 * This is the model class for table "tbl_user".
 *
 * The followings are the available columns in table 'tbl_user':
 * @property string $id
 * @property string $user_id
 * @property integer $user_type
 * @property integer $username
 * @property string $password
 * @property string $firstname
 * @property string $lastname
 * @property string $dob
 * @property string $profession
 * @property string $hobby
 * @property string $height
 * @property double $weight
 * @property string $weight_taken_on
 * @property integer $login_attempt
 * @property integer $status
 * @property string $registration_date
 */
class User extends CActiveRecord {

    public $password_real, $repeat_password,$new_password;


    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return User the static model class
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'tbl_user';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('user_id, username, firstname, lastname, dob, profession, hobby, email', 'required', 'on'=>'signup, profile'),
            array('user_type, password_real, repeat_password,', 'required', 'on' => 'signup'),
            array('repeat_password', 'compare', 'compareAttribute' => 'password_real', 'on' => 'signup, changePassword', 'message' => 'Password must be repeated exactly.'),
            array('username', 'unique'),
            array('password_real, repeat_password', 'required', 'on'=>'changePassword'),
            //array('repeat_password', 'compare', 'compareAttribute' => 'new_password', 'on' => 'changePassword', 'message' => 'Password must be repeated exactly.'),
            array('user_id, username, firstname, lastname, dob, profession, hobby, email, status, user_type', 'required', 'on'=>'admin_update'),
            array('password_real', 'strongPassword', 'on'=> array('signup', 'changePassword')),
            array('user_type, user_id, login_attempt, status', 'numerical', 'integerOnly' => true),
            array('weight', 'numerical'),
            array('user_id', 'length', 'min' => 6, 'max' => 6),
            array('password, username', 'length', 'max' => 80),
            array('password', 'length', 'min' => 6),
            array('firstname, lastname', 'length', 'max' => 100),
            array('profession, hobby', 'length', 'max' => 255),
            array('height', 'length', 'max' => 20),
            array('programs_taken, weight_taken_on', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, user_id, user_type, username, password, firstname, lastname, dob, profession, hobby, height, weight, weight_taken_on, login_attempt, status, registration_date', 'safe', 'on' => 'search'),
        );
    }

    public function strongPassword($attribute){
        $d='/[0-9]/';  //numbers
        $c='/[A-Z]/'; //capital letter
        $s='/[._#$%&*@!~?]/'; // contain one symbol
        if(preg_match_all($d,$this->password_real, $o)<1)
            $this->addError($attribute, 'Password must contain at least one digit.');
        else if(preg_match_all($c,$this->password_real, $o)<1)
            $this->addError($attribute, 'Password must contain at least one uppercase letter.');
        else if(preg_match_all($s,$this->password_real, $o)<1)
            $this->addError($attribute, 'Password must contain at least one symbol among these (. _ # $ % & * @ ! ~ ?).');
        else if(strlen(trim($this->password_real))<6){
            $this->addError($attribute, 'Password must consist at least six letters.');
        }
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'countProject'=>array(self::STAT, 'Project', 'client_id', 'condition'=>'is_approved=1'),
            'projects'=> array(self::HAS_MANY, 'Project', 'project_id'),
            'ask_specialist'=> array(self::HAS_MANY, 'Askspecialist', 'specialist_id'),
            'client_program' => array(self::HAS_MANY, 'Askspecialist', 'program_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'id' => 'Id',
            'user_id' => 'PIN',
            'user_type' => 'User Type',
            'username' => 'Username',
            'password' => 'Password',
            'firstname' => 'Firstname',
            'lastname' => 'Lastname',
            'dob' => 'DOB',
            'profession' => 'Profession',
            'hobby' => 'Hobby',
            'height' => 'Height',
            'weight' => 'Weight',
            'weight_taken_on' => 'Weight Taken On',
            'login_attempt' => 'Login Attempt',
            'status' => 'Status',
            'registration_date' => 'Registration Date',
            'password_real' => 'Password',
            'repeat_password' => 'Repeat Password',
            'email' => 'Email Address',
            'new_password'=>'New Password'
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('id', $this->id, true);
        $criteria->compare('user_id', $this->user_id, true);
        $criteria->compare('user_type', $this->user_type);
        $criteria->compare('username', $this->username);
        $criteria->compare('password', $this->password, true);
        $criteria->compare('firstname', $this->firstname, true);
        $criteria->compare('lastname', $this->lastname, true);
        $criteria->compare('dob', $this->dob, true);
        $criteria->compare('profession', $this->profession, true);
        $criteria->compare('hobby', $this->hobby, true);
        $criteria->compare('height', $this->height, true);
        $criteria->compare('weight', $this->weight);
        $criteria->compare('weight_taken_on', $this->weight_taken_on, true);
        $criteria->compare('login_attempt', $this->login_attempt);
        $criteria->compare('status', $this->status);
        $criteria->compare('registration_date', $this->registration_date, true);
        //$criteria->order='id DESC';
        $criteria->condition='status!=2';
        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

    
    public function getFullname(){
        return $this->firstname.' '.$this->lastname;
    }

    /**
     * return array - client and advisor
     */
    public function getUserType() {
        return array(
            ""=>"Select",
            1 => 'Client',
            2 => 'Advisor',
            3 => 'Specialist');
    }
    public function calculateAge($date){
        $cur_year = date("Y", time());
        $input_year = date('Y', strtotime($date));
        return $cur_year-$input_year;
    }
    public function getConcatedname(){
        return $this->firstname.' '.$this->lastname;
    }

    /**
     * return all active advisor user
     */
    public function listAdvisors(){
        $models = User::model()->findAllByAttributes(array('status'=>1,'user_type'=>2));
        $lists =  CHtml::listData($models, 'id', 'concatedname');
        return $lists;

    }
    public function listSpecialists(){
        $models = User::model()->findAllByAttributes(array('status'=>1,'user_type'=>3));
        $lists =  CHtml::listData($models, 'id', 'concatedname');
        return $lists;

    }
    public function getActiveUserByType($type){
        return User::model()->findAllByAttributes(array('user_type'=>$type, 'status'=>'1'), array('order'=>'id ASC', 'limit'=>10));
    }
    public function getInActiveUser(){
        return User::model()->findAllByAttributes(array('status'=>'0'), array('order'=>'id ASC', 'limit'=>10));
    }
    public function clientWaitingSuggestion(){
        return Project::model()->findAllByAttributes(array('project_status'=>'0'), array('order'=>'id ASC', 'group'=>'client_id','limit'=>5));
    }

    /**
     * return type of user
     * return string
     */
    public function getType($user_type)
    {
        if($user_type == 1){
            return 'Client';
        }
        else if($user_type == 2){
            return "Advisor";
        }
        else if($user_type == 3)
            return "Specialist";
        else
            return 'Not set';
    }

}