public function run() { $this->filter(); $this->buildRange(); $this->buildData(); $overall = $this->buildOverAllStatistics(); $datetime_range = ArrayHelper::getValue($this->from_time, 'date') . '/' . ArrayHelper::getValue($this->to_time, 'date'); $this->model->datetime_range = $datetime_range; echo $this->render('member-report', ['model' => $this->model, 'overall_statistics' => $overall, 'gridview' => $this->buildGridview()]); $this->registerAssets(); }
public static function customButton($options = [], $defOptions = []) { extract(ArrayHelper::remove($options, ['text', 'url'])); if (is_null($text)) { $text = $defOptions['text']; } $options['class'] = (isset($options['class']) ? $options['class'] . ' ' : '') . $defOptions['class']; if (!array_key_exists('glyphicon', $options)) { $options['glyphicon'] = $defOptions['glyphicon']; } return empty($url) ? static::button($text, $options) : static::a($text, $url, $options); }
public function search($params, $pageSize = 20) { $query = self::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) and $this->validate())) { return $dataProvider; } if (!empty($this->keyword)) { $query->orFilterWhere(['like', 'education_name', $this->keyword])->orFilterWhere(['like', 'phone_number', $this->keyword])->orFilterWhere(['like', 'social_facebook', $this->keyword])->orFilterWhere(['like', 'social_twitter', $this->keyword])->orFilterWhere(['like', 'latest_company', $this->keyword])->orFilterWhere(['like', 'latest_position', $this->keyword])->orFilterWhere(['like', 'education_study', $this->keyword]); //get user's _ids by keyword from user document $this->_ids = array_keys(ArrayHelper::map(User::find()->orFilterWhere(['like', 'email', $this->keyword])->orFilterWhere(['like', 'fullname', $this->keyword])->orFilterWhere(['like', 'displayname', $this->keyword])->orFilterWhere(['like', 'first_name', $this->keyword])->orFilterWhere(['like', 'last_name', $this->keyword])->orFilterWhere(['like', 'phone', $this->keyword])->asArray()->all(), '_id', '_id')); } if ($this->search_mode == 'AND') { if (!empty($this->_ids)) { $query->where(['in', '_id', $this->_ids]); } if (!empty($this->nationality)) { $query->andFilterWhere(['=', 'nationality', $this->nationality]); } if (!empty($this->location)) { $query->andFilterWhere(['=', 'location', $this->location]); } if (!empty($this->functions)) { $query->andFilterWhere(['in', 'functions', $this->functions]); } if (!empty($this->industries)) { $query->andFilterWhere(['industries' => [$this->industries]]); } } else { if (!empty($this->_ids)) { $query->orFilterWhere(['in', '_id', $this->_ids]); } if (!empty($this->nationality)) { $query->orFilterWhere(['=', 'nationality', $this->nationality]); } if (!empty($this->location)) { $query->orFilterWhere(['=', 'location', $this->location]); } if (!empty($this->functions)) { $query->orFilterWhere(['in', 'functions', $this->functions]); } if (!empty($this->industries)) { $query->orFilterWhere(['industries' => [$this->industries]]); } } if (\app\helpers\ArrayHelper::getValue($params, 'sort') == NULL) { $query->orderBy('candidate_id DESC'); } return $dataProvider; }
public function search($params, $pageSize = 20) { $query = self::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) and $this->validate())) { return $dataProvider; } $query->andFilterWhere(['create_time' => $this->create_time, 'target' => $this->target, 'status' => $this->status, 'about_me' => $this->about_me, 'about_you' => $this->about_you, 'category' => $this->category, 'creator' => $this->creator]); $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'title', $this->title]); if (\app\helpers\ArrayHelper::getValue($params, 'sort') == NULL) { $query->orderBy('create_time DESC'); } return $dataProvider; }
public function search($params, $pageSize = 20) { $query = self::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); if (!($this->load($params) and $this->validate())) { return $dataProvider; } // $query->andFilterWhere([ // 'model' => $this->model, // ]); $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'file_path', $this->file_path])->andFilterWhere(['like', 'model_namespace', $this->model_namespace]); if (\app\helpers\ArrayHelper::getValue($params, 'sort') == NULL) { $query->orderBy('create_time DESC'); } return $dataProvider; }
public function actionFixpermission() { $auth = Yii::$app->authManager; $itemPermission = $auth->getPermissions(); $actionList = AuthActionList::find()->all(); $actionList = \app\helpers\ArrayHelper::map($actionList, '_id', 'is_permission'); if ($itemPermission) { foreach ($itemPermission as $item) { $updatePermission = AuthActionList::findOne($item->name); if ($updatePermission and $updatePermission->is_permission !== "1") { $updatePermission->is_permission = "1"; $updatePermission->save(); } } } $this->redirect(['/account/rbac/actionlist']); }
public function run() { $output = ''; if (!isset($this->options['class']) or empty($this->options['class'])) { $this->options['class'] = 'form-control'; } if (!isset($this->options['id']) or empty($this->options['id'])) { $this->options['id'] = 'locationCity'; } if (!isset($this->options['onchange']) or empty($this->options['onchange'])) { $this->options['onchange'] = 'selected_region(this.value)'; } $cities = ArrayHelper::map(LocationCity::find()->orderBy('title ASC')->all(), '_id', 'title'); $output = Html::activeDropDownList($this->model, $this->attribute, $cities, $this->options); $output .= '<div id="district"></div>'; echo $output; }
/** * Renders the widget. */ public function run() { if (!isset($this->options['class']) or empty($this->options['class'])) { $this->options['class'] = 'form-control'; } $name = Html::getInputName($this->model, $this->attribute); $value = Html::getAttributeValue($this->model, $this->attribute); echo Html::beginTag('div', ['class' => 'row']); echo Html::beginTag('div', ['class' => 'col-lg-4']); echo Html::textInput($name . '[1]', ArrayHelper::getValue($value, '1', ''), $this->options); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-lg-4']); echo Html::textInput($name . '[2]', ArrayHelper::getValue($value, '2', ''), $this->options); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-lg-4']); echo Html::textInput($name . '[3]', ArrayHelper::getValue($value, '3', ''), $this->options); echo Html::endTag('div'); echo Html::endTag('div'); }
public function actionIndex() { Yii::$app->view->title = Yii::t('common', 'Setting'); $module = Yii::$app->request->get('module', ''); if (!empty($module)) { $label = Yii::t($module, ucfirst($module)); Yii::$app->view->params['breadcrumbs'][] = ['label' => $label, 'url' => ['/' . $module . '/default']]; } $models = Setting::find()->where(['module' => Yii::$app->request->get('module', 'common')])->all(); if (Yii::$app->request->post()) { foreach ($models as $model) { $settingPosted = Yii::$app->request->post('setting'); $model->value = ArrayHelper::getValue($settingPosted, (string) $model->_id, ''); $model->save(); } } Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title; return $this->render('index', ['models' => $models]); }
public function search($params, $pageSize = 20) { $query = self::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]); $this->load($params); if (!$this->validate()) { return $dataProvider; } // condition here $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'role', $this->role])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'days', $this->days])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'sort', $this->sort])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'creator', $this->creator])->andFilterWhere(['like', 'create_time', $this->create_time])->andFilterWhere(['like', 'editor', $this->editor])->andFilterWhere(['like', 'update_time', $this->update_time]); if (!empty($this->create_time)) { list($minDate, $maxDate) = explode(' to ', $this->create_time); $min_date = new \MongoDate(strtotime($minDate . ' 00:00:00')); $max_date = new \MongoDate(strtotime($maxDate . ' 23:59:59')); $query = \app\helpers\LetHelper::addFilter($query, 'create_time', [$min_date, $max_date], 'between'); } if (\app\helpers\ArrayHelper::getValue($params, 'sort') == NULL) { $query->orderBy('create_time DESC'); } return $dataProvider; }
/** * Ham lay ra gia tri cua option setting * @param string $module ten module * @param string $key config key * @return string tra ve gia tri cua config key */ public static function getValue($module, $key) { $model = self::findOne(['module' => $module, 'key' => $key]); if (!$model) { $model = new self(); $model->module = $module; $model->type = 'text'; $model->key = $key; $model->value = ''; $model->save(); } $attributes = array_keys($model->getAttributes()); $value = in_array('value', $attributes) ? $model->value : ''; if ($model->type == 'text') { return $value; } elseif (in_array($model->type, ['checkbox', 'radio', 'dropdown']) and property_exists($model, 'items')) { return \app\helpers\ArrayHelper::getValue($model->items, $model->value, ''); } else { return ''; } }
/** * Renders the widget. */ public function run() { if (!isset($this->options['class']) or empty($this->options['class'])) { $this->options['class'] = 'form-control m-t-xs'; } $name = Html::getInputName($this->model, $this->attribute); $id = Html::getInputId($this->model, $this->attribute); $value = Html::getAttributeValue($this->model, $this->attribute); $interestList = ArrayHelper::getValue(UserExtra::$options, 'interest', []); foreach ($interestList as $key => $label) { $this->options['id'] = $id . '-' . $key; echo Html::beginTag('div', ['class' => 'm-b-md']); echo Html::beginTag('label', ['class' => 'control-label', 'for' => $this->options['id']]); echo Yii::t('account', $label); echo Html::endTag('label'); echo Html::beginTag('div'); echo Html::textInput($name . '[' . $key . ']', ArrayHelper::getValue($value, $key, ''), $this->options); echo Html::endTag('div'); echo Html::endTag('div'); } }
protected function renderPanel() { if (!$this->bootstrap || !is_array($this->panel) || empty($this->panel)) { return; } $type = 'panel-' . ArrayHelper::getValue($this->panel, 'type', 'default'); $heading = ArrayHelper::getValue($this->panel, 'heading', ''); $footer = ArrayHelper::getValue($this->panel, 'footer', ''); $before = ArrayHelper::getValue($this->panel, 'before', ''); $after = ArrayHelper::getValue($this->panel, 'after', ''); $headingOptions = ArrayHelper::getValue($this->panel, 'headingOptions', []); $footerOptions = ArrayHelper::getValue($this->panel, 'footerOptions', []); $beforeOptions = ArrayHelper::getValue($this->panel, 'beforeOptions', []); $afterOptions = ArrayHelper::getValue($this->panel, 'afterOptions', []); $panelHeading = ''; $panelBefore = ''; $panelAfter = ''; $panelFooter = ''; if ($heading !== false) { Html::addCssClass($headingOptions, 'ibox-title'); $content = strtr($this->panelHeadingTemplate, ['{heading}' => $heading]); $panelHeading = Html::tag('div', $content, $headingOptions); } if ($footer !== false) { Html::addCssClass($footerOptions, 'ibox-title'); $content = strtr($this->panelFooterTemplate, ['{footer}' => $footer]); $panelFooter = Html::tag('div', $content, $footerOptions); } if ($before !== false) { Html::addCssClass($beforeOptions, 'kv-panel-before'); $content = strtr($this->panelBeforeTemplate, ['{before}' => $before]); $panelBefore = Html::tag('div', $content, $beforeOptions); } if ($after !== false) { Html::addCssClass($afterOptions, 'kv-panel-after'); $content = strtr($this->panelAfterTemplate, ['{after}' => $after]); $panelAfter = Html::tag('div', $content, $afterOptions); } $this->layout = strtr($this->panelTemplate, ['{panelHeading}' => $panelHeading, '{type}' => $type, '{panelFooter}' => $panelFooter, '{panelBefore}' => $panelBefore, '{panelAfter}' => $panelAfter]); }
/** * Initializes the widget options. * This method sets the default values for various options. */ protected function initOptions() { if (empty($this->content) && $this->skipOnEmpty == false) { throw new InvalidConfigException("No content for widget data"); } elseif (empty($this->content)) { return false; } $itemsCount = count($this->content); $colorStep = round(100 / $itemsCount); ArrayHelper::multisort($this->content, 'value', SORT_DESC); foreach ($this->content as $key => $item) { if (empty($this->content[$key]['color'])) { $nextColor = $this->adjustBrightness(isset($nextColor) ? $nextColor : $this->baseColor, $colorStep); $this->content[$key]['color'] = $nextColor; $this->content[$key]['label'] = $this->content[$key]['label']; } } $this->pieOptions['data']['content'] = $this->content; $this->pieOptions['header']['title']['text'] = $this->title; $this->pieOptions = ArrayHelper::merge($this->pieOptions, $this->options); $this->registerAssets(); }
/** * Gui nhung tin nhan cua status = 0 * Use: php yii sendsms/daily */ public function actionDaily() { $stats = []; $limit = 100; for ($i = 0; $i < 10000; $i++) { $model = Sms::find()->where(['status' => 0])->limit($limit)->all(); if ($model) { foreach ($model as $sms) { $sendSms = new \app\modules\sms\helpers\SmsBrandname(); $sendSms->model = $sms; $sended = $sendSms->sent(); if (property_exists($sended, 'status')) { $stats[$sended->status] = ArrayHelper::getValue($stats, $sended->status, 0) + 1; } } } else { break; } } echo "Thong ke gui sms:\n"; foreach ($stats as $status => $value) { echo $status . ': ' . $value . "\n"; } }
<?php use yii\helpers\Url; use yii\helpers\Html; use app\helpers\ArrayHelper; use app\components\GridView; ?> <?php echo GridView::widget(['panel' => ['tableOptions' => ['id' => 'listJobs']], 'pjax' => true, 'dataProvider' => $dataProvider, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')])]], 'columns' => ['title', ['attribute' => 'annual_salary_from', 'value' => function ($model, $key, $index, $widget) { return Html::encode(ArrayHelper::getValue(\app\modules\job\models\JobSalary::getOptions(), ArrayHelper::getValue($model, 'annual_salary_from')) . ' to ' . ArrayHelper::getValue(\app\modules\job\models\JobSalary::getOptions(), ArrayHelper::getValue($model, 'annual_salary_to'))); }], ['attribute' => 'company_name', 'value' => function ($model, $key, $index, $widget) { return Html::encode($model->company_name); }], ['attribute' => 'updated_time', 'value' => function ($model, $key, $index, $widget) { return Yii::$app->formatter->asDate($model->updated_time->sec); }], ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view}', 'buttons' => ['view' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['job-detail', 'id' => $model->_id], ['data-pjax' => '0', 'title' => Yii::t('yii', 'View')]); }]]], 'responsive' => true, 'hover' => true]);
/** * Form ids assigned to this user * * @return array */ public function getAssignedFormIds() { /** @var \app\models\User $user */ $user = Yii::$app->user->identity; $userForms = $user->getUserForms()->asArray()->all(); $userForms = ArrayHelper::getColumn($userForms, 'form_id'); return $userForms; }
$time .= ",{$nbsp}"; } $time .= "{$nedelya}{$nbsp}неделя"; } $caption = $prefixNo . ' ' . Val::asText($temaRecord, 'nazvanie'); if ($time) { $caption .= " ({$time})"; } ?> <h4><?php echo $caption; ?> </h4> <?php if (ArrayHelper::getValue($temaRecord, ['formaKontrolyaVTechenieKursaRel', 'nazvanie'])) { ?> <div class="kontrol-block"> <div class="inner"> <?php echo Val::asText($temaRecord, 'formaKontrolyaVTechenieKursaRel', 'nazvanie'); ?> </div> </div> <?php } ?> <?php if ($temaRecord->umkRel) { ?>
private function getPrepIds($rows) { $prepIds = ArrayHelper::getColumn($rows, 'prep_id'); return array_unique($prepIds); }
}); }); }); JS; $this->registerJs($js); function hasFilter() { foreach (Yii::$app->request->get() as $k => $v) { if ($k !== 'page' && $v) { return true; } } return false; } $this->title = ArrayHelper::getValue([TipKursa::PK => 'Курсы повышения квалификации', TipKursa::PP => 'Курсы профессиональной переподготовки', TipKursa::PO => 'Курсы профессионального обучения'], $tip); ?> <h2><?php echo $this->title; ?> </h2> <div class="spisok-kursov-filter"> <div class="switch-container"><a class="switch" href="#">Фильтры</a></div> <?php echo Html::beginTag('div', ['class' => 'form-container', 'style' => hasFilter() ? null : 'display:none']); ?> <?php $form = ActiveForm::begin(['method' => 'get', 'action' => [Yii::$app->controller->id . '/' . Yii::$app->controller->action->id]]); ?>
<div class="form-group"> <div class="col-sm-12"> <input type="reset" id="btn-reset" value="Reset" class="button"> <input type="submit" id="bnt-save" value="Save" class="button button-primary" name="btn_create"> </div> </div> <?php ActiveForm::end(); ?> </div> <div role="tabpanel" class="tab-pane active" id="all-project"> <div class="table-responsive"> <?php echo GridView::widget(['panel' => ['tableOptions' => ['id' => 'listDefault']], 'pjax' => true, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'toolbar' => [['content' => Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['projects'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')])], '{toggleData}'], 'columns' => [['class' => 'kartik\\grid\\CheckboxColumn'], ['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'status', 'label' => Yii::t('job', 'Satus'), 'value' => function ($model, $key, $index, $widget) { return ArrayHelper::getValue(\app\modules\job\models\Project::getStatusOptions(), ArrayHelper::getValue($model, 'status')); }, 'contentOptions' => ['style' => 'min-width: 150px;'], 'filterType' => GridView::FILTER_SELECT2, 'filter' => \app\modules\job\models\Project::getStatusOptions(true)], ['attribute' => 'name', 'label' => Yii::t('job', 'Name')], ['attribute' => 'description', 'label' => Yii::t('job', 'Description'), 'format' => 'raw'], ['attribute' => 'created_time', 'label' => Yii::t('job', 'Date'), 'filterType' => GridView::FILTER_DATE_RANGE, 'format' => 'raw', 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'Y-m-d', 'separator' => ' to ', 'opens' => 'left'], 'presetDropdown' => true, 'hideInput' => true, 'convertFormat' => true], 'value' => function ($model, $key, $index, $widget) { //return date('Y-m-d h:i:s', $model->created_time->sec); return Yii::$app->formatter->asDate(date('Y-m-d h:i:s', $model->created_time->sec), 'long'); }], ['class' => '\\kartik\\grid\\ActionColumn']], 'responsive' => true, 'hover' => true]); ?> </div> </div> </div> </div> <div class="col-xs-12 col-sm-3 col-sm-pull-9 col-sidebar"> <ul class="nav nav-pills nav-stacked" role="tablist"> <li role="presentation"> <a href="#add-new-project" aria-controls="add-new-project" role="tab" data-toggle="tab">Create A New Project</a> </li> <li role="presentation" class="active">
/** * Gets all a combined map of all the settings. * * @return array */ public function getSettings() { $settings = static::find()->where(['status' => true])->asArray()->all(); return array_merge_recursive(ArrayHelper::map($settings, 'key', 'value', 'category'), ArrayHelper::map($settings, 'key', 'type', 'category')); }
<?php use yii\bootstrap\Html; use app\components\DetailView; use app\helpers\ArrayHelper; use app\modules\job\models\Job; ?> <!-- MAIN --> <main id="main" class="main-container"> <!-- SECTION 1 --> <div class="section section-1"> <div class="container"> <div class="row jobs-posted"> <div class="section-title section-title-style-2"> <h2 class="title"> <?php echo Yii::t('job', "Job Informations"); ?> </h2> </div> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['code', ['attribute' => 'country_id', 'value' => ArrayHelper::getValue(\app\modules\job\models\JobLocation::getOptions(), ArrayHelper::getValue($model, 'country_id'))], ['attribute' => 'category_ids', 'value' => $model->getCategoryNames(), 'format' => 'raw'], 'city_name', ['attribute' => 'annual_salary_from', 'value' => ArrayHelper::getValue(\app\modules\job\models\JobSalary::getOptions(), ArrayHelper::getValue($model, 'annual_salary_from'))], ['attribute' => 'annual_salary_to', 'value' => ArrayHelper::getValue(\app\modules\job\models\JobSalary::getOptions(), ArrayHelper::getValue($model, 'annual_salary_to'))], ['attribute' => 'functions', 'value' => $model->getFunctionNames(), 'format' => 'raw'], ['attribute' => 'work_type', 'value' => ArrayHelper::getValue(app\modules\job\models\JobWorkType::getOptions(), ArrayHelper::getValue($model, 'work_type'))], ['attribute' => 'industry', 'value' => $model->getIndustryNames(), 'format' => 'raw'], 'company_name', 'company_description:html', 'description:html', 'seo_url', 'seo_title', 'seo_desc', ['attribute' => 'created_time', 'format' => ['datetime', 'php:m/d/Y H:i:s'], 'value' => $model->created_time->sec], ['attribute' => 'updated_time', 'format' => ['datetime', 'php:m/d/Y H:i:s'], 'value' => $model->updated_time->sec], ['attribute' => 'satus', 'value' => ArrayHelper::getValue(Job::getStatusOptions(), ArrayHelper::getValue($model, 'status'))], 'hits']]); ?> </div> </div> </div> <!-- # SECTION 1 --> </main> <!-- # MAIN -->
/** * Update Template model * * @param $id * @return array * @throws \yii\db\Exception */ public function actionUpdateTemplate($id) { if (Yii::$app->request->isAjax) { // Response fornat Yii::$app->response->format = Response::FORMAT_JSON; // Extract FormBuilder data from post request $post = Yii::$app->request->post(); $data = ['FormBuilder' => Json::decode($post['FormBuilder'], true)]; $formBuilder = new FormBuilder(); $success = false; $message = ''; $code = 0; // Form Builder Validation if ($formBuilder->load($data) && $formBuilder->validate()) { // Save data in single transaction $transaction = Template::getDb()->beginTransaction(); try { // Parse html form fields to array $formDOM = new FormDOM(); // If two elements has same id, throw a exception $formDOM->loadHTML(ArrayHelper::getValue($data, 'FormBuilder.html')); // Get Template Model $templateModel = $this->findTemplateModel($id); // Post Template $postTemplate = ['Template' => ['name' => ArrayHelper::getValue($data, 'FormBuilder.data.settings.name'), 'builder' => Json::htmlEncode(ArrayHelper::getValue($data, 'FormBuilder.data')), 'html' => Html::encode(ArrayHelper::getValue($data, 'FormBuilder.html'))]]; if (!$templateModel->load($postTemplate) || !$templateModel->save()) { throw new Exception(Yii::t('app', 'Error saving data'), 1); } $transaction->commit(); // Change success flag and message $success = true; $message = Yii::t("app", "The template has been successfully updated"); } catch (Exception $e) { // Rolls back the transaction $transaction->rollBack(); // Rethrow the exception // throw $e; $message = $e->getMessage(); $code = $e->getCode(); } } // Response to Client $res = array('success' => $success, 'id' => $id, 'action' => 'update', 'message' => $message, 'code' => $code); return $res; } return ''; }
public function getUserOptions() { return ArrayHelper::map(User::find()->where(['status' => '1'])->andWhere(['NOT', '_id', Yii::$app->user->id])->orderBy('email')->all(), '_id', 'email'); }
/** * Updates an existing Form model (except id). * Updates an existing FormData model (only data field). * Updates an existing FormConfirmation model (except id & form_id). * Updates an existing FormEmail model (except id & form_id). * If update is successful, the browser will be redirected to the 'index' page. * * @param int|null $id * @return string|\yii\web\Response * @throws NotFoundHttpException * @throws \Exception * @throws \yii\db\Exception */ public function actionSettings($id = null) { /** @var \app\models\Form $formModel */ $formModel = $this->findFormModel($id); $formDataModel = $formModel->formData; $formConfirmationModel = $formModel->formConfirmation; $formEmailModel = $formModel->formEmail; $formUIModel = $formModel->ui; $postData = Yii::$app->request->post(); if ($formModel->load($postData) && $formConfirmationModel->load($postData) && $formEmailModel->load($postData) && $formUIModel->load($postData) && Model::validateMultiple([$formModel, $formConfirmationModel, $formEmailModel, $formUIModel])) { // Save data in single transaction $transaction = Form::getDb()->beginTransaction(); try { // Save Form Model if (!$formModel->save()) { throw new \Exception(Yii::t("app", "Error saving Form Model")); } // Save data field in FormData model if (isset($postData['Form']['name'])) { // Convert JSON Data of Form Data Model to PHP Array /** @var \app\components\JsonToArrayBehavior $builderField */ $builderField = $formDataModel->behaviors['builderField']; // Set form name by json key path. If fail, throw \ArrayAccessException $builderField->setSafeValue('settings.name', $postData['Form']['name']); // Save to DB $builderField->save(); // If fail, throw \Exception } // Save FormConfirmation Model if (!$formConfirmationModel->save()) { throw new \Exception(Yii::t("app", "Error saving Form Confirmation Model")); } // Save FormEmail Model if (!$formEmailModel->save()) { throw new \Exception(Yii::t("app", "Error saving Form Email Model")); } // Save FormUI Model if (!$formUIModel->save()) { throw new \Exception(Yii::t("app", "Error saving Form UI Model")); } $transaction->commit(); Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The form settings have been successfully updated')); return $this->redirect(['index']); } catch (\Exception $e) { // Rolls back the transaction $transaction->rollBack(); // Rethrow the exception throw $e; } } else { // Select id & name of all themes in the system $themes = Theme::find()->select(['id', 'name'])->asArray()->all(); $themes = ArrayHelper::map($themes, 'id', 'name'); return $this->render('settings', ['formModel' => $formModel, 'formDataModel' => $formDataModel, 'formConfirmationModel' => $formConfirmationModel, 'formEmailModel' => $formEmailModel, 'formUIModel' => $formUIModel, 'themes' => $themes]); } }
<?php /** * Created by JetBrains PhpStorm. * User: Александр * Date: 27.05.15 * Time: 23:57 * To change this template use File | Settings | File Templates. */ $this->beginBlock('catalogNav'); $ids = []; $id = $catalog_category ? $catalog_category->id : null; if ($catalog_category->route) { foreach ($catalog_category->route as $r) { $ids[] = $r->id; } } $tree = \app\helpers\ArrayHelper::tree(\yii\helpers\ArrayHelper::toArray(\app\modules\catalog\models\CatalogCategories::find()->orderBy('ordering')->all()), 'id', 'parent_id', 'childs'); echo frontend\widgets\Tree::widget(['data' => $tree, 'childAttribute' => 'childs', 'groupTag' => 'div', 'groupOptions' => function ($data, $level, $parent) use($ids) { return $level === 0 ? ['class' => 'list-group'] : (in_array($parent, $ids) ? ['class' => 'submenu panel-collapse collapse in'] : ['class' => 'submenu panel-collapse collapse']); }, 'elementTag' => 'a', 'elementOptions' => function ($data, $level, $parent, $widgetId) use($id) { return ['href' => count($data['childs']) ? '#' . $widgetId . '-navi-' . $data['id'] : \yii\helpers\Url::to(['categories/view', 'id' => $data['id']]), 'data-toggle' => count($data['childs']) ? 'collapse' : '', 'class' => 'list-group-item' . ($id == $data['id'] ? ' active' : '')]; }, 'value' => function ($data, $level) { return ($level == 0 ? mb_strtoupper($data['title'], 'UTF-8') : $data['title']) . (count($data['childs']) != 0 ? ' ' . \yii\helpers\Html::tag('b', '', ['class' => 'caret']) : ''); }]); $this->endBlock();
<td><?php echo Html::encode($model->title); ?> </td> </tr> <tr> <td colspan="2">Job Code</td> <td><?php echo Html::encode($model->code); ?> </td> </tr> <tr> <td colspan="2">Location</td> <td><?php echo ArrayHelper::getValue(\app\modules\job\models\JobLocation::getOptions(), ArrayHelper::getValue($model, 'country_id')); ?> </td> </tr> <tr> <td colspan="2">Jobs Industry</td> <td><?php echo $model->getIndustryNames(); ?> </td> </tr> <tr> <td colspan="2">Company Info</td> <td> <?php if (UserJob::canView()) {
$this->registerCss($style); $roles = Yii::$app->authManager->getRolesByUser(Yii::$app->user->id); ?> <div ng-app="rukovoditel" ng-controller="RukovoditelKomissiiController as rk"> <div class="inline-block"> <div class="inline-block"> <?php if (isset($roles[\app\enums2\Rol::SOTRUDNIK_OTDELA_ATTESTACII])) { echo Html::label('Комиссия', 'komissiya', []); echo Html::dropDownList('komissiya', null, \app\entities\AttestacionnayaKomissiya::find()->formattedAll(\app\entities\EntityQuery::DROP_DOWN, 'nazvanie'), ['id' => 'komissiya', 'class' => 'form-control inline-block', 'ng-model' => "rk.komissiya"]); } else { //echo Html::input('hidden','komissiya',$komissiyaId,['id' => 'komissiya']); echo Html::label('Комиссия', 'komissiya', []); echo Html::dropDownList('komissiya', null, \app\helpers\ArrayHelper::map($komissiyaId, 'attestacionnaya_komissiya', 'attestacionnayaKomissiyaRel.nazvanie'), ['id' => 'komissiya', 'class' => 'form-control inline-block', 'ng-model' => "rk.komissiya"]); } ?> </div> <div class="inline-block"> <?php echo Html::label('Период прохождения аттестации', 'periods', []); ?> <?php echo Html::dropDownList('periods', null, $periods_for_dropdown, ['id' => 'periods', 'class' => 'form-control inline-block', 'ng-disabled' => 'rk.allUnfinished']); ?> </div> <div class="inline-block checkbox filter-block"> <label for="all_unfinished"> <input type="checkbox" id="all_unfinished" ng-change="s.toggleUnfinished()" ng-model="rk.allUnfinished"/>
/** * Ham tao cau dieu kien * @param object $query * @param string $attribute Ten attribute in collection * @param string|array $values Gia tri cua attribute * @param string|array $operator Dieu kien cua attribute va value: like, between, gt, gte, lt, lte * @return object $query */ public static function addFilter($query, $attribute, $values, $operator = null) { if ($operator == 'between' and isset($values[1])) { $where = [$attribute => ['$gte' => ArrayHelper::getValue($values, 0), '$lte' => ArrayHelper::getValue($values, 1)]]; } elseif (in_array($operator, ['gt', 'gte', 'lt', 'lte'])) { $where = [$attribute => ['$' . $operator => $values]]; } elseif ($operator == 'like') { $where = [$attribute => ['$regex' => $values]]; } else { $where = [$attribute => $values]; } // if (empty($operator)){// Neu operators rong thi attribute = values // $query->andFilterWhere([ // $attribute => $values // ]); // } else if (!is_array($values) && !(is_array($operator))){ // $query->andFilterWhere([ // $attribute => [ // $operator => $values, // ] // ]); // } else { // // Tao dieu kien theo mang value va operators // $where = []; // foreach ($values as $key => $value) { // $operator = (isset($operators[$key])) ? $operators[$key] : ''; // $where[$operator] = $value; // } // // $query->andFilterWhere([ // $attribute => $where // ]); // } return $query->andFilterWhere($where); }