/** * Signs user up. * * @return User|null the saved model or null if saving fails * @param $isAdmin true|false * can create Simple Manager or Admin */ public function signup($isAdmin = false) { if ($this->validate()) { $user = new User(); $user->firmname = $this->firmname; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); if ($user->save()) { if ($isAdmin) { $ssid = $user->id; $user->ssid = $ssid; $user->update(); // set's up Defaults for Admin NewUserSetup::AdminSetUp($ssid); } else { $user->ssid = helper::getSsid(); $user->update(); } return $user; } } else { return null; } }
public function rules() { return [[['password', 'email', 'title'], 'required', 'on' => self::SCENARIO_NEW], [['email', 'title'], 'required', 'on' => self::SCENARIO_EDIT], ['password', 'string', 'min' => Yii::$app->params['passLength']], ['password_repeat', 'compare', 'compareAttribute' => 'password', 'message' => Yii::t('app', "Passwords don't match")], [['ssid'], 'default', 'value' => helper::getSsid()], [['ssid', 'shop_id'], 'integer'], [['title'], 'string', 'max' => 100], [['description'], 'string', 'max' => 250], 'emailPattern' => ['email', 'email'], 'emailLength' => ['email', 'string', 'max' => 255], 'emailUniqueEdit' => ['email', function ($attribute) { if (User::findByEmail($this->email)) { $this->addError($attribute, $this->email . Yii::t('app', 'Email already exist')); } }, 'when' => function () { $user = User::findByEmail($this->email); if (!empty((array) $user)) { return Yii::$app->user->id != $user->id; // do not check for current user (my email) } }, 'on' => self::SCENARIO_EDIT], 'emailUniqueNew' => ['email', function ($attribute, $params) { $user = User::findByEmail($this->{$attribute}); if (!empty((array) $user)) { $this->addError($attribute, Yii::t('app', 'Email already exist')); } }, 'on' => self::SCENARIO_NEW], 'emailTrim' => ['email', 'trim'], 'oldPassCheck' => ['password_old', function ($attribute) { $user = User::findIdentity($this->id); if (!empty((array) $user)) { if ($user->validatePassword($this->password_old)) { $this->addError($attribute, Yii::t('app', 'Password Do not match')); } } }, 'on' => self::SCENARIO_EDIT]]; }
public function actionWellcome() { if (Yii::$app->user->isGuest) { return $this->render('/user/thankYou'); } else { // $this->layout = 'shop'; // custom layout for logged users $model = helper::getSsid(); return $this->render('wellcome', ['model' => $model]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Merchandise::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; } $query->andFilterWhere(['id' => $this->id, 'ssid' => helper::getSsid(), 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'producer', $this->producer]); return $dataProvider; }
public function tree() { $arrIN = array(); // Model to array $arr = array(); $query = CatProd::find()->where(['ssid' => helper::getSsid()])->orderBy('title')->all(); // builds internall array foreach ($query as $item) { $arrIN[] = array('key' => $item->id, 'parent' => $item->self_id, 'title' => $item->title, 'folder' => true, 'href' => '#', 'target' => '_self'); } foreach ($arrIN as $a) { $arr[$a['parent']][] = $a; } $tree = self::createTree($arr, $arr[0]); return $tree; }
public static function getFirmName() { if (Yii::$app->session->get('firmname') == null) { $userObj = User::findOne(['id' => helper::getSsid()]); if (!empty((array) $userObj)) { $firmname = $userObj->firmname; } else { $firmname = null; } if ($firmname == null) { \Yii::getLogger()->log("Firm name not found !", Logger::LEVEL_ERROR); //echo "Firm name not found !"; } else { Yii::$app->session->set('firmname', $firmname); } } else { $firmname = Yii::$app->session->get('firmname'); } return $firmname; }
public static function getShopList() { //$models = Shop::find()->asArray()->andWhere(['ssid'=>helper::getSsid()]); $models = Shop::findAll(['ssid' => helper::getSsid()]); return ArrayHelper::map($models, 'id', 'title'); }
/** * @inheritdoc */ public function rules() { return [[['cat_id', 'warranty', 'serialno', 'type', 'units', 'ssid', 'shopID', 'manID', 'status', 'created_at', 'updated_at'], 'integer'], [['curs', 'price', 'buy', 'quantity', 'min_quantity'], 'number'], [['ssid'], 'default', 'value' => helper::getSsid()], [['producer'], 'string', 'max' => 150], [['title'], 'string', 'max' => 200], [['barcode'], 'string', 'max' => 50]]; }
/** * @inheritdoc */ public function rules() { return [[['ssid'], 'default', 'value' => helper::getSsid()], [['ssid', 'shop_id', 'created_at', 'updated_at'], 'integer'], [['title'], 'string', 'max' => 100], [['description'], 'string', 'max' => 250]]; }
/** * @inheritdoc */ public function rules() { return [[['self_id', 'ssid', 'shopID', 'manID', 'status', 'created_at', 'updated_at'], 'integer'], [['fixedMarkup', 'percentMarkup'], 'number'], [['ssid'], 'default', 'value' => helper::getSsid()], [['shopID'], 'default', 'value' => helper::showShopID()], [['manID'], 'default', 'value' => Yii::$app->user->id], [['self_id'], 'default', 'value' => '0'], [['title'], 'string', 'max' => 200], [['title'], 'required']]; }
/** * Logs out the current user. * * @return mixed */ public function actionLogout() { Yii::$app->user->logout(); helper::logout(); return $this->goHome(); }
echo $content; ?> </div> </div> <footer class="footer"> <div class="container"> <p class="pull-left">© <?php echo Html::encode(Yii::$app->name); ?> <?php echo date('Y'); ?> </p> <p class="pull-right"><?php if (!Yii::$app->user->isGuest) { print Html::encode(\frontend\models\helper::getFirmName()); } ?> </p> </div> </footer> <?php $this->endBody(); ?> </body> </html> <?php $this->endPage();
?> <div class="manager-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('app', 'Create Manager'), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'title', 'label' => Yii::t('app', 'Title'), 'format' => 'html', 'value' => function ($data) { return Html::a($data->title, ['managersettings/view?id=' . $data->id]); }], 'description', 'ssid', ['attribute' => 'shop_id', 'label' => Yii::t('app/foruser', 'Shop'), 'format' => 'text', 'content' => function ($model) { return Html::a(\frontend\models\helper::getShopName($model->shop_id), ['shopsettings/view?id=' . $model->shop_id]); }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <p> <?php echo Html::a(Yii::t('app', 'Create Manager'), ['create'], ['class' => 'btn btn-success']); ?> </p> </div>