public function actionDelSessionTrainee()
 {
     $listTrainee = Yii::app()->session->get('listTrainee') ? json_decode(Yii::app()->session->get('listTrainee'), true) : array();
     $id = (isset($_POST['id']) and !empty($_POST['id'])) ? $_POST['id'] : NULL;
     $team_leader_id = (isset($_POST['team_leader_id']) and !empty($_POST['team_leader_id'])) ? $_POST['team_leader_id'] : NULL;
     if (!empty($id)) {
         unset($listTrainee[$id]);
         Yii::app()->session->add('listTrainee', json_encode($listTrainee));
         if (!empty($team_leader_id)) {
             $comm = Yii::app()->db->createCommand();
             $comm->delete('pls_training_team', 'team_leader_id=' . $team_leader_id . ' AND trainee_id=' . $id);
             $model = AUser::model()->find('id=' . $team_leader_id);
             //$model->trainee_count = count($listTrainee);
             $model->save();
         }
         echo 'true';
     } else {
         echo 'false';
     }
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return AUser the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = AUser::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
 public function run()
 {
     /*
             $params = array();
             $criteria = new CDbCriteria;
             $criteria->select = array('id,username,fullname,phone,address,status');
             if (isset($this->username) AND $this->username != '') {
                 $keyword = addcslashes($this->username, '%_');
                 $criteria->addCondition('username LIKE :keyword OR email LIKE :keyword OR fullname LIKE :keyword OR address LIKE :keyword');
                 $params[':keyword'] = "%$keyword%";
             }
             if (isset($this->group_id) AND $this->group_id != '') {
                 $criteria->addCondition('user_group_idd='.$this->group_id);
             }
             if (isset($this->course_id) AND $this->course_id != '') {
     
             }
             $criteria->order = 'status';
             $criteria->params = $params;
             $total = WUser::model()->count($criteria);
             $criteria->limit = $this->limit;
             $criteria->offset = $offset;
             $data = WUser::model()->findAll($criteria);
             if(!empty($data)){
                 $data = CJSON::decode(CJSON::encode($data));
             }
             $pages = new CPagination($total);
             $pages->pageSize = $this->limit;
             $pages->applyLimit($criteria);*/
     $where = '';
     if (isset($this->username) and $this->username != '') {
         $where .= ' AND (username LIKE "%' . $this->username . '%" OR email LIKE "%' . $this->username . '%" OR fullname LIKE "%' . $this->username . '%")';
     }
     if (isset($this->company) and $this->company != '') {
         $where .= ' AND (company LIKE "%' . $this->company . '%")';
     }
     if (isset($this->group_id) and $this->group_id != '') {
         $where .= ' AND user_group_id=' . $this->group_id;
     }
     $arrID = AUser::getIDTrainee();
     //echo implode(',', $arrID);
     if (isset($arrID) and !empty($arrID)) {
         $total = count(AUser::model()->findAll('id is NOT NULL and id NOT IN (' . implode(',', $arrID) . ') ' . $where));
     } else {
         $total = count(AUser::model()->findAll('id is NOT NULL ' . $where));
     }
     //echo $total;exit();
     $db = Yii::app()->db;
     $comm = $db->createCommand()->select('COUNT(*)')->from('pls_user t');
     if (isset($arrID) and !empty($arrID)) {
         $comm = $comm->where('t.id is NOT NULL and t.id NOT IN (' . implode(',', $arrID) . ') ' . $where);
     } else {
         $comm = $comm->where('id is NOT NULL ' . $where);
     }
     //$total = $comm->queryScalar();
     $comm->reset();
     if (isset($arrID) and !empty($arrID)) {
         $comm = $db->createCommand()->select('
                     t.*,
                 ')->from('pls_user t')->where('t.id is NOT NULL and t.id NOT IN (' . implode(',', $arrID) . ') ' . $where)->order('t.username ASC');
     } else {
         $comm = $db->createCommand()->select('
                     t.*,
                 ')->from('pls_user t')->where('t.id is NOT NULL ' . $where)->order('t.username ASC');
     }
     $comm->limit = $this->limit;
     $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1;
     $offset = $this->limit * ($page - 1);
     $comm->offset = $offset;
     $data = $comm->queryAll();
     $pages = new CPagination($total);
     $pages->pageSize = $this->limit;
     $this->render($this->view, array('data' => $data, 'pages' => $pages));
 }
Esempio n. 4
0
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return Route the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Esempio n. 5
0
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title"><?php 
echo Yii::t('web/home', 'Thêm học viên vào Team');
?>
</h4>
            </div>
            <!--form search-->
            <div class="modal-body" >
                <label class="sr-only"><?php 
echo Yii::t('web/home', 'Search');
?>
</label>
                <input type="text" id="trainee_username" class="form-control" placeholder="Username Or Fullname Or Email" style="width: 600px;float: left;">
                <?php 
echo Chtml::dropDownList('dataListCompany', 'id', Chtml::listData(AUser::model()->findAll('company is NOT NULL GROUP BY company'), "company", "company"), array('empty' => Yii::t('web/home', 'Select a Company'), 'style' => 'width:215px;float:left;margin-left:10px', 'class' => 'form-control'));
?>
                <button type="button" onclick="return loadTraineeOption();" class="btn btn-success" style="margin-left: 10px; float: left;"><?php 
echo Yii::t('web/home', 'Search');
?>
</button>
                <div id="bodyTraineeList" style="float: left;width: 100%; margin-top: 10px;"></div>
                <div class="clear"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success btn-sm" onclick="return addMutilTrainee();"><?php 
echo Yii::t('web/home', 'titleBoxAddTraineeButtonAdd');
?>
</button>
                <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal" ><?php 
echo Yii::t('web/home', 'titleBoxAddTraineeButtonClose');