public function actionEdituser()
 {
     $req = Yii::$app->request;
     //创建一个请求对象
     $form = new UserForm();
     $form->setScenario('update');
     $id = trim($req->get('id'));
     if (!is_numeric($id) || $id == 0) {
         $this->redirect(Variable::$userMange_url);
         return;
     }
     //修改
     if ($form->load($req->post()) && $form->validate()) {
         $isSuccess = (new User())->updateCusetomer($id, $form->realName, $form->nickName, $form->password, $form->email, $form->mobile, $form->userType, $form->userStatus, $form->frozenReason, $form->comeFrom);
         if ($isSuccess) {
             $form->addError('', '资料更新成功');
         } else {
             $form->addError('', '资料更新失败');
         }
     }
     $userModel = User::findOne($id);
     $form->realName = $userModel->realName;
     $form->nickName = $userModel->nickName;
     $form->password = $userModel->password;
     $form->email = $userModel->email;
     $form->mobile = $userModel->mobile;
     $form->userType = $userModel->userType;
     $form->userStatus = $userModel->userStatus;
     $form->frozenReason = $userModel->frozenReason;
     $form->comeFrom = $userModel->comeFrom;
     return $this->render(Variable::$editUser_view, ['model' => $form, 'userModel' => $userModel]);
 }
 public function actionPassword()
 {
     $model = User::findOne(Yii::$app->user->id);
     $data = Yii::$app->request->post('User');
     if (count($data)) {
         if (isset($data['password'])) {
             if ($model->validateName($data['username'])) {
                 if ($model->validatePassword($data['password_old']) && $model->validateName($data['username_old'])) {
                     $model->setAttributes($data);
                     $model->setPassword($model->password);
                     if ($model->save()) {
                         Yii::$app->session->setFlash('success', '密码修改成功');
                     } else {
                         Yii::$app->session->setFlash('danger', '密码修改失败');
                     }
                 } else {
                     Yii::$app->session->setFlash('danger', '原密码有误, 请输入正确的原密码');
                 }
             } else {
                 Yii::$app->session->setFlash('danger', '用户名已存在请重试');
             }
         }
     }
     $result['model'] = $model;
     return $this->render('password', $result);
 }
 public function actionSave()
 {
     $this->_setJSONFormat(Yii::$app);
     $request = Yii::$app->request;
     $data = $request->post();
     $code = '1';
     if (!empty($data['_id'])) {
         $product = Product::findOne($data['_id']['$id']);
         $data['updatedAt'] = new \MongoDate();
         $code = '2';
     }
     if (empty($product)) {
         $product = new Product();
         $accessToken = Token::getToken();
         $user = User::findOne(['_id' => $accessToken->userId]);
         $data['accountId'] = $this->getAccountId();
         $data['creator'] = $user->name;
         $data['createdAt'] = new \MongoDate();
         $data['isDeleted'] = false;
     }
     if (!empty($product->accountId)) {
         unset($data['accountId']);
     }
     $product->attributes = $data;
     $product->save();
     return ['code' => $code];
 }
示例#4
0
 public function cekOldpassword($attribute)
 {
     $user = User::findOne(['id' => $this->id]);
     if ($user->password != sha1($this->salt . $this->oldpass)) {
         $this->addError($attribute, "Password yang Anda masukkan tidak sama dengan password saat ini");
     }
 }
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
 public function actionUserList($id = 0)
 {
     if ($id) {
         return User::findOne($id)->username;
     } else {
         return $this->_list(new User(), 'user-list');
     }
 }
示例#7
0
 /**
  * 获取用户对象
  */
 public function getUser()
 {
     if ($this->getIsNewRecord()) {
         return [];
     }
     $data = User::findOne($this->getAttribute('uid'));
     return $data;
 }
示例#8
0
文件: User.php 项目: Griff19/it_base
 public function getParent($id)
 {
     $usr = User::findOne(['id' => $id]);
     $cust = Customers::findOne(['customer_name' => $usr->fullname]);
     //$usr = User::findOne(['id' => $cust->user_id]);
     //var_dump($cust);
     //die;
     return $cust->typeprices_id;
 }
 public function findBusqueda()
 {
     $data = $this->find();
     $resultado = [];
     foreach ($data as $ruta) {
         $resultado[$ruta->id] = ['id' => $ruta->id, 'dia' => $ruta->dia, 'esActivo' => $ruta->esActivo, 'user' => User::findOne($ruta->id_usuario)->username];
     }
     return $resultado;
 }
示例#10
0
 public static function saveImportedCookbooks($datas, $accountId)
 {
     $results = [];
     $accessToken = Token::getToken();
     $userId = $accessToken->userId;
     $user = User::findOne(['_id' => $userId]);
     for ($i = 0; $i < sizeof($datas); $i++) {
         $results[] = self::_saveSingleCookbook($datas[$i], $user, $accountId);
     }
     return $results;
 }
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $comerciosOrdenados = $model->getComerciosOrdenados();
     $usuario = User::findOne($model->id_usuario);
     $comercios = [];
     $datosGrillaPasos = [];
     $datosGrillaPasos[0] = ['orden' => 0, 'tipo' => Yii::t('core', 'User'), 'nombre' => $usuario->username, 'direccion' => $usuario->direccion, 'id_ruta_diaria' => $model->id, "id_comercio" => ''];
     $i = 0;
     foreach ($comerciosOrdenados as $comercio) {
         $datosGrillaPasos[$i + 1] = ['orden' => $i + 1, 'tipo' => Yii::t('core', 'Store'), 'nombre' => $comercio->nombre, 'direccion' => $comercio->direccion, 'id_ruta_diaria' => $model->id, "id_comercio" => $comercio->id];
         $i++;
     }
     $requestRuta = json_encode(sysconfigs::getRutaRequestParaMostrar($usuario, $comerciosOrdenados));
     return $this->render('view', ['model' => $this->findModel($id), 'requestRuta' => $requestRuta, 'datosGrillaPasos' => $datosGrillaPasos]);
 }
 /**
  * Creates a new Manager model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Manager();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $user_id = Yii::$app->request->post('user_id');
         $userModel = User::findOne($user_id);
         if ($userModel) {
             $model->created_at = time();
             $model->updated_at = time();
             $model->user_id = $userModel->id;
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     return $this->render('create', ['model' => $model]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RutaDiaria::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $user = User::findOne(['id' => $this->id_usuario]);
     $query->andFilterWhere(['id' => $this->id, 'fecha' => $this->fecha]);
     if ($this->id_usuario != null) {
         $query->andFilterWhere(['id_usuario' => $user != null ? $user->id : 0]);
     }
     return $dataProvider;
 }
 public function actionSave()
 {
     $accountId = $this->getAccountId();
     $adminId = $this->getParams("id");
     $admin = User::findOne($adminId);
     if ($admin == null) {
         return ['code' => 1209, 'msg' => 'not login'];
     }
     $name = $this->getParams('name', '');
     if ($name == '') {
         return ['code' => 1202, 'msg' => 'Name is required.'];
     }
     $category = $this->getParams('category', '');
     if ($category == '') {
         return ['code' => 1202, 'msg' => 'Category is required.'];
     }
     $radio = $this->getParams('radio', true);
     $cookingtypeId = $this->getParams('cookingtypeId', '');
     $cookingType = null;
     if ($cookingtypeId != '') {
         $cookingType = CookingType::findOne($cookingtypeId);
         if ($cookingType == null) {
             return ['code' => 1204, 'msg' => 'cooking type not found.'];
         } else {
             $cookingTypes = CookingType::find()->where(['category' => $cookingType->name])->all();
             for ($i = 0; $i < count($cookingTypes); $i++) {
                 $cookingTypes[$i]->category = $name;
                 $cookingTypes[$i]->save();
             }
         }
     } else {
         $cookingType = new CookingType();
     }
     $cookingType->name = $name;
     $cookingType->category = $category;
     $cookingType->operator = $admin['name'];
     $cookingType->radio = $radio . '';
     $cookingType->accountId = $accountId;
     $cookingType->save();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['code' => 200, 'msg' => 'save success'];
 }
 public function actionSave()
 {
     $this->delete();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $request = Yii::$app->request;
     $adminId = $request->post("id");
     $admin = User::findOne($adminId);
     if ($admin == null) {
         return ['code' => 1209, 'msg' => 'not login'];
     }
     $accountId = $this->getAccountId();
     $startDate = MongodbUtil::msTimetamp2MongoDate($request->post("startDate", ''));
     $endDate = MongodbUtil::msTimetamp2MongoDate($request->post("endDate", ''));
     $tags = $request->post("tags", '');
     $startDateOrder = MongodbUtil::msTimetamp2MongoDate($request->post("startDateOrder", ''));
     $endDateOrder = MongodbUtil::msTimetamp2MongoDate($request->post("endDateOrder", ''));
     $tagsOrder = $request->post("tagsOrder");
     $WestPromotionActivity = new WestPromotionActivity();
     $WestPromotionActivity->accountId = $accountId;
     $WestPromotionActivity->name = "registrationSetting";
     $WestPromotionActivity->startDate = $startDate;
     $WestPromotionActivity->endDate = $endDate;
     $WestPromotionActivity->tags = $tags;
     $result = $WestPromotionActivity->save();
     if ($result <= 0) {
         return ['msg' => 'failed', 'code' => '500'];
     }
     $WestPromotionActivity = new WestPromotionActivity();
     $WestPromotionActivity->accountId = $accountId;
     $WestPromotionActivity->name = "orderSetting";
     $WestPromotionActivity->startDate = $startDateOrder;
     $WestPromotionActivity->endDate = $endDateOrder;
     $WestPromotionActivity->tags = $tagsOrder;
     $result = $WestPromotionActivity->save();
     if ($result > 0) {
         return ['msg' => 'success', 'code' => '200'];
     } else {
         return ['msg' => 'failed', 'code' => '500'];
     }
 }
示例#16
0
 /**
  * Update user password
  *
  * <b>Request Type</b>: PUT<br/><br/>
  * <b>Request Endpoint</b>:http://{server-domain}/common/user<br/><br/>
  * <b>Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used for billing account to update password.
  * <br/><br/>
  *
  * <b>Request Params</b>:<br/>
  *     id: int, the user id, required<br/>
  *     currentPwd: string, the user currentPwd, required<br/>
  *     newPwd: string, the user newPwd, required<br/>
  *     newPwdC: string, the user newPwdC, required<br/>
  *     <br/><br/>
  *
  * <b>Response Params:</b><br/>
  *     ack: integer, mark the update result, 0 means update successfully, 1 means update fail<br/>
  *     data: array, json array to describe the user updated<br/>
  *     <br/><br/>
  *
  * <b>Request Example:</b><br/>
  * <pre>
  * {
  *     "id" : "547eaf82e9c2fb52478b4567,
  *     "currentPwd" : "6c302344ab2117ee4ce52b7d8952c689",
  *     "newPwd" : "6c302344ab2117ee4ce52b7d8952c689",
  *     "newPwdC" : "6c302344ab2117ee4ce52b7d8952c689"
  * }
  * </pre>
  * <br/><br/>
  *
  * <b>Response Example</b>:<br/>
  * <pre>
  * {
  *    'ack' : 1,
  *    'data': {"msg": "success", "user": {password:"******"}}
  * }
  * </pre>
  */
 public function actionUpdatepassword()
 {
     $params = $this->getParams();
     if (empty($params['id'])) {
         throw new BadRequestHttpException("Parameters missing");
     }
     // validate if the userid is correct
     $user = User::findOne(['_id' => new \MongoId($params['id'])]);
     if (empty($user)) {
         throw new BadRequestHttpException("Incorrect userid");
     }
     if (empty($params['currentPwd']) || $params['currentPwd'] === md5('')) {
         throw new InvalidParameterException(['old-password' => Yii::t('common', 'required_filed')]);
     }
     // validate if the current password is correct
     if (!$user->validatePassword($params['currentPwd'])) {
         throw new InvalidParameterException(['old-password' => Yii::t('common', 'common_user_currentpwd_error')]);
     }
     if (empty($params['newPwd']) || $params['newPwd'] === md5('')) {
         throw new InvalidParameterException(['new-password' => Yii::t('common', 'required_filed')]);
     }
     if (empty($params['newPwdC']) || $params['newPwdC'] === md5('')) {
         throw new InvalidParameterException(['confirm-password' => Yii::t('common', 'required_filed')]);
     }
     // check if the two passwords match
     if ($params['newPwd'] !== $params['newPwdC']) {
         throw new InvalidParameterException(['new-password' => Yii::t('common', 'common_user_currentpwd_error')]);
     }
     // check the new password is same as the current password
     if ($params['currentPwd'] == $params['newPwd']) {
         throw new InvalidParameterException(['new-password' => Yii::t('common', 'newpwd_equals_old_error')]);
     }
     // update the user information
     $user->password = User::encryptPassword($params['newPwd'], $user->salt);
     if (!$user->save()) {
         throw new ServerErrorHttpException("Save user failed!");
     }
     return ['result' => 'success'];
 }
示例#17
0
 public function actionUpdate($id)
 {
     $id = new \MongoId($id);
     $user = User::findOne(['_id' => $id]);
     $user->load($this->getParams(), '');
     if ($user->save() === false && !$user->hasErrors()) {
         throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
     }
     //update the language information in token
     Token::updateAll(['language' => $user->language]);
     return $user;
 }
示例#18
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемой страницы не существует.');
     }
 }
 public function actionDelete()
 {
     $accountId = $this->getAccountId();
     $adminId = $request = Yii::$app->request->post("id");
     $admin = User::findOne($adminId);
     if ($admin == null) {
         return ['message' => 'not login'];
     }
     $cookbookId = Yii::$app->request->post('cookbookId');
     if ($cookbookId != null) {
         Cookbook::deleteAll(['_id' => $cookbookId]);
         return ['message' => 'success'];
     }
     return $cookbookId;
 }
示例#20
0
 public function beforeSave($insert)
 {
     $this->user_name = User::findOne($this->user_id)['username'];
     return parent::beforeSave($insert);
 }
示例#21
0
 public static function getUserById($id)
 {
     if ($id != NULL) {
         $username = User::findOne($id);
         return $username->username;
     }
     return "No Asignado";
 }
示例#22
0
 /**
  * 删除用户
  */
 public static function delUser($id)
 {
     return User::findOne($id)->delete();
 }
示例#23
0
?>
                        </td>
                    </tr>
                    <tr>
                        <td><strong>IP при регистрации:</strong></td>
                        <td colspan="3">
                            <?php 
echo $user->registration_ip;
?>
                        </td>
                    </tr>
                    <tr>
                        <td><strong>Пригласил:</strong></td>
                        <td colspan="3">
                            <?php 
echo $user->referral ? User::findOne($user->referral)->username : "";
?>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>

<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title">Вклады</h3>
    </div>
    <div class="panel-body">
        <?php 
示例#24
0
 /**
  * Validate code when activate user
  * @param $code, String.
  * @return String, error code or userId
  *
  * @author Sara Zhang
  */
 public static function validateCode($code, $isDeleted = true)
 {
     if (empty($code)) {
         return self::LINK_INVALID;
     }
     $validation = Validation::findOne(['code' => $code]);
     if (empty($validation)) {
         return self::LINK_INVALID;
     }
     if (empty($validation->expire) || MongodbUtil::isExpired($validation->expire)) {
         return self::LINK_EXPIRED;
     }
     $userId = $validation->userId;
     if ($validation->toValidateAccount) {
         $user = User::findOne(['_id' => $userId]);
         $attributes = ['status' => Account::STATUS_ACTIVATED, 'trialStartAt' => new \MongoDate(), 'trialEndAt' => new \MongoDate(strtotime("+30 day"))];
         Account::updateAll($attributes, ['_id' => $user->accountId]);
     }
     if ($isDeleted) {
         $validation->delete();
     }
     return $userId;
 }
示例#25
0
 public function deleteUser($userId)
 {
     $model = User::findOne($userId);
     if (!$model) {
         return false;
     }
     if ($model->delete()) {
         return true;
     }
     return false;
 }
示例#26
0
            <input type="submit" onclick="query('<?php 
echo Yii::$app->urlManager->createUrl(['userlog/index']);
?>
')" value=" 搜索 " class="button">

        </form>

    </div>

    <?php 
Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'showFooter' => true, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'name' => 'id', 'footer' => Html::button('批量删除', ['class' => 'btn btn-danger', 'onclick' => 'delAll()']), 'options' => ['width' => 50]], ['attribute' => 'uid', 'label' => '管理员ID'], ['header' => Html::a('管理员账号', 'javascript:;'), 'content' => function ($model) {
    return User::findOne($model->uid)->username;
}], ['attribute' => 'action_ip', 'label' => '操作IP'], 'model', 'model_id', 'remark', 'add_time:datetime', ['class' => 'yii\\grid\\ActionColumn', 'header' => Html::a('操作', 'javascript:void(0);'), 'template' => '{delete}']]]);
?>
    <?php 
Pjax::end();
?>

</div>


<?php 
$this->beginBlock('js_end');
?>

function delAll()
{
 /** Get remove My  Booth  */
 public function actionRemovemybooth()
 {
     $boothschedule = new BoothSchedules();
     $connection = Yii::$app->db;
     if (Yii::$app->request->post()) {
         $value = \Yii::$app->request->post();
         if (!empty($value['attendee_id']) && !empty($value['booth_id'])) {
             $userid = User::findOne(['id' => $value['attendee_id']]);
             if ($userid) {
                 $model = BoothSchedules::deleteAll('booth_id = :booth_id AND attendee_id = :attendee_id', [':booth_id' => $value['booth_id'], ':attendee_id' => $userid->attendee_id]);
                 if ($model) {
                     echo "Booth deleted successfully";
                 } else {
                     echo "error";
                 }
             } else {
                 echo "User is not exist in Contect List";
             }
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function getUserDetails($username)
 {
     $user = User::findOne(['username' => $username, 'blocked_at' => NULL]);
     // Update last login flag
     //$user->last_login = new Expression('NOW()');
     //$user->save(true, ["last_login"]);
     $userData = ['id' => $user->id, 'user_id' => $user->id, 'username' => $user->username, 'email' => $user->email, 'registration_ip' => $user->registration_ip];
     return $userData;
 }
示例#29
0
 public function actionUpdate()
 {
     $request = Yii::$app->request;
     $adminId = $request->post("id");
     $admin = User::findOne($adminId);
     if ($admin == null) {
         return ['code' => 1209, 'msg' => 'not login'];
     }
     $id = $request->post("_id");
     $name = $request->post("name", '');
     $mobile = $request->post("mobile", '');
     $restaurantName = $request->post("restaurantName", '');
     $address = $request->post("address", '');
     $businessForm = $request->post("businessForm", '');
     $product = $request->post("product");
     $resultCondition = ['_id' => new \MongoId($id)];
     $order = Order::findOne($resultCondition);
     $order->name = $name;
     $order->mobile = $mobile;
     $order->restaurantName = $restaurantName;
     $order->address = $address;
     $order->businessForm = $businessForm;
     $order->product = $product;
     $result = $order->save();
     // LogUtil::error(date('Y-m-d h:i:s') . ' $result: ' . $result);
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     if ($result > 0) {
         return ['msg' => 'success', 'code' => '200'];
     } else {
         return ['msg' => 'failed', 'code' => '500'];
     }
 }
示例#30
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = User::findOne($id)) !== null) {
         /*
          * Asign auth_assignment for current user
          */
         $array = ArrayHelper::map(\backend\models\AuthAssignment::find()->where(['user_id' => $id])->all(), 'user_id', 'item_name');
         if ($array) {
             $model->auth_assignment = $array[$id];
         }
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }