Exemplo n.º 1
0
 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';
     }
 }
Exemplo n.º 2
0
 public function validate()
 {
     if ($this->user->isLogged()) {
         $this->user->logout();
         unset($this->session->data['token']);
     }
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('common/forgot_password');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->request->is_POST() && $this->_validateCaptcha()) {
         //generate password
         $password = AUser::generatePassword(8);
         $this->model_user_user->editUser($this->user_data['user_id'], array('password' => $password));
         $mail = new AMail($this->config);
         $mail->setTo($this->user_data['email']);
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setSender($this->config->get('config_owner'));
         $mail->setSubject(sprintf($this->language->get('reset_email_subject'), $this->config->get('store_name')));
         $mail->setHtml(sprintf($this->language->get('new_password_email_body'), $password));
         $mail->setText(sprintf($this->language->get('new_password_email_body'), $password));
         $mail->send();
         $this->redirect($this->html->getSecureURL('index/forgot_password/validate', '&mail=sent'));
     }
     $this->data['text_heading'] = $this->language->get('text_heading_reset');
     $this->data['login'] = $this->html->getSecureURL('index/login');
     if (isset($this->request->get['mail']) && $this->request->get['mail'] == 'sent') {
         $this->data['show_instructions'] = true;
         $this->data['text_instructions'] = $this->language->get('text_instructions_reset');
     } else {
         $this->data['error'] = $this->error;
         $this->data['action'] = $this->html->getSecureURL('index/forgot_password/validate', '&hash=' . $this->request->get['hash']);
         $this->data['update'] = '';
         $form = new AForm('ST');
         $form->setForm(array('form_name' => 'forgotFrm', 'update' => $this->data['update']));
         $this->data['form']['id'] = 'forgotFrm';
         $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'forgotFrm', 'action' => $this->data['action']));
         $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('text_please_confirm'), 'style' => 'button3'));
         $this->data['form']['fields']['username'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'username', 'value' => $this->request->post['username'], 'required' => true, 'placeholder' => $this->language->get('entry_username')));
         if ($this->config->get('config_recaptcha_site_key')) {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'recaptcha', 'name' => 'captcha', 'recaptcha_site_key' => $this->config->get('config_recaptcha_site_key'), 'language_code' => $this->language->getLanguageCode()));
         } else {
             $this->data['form']['fields']['captcha'] = $form->getFieldHtml(array('type' => 'captcha', 'name' => 'captcha', 'value' => $this->data['captcha'], 'required' => true, 'placeholder' => $this->language->get('entry_captcha')));
         }
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/index/forgot_password.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 /**
  * 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;
 }
Exemplo n.º 4
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));
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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');