diff --git a/common/models/Job.php b/common/models/Job.php index 94865d3..01e1ace 100755 --- a/common/models/Job.php +++ b/common/models/Job.php @@ -69,8 +69,6 @@ [ [ 'user_id', - 'total_count', - 'complete_count', 'current', ], 'integer', @@ -91,6 +89,22 @@ 'match', 'pattern' => '/^(?:https?:\/\/)?(?:w{3}\.)?'.preg_quote($_SERVER['HTTP_HOST']).'\/company\/\w+\/\d+$/i', ], + [ + [ + 'total_count', + 'complete_count', + ], + 'integer', + 'min' => 0, + ], + [ + [ + 'complete_count', + ], + 'compare', + 'compareAttribute' => 'total_count', + 'operator' => '<=', + ] ]; } diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php index 083ab3a..d94843e 100644 --- a/common/models/Portfolio.php +++ b/common/models/Portfolio.php @@ -70,7 +70,6 @@ [ 'name', 'preview', - 'link', 'city', 'cover' ], diff --git a/common/models/UserInfo.php b/common/models/UserInfo.php index 9b3f1f2..b2314a5 100755 --- a/common/models/UserInfo.php +++ b/common/models/UserInfo.php @@ -230,6 +230,9 @@ ], 'filter', 'filter' => function($value) { + if(empty($value)) { + return $value; + } if(!preg_match('/^https?:\/{2}.*$/', $value)) { $value = 'https://' . $value; } diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index e9e96b8..c57589b 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -234,8 +234,8 @@ $user_info->load($post); $user_info->save(); $job = [ ]; - for($i = 0; $i < count($post[ 'Job' ]); $i++) { - $job[ $i ] = new Job([ + foreach($post['Job'] as $index => $value) { + $job[$index] = new Job([ 'user_id' => \Yii::$app->user->getId(), 'current' => 0, ]); @@ -795,6 +795,9 @@ */ public function actionService() { + /** + * @var User $user + */ $user = \Yii::$app->user->identity; $user_info = $user->userInfo; if(empty( $user_info )) { diff --git a/frontend/controllers/PerformerController.php b/frontend/controllers/PerformerController.php index a570057..c059059 100755 --- a/frontend/controllers/PerformerController.php +++ b/frontend/controllers/PerformerController.php @@ -74,7 +74,15 @@ $phones = Fields::getData($user->id, $user->className(), 'phone'); $sites = Fields::getData($user->id, $user->className(), 'site'); $soft = implode(', ', ArrayHelper::getColumn(Fields::getData($user->id, $user->className(), 'soft'), 'soft')); - + $geography = $user->getPortfolios() + ->select([ + 'count' => 'COUNT(*)', + 'city' => 'city', + ]) + ->groupBy('city') + ->asArray() + ->indexBy('city') + ->column(); return $this->render('common', [ 'user' => $user, 'educations' => $educations, @@ -83,6 +91,7 @@ 'phones' => $phones, 'sites' => $sites, 'soft' => $soft, + 'geography' => $geography, ]); } @@ -324,8 +333,8 @@ public function beforeAction($action) { - if(!empty(\Yii::$app->request->get('type'))) { - $action->controller->view->params['type'] = \Yii::$app->request->get('type'); + if(!empty( \Yii::$app->request->get('type') )) { + $action->controller->view->params[ 'type' ] = \Yii::$app->request->get('type'); } return parent::beforeAction($action); } diff --git a/frontend/views/accounts/_job_form.php b/frontend/views/accounts/_job_form.php index b17364d..484948d 100755 --- a/frontend/views/accounts/_job_form.php +++ b/frontend/views/accounts/_job_form.php @@ -82,10 +82,10 @@ ]); ?>
- field($model, '[' . $index . ']complete_count') + field($model, '[' . $index . ']complete_count', [ 'enableClientValidation' => false ]) ->label('из них реализовано') ->textInput([ - 'class' => 'custom-input-2 custom-input-2-date', + 'class' => 'custom-input-2 custom-input-2-date no-client-validation', 'type' => 'number', ]); ?>
diff --git a/frontend/views/accounts/_portfolio_form.php b/frontend/views/accounts/_portfolio_form.php index 86ad81e..d18fdfe 100644 --- a/frontend/views/accounts/_portfolio_form.php +++ b/frontend/views/accounts/_portfolio_form.php @@ -20,6 +20,7 @@ use mihaildev\ckeditor\CKEditor; $this->title = 'Портфолио'; $this->params[ 'breadcrumbs' ][] = $this->title; + var_dump($portfolio->getErrors()); ?>
title ?>
diff --git a/frontend/views/accounts/employment.php b/frontend/views/accounts/employment.php index ae8254d..9c8c776 100755 --- a/frontend/views/accounts/employment.php +++ b/frontend/views/accounts/employment.php @@ -71,10 +71,10 @@ 'type' => 'number', ]); ?>
- field($current, '[0]complete_count') + field($current, '[0]complete_count', [ 'enableClientValidation' => false ]) ->label('из них реализовано') ->textInput([ - 'class' => 'custom-input-2 custom-input-2-date', + 'class' => 'custom-input-2 custom-input-2-date no-client-validation', 'type' => 'number', ]); ?>
@@ -173,10 +173,10 @@ 'type' => 'number', ]); ?>
- field($job_model, '[' . ( $index + 1 ) . ']complete_count') + field($job_model, '[' . ( $index + 1 ) . ']complete_count', [ 'enableClientValidation' => false ]) ->label('из них реализовано') ->textInput([ - 'class' => 'custom-input-2 custom-input-2-date', + 'class' => 'custom-input-2 custom-input-2-date no-client-validation', 'type' => 'number', ]); ?>
@@ -208,6 +208,9 @@ $( function() { + $(document).on('change', '.no-client-validation', function() { + $(this).parent().find('.help-block').hide(); + }); var regexp = /^[\w]+\[(\d+)\].*$/; var prevEmploy = $('.prev_job_inputs').length if(prevEmploy < 1) diff --git a/frontend/views/accounts/general.php b/frontend/views/accounts/general.php index aed0b32..7c7b0dc 100755 --- a/frontend/views/accounts/general.php +++ b/frontend/views/accounts/general.php @@ -97,7 +97,7 @@
- field($company_info, 'name', [ 'options' => [ 'class' => 'form-group company_info' ] ]) + field($company_info, 'name', [ 'options' => [ 'class' => 'form-group company_info' ], 'enableClientValidation' => false ]) ->textInput([ 'class' => 'custom-input-2' ]); ?>
diff --git a/frontend/views/accounts/service.php b/frontend/views/accounts/service.php index 5c9513f..56959da 100755 --- a/frontend/views/accounts/service.php +++ b/frontend/views/accounts/service.php @@ -104,6 +104,9 @@
+
field($user_info, 'geographies') @@ -127,6 +130,9 @@ ]); ?>
+
field($user_info, 'guarantee', [ diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index fcaa970..a47940a 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -56,7 +56,11 @@ AppAsset::register($this);
- user->identity->minImg(Yii::$app->user->identity->userInfo->image,48,48))?> + user->identity->userInfo->image)) { + echo Html::img(Yii::$app->user->identity->minImg(Yii::$app->user->identity->userInfo->image,48,48)); + } + ?>
Профиль
user->identity->email,['/accounts']) ?> diff --git a/frontend/views/performer/common.php b/frontend/views/performer/common.php index a69a9b9..30337ab 100755 --- a/frontend/views/performer/common.php +++ b/frontend/views/performer/common.php @@ -9,12 +9,23 @@ * @var array $developments * @var array $educations * @var array $courses + * @var int[] $geography */ $this->params[ 'user' ] = $user; $this->title = 'My Yii Application'; - $georgaphy = implode(',', array_filter(ArrayHelper::getColumn($user->portfolios, 'city'))); + $geographyString = ''; + + $first = 1; + foreach($geography as $city => $count) { + if(!$first) { + $geographyString .= ', '; + } + $geographyString .= $city . ' ('.$count.')'; + $first = 0; + } + unset($first); ?>
  • - География работ: + География работ:
  • sort->getAttributeOrders(); -$active_key = array_keys($sort_array)[0]; -$active_value = $sort_array[$active_key]; -$sort_name = (($active_value == 4)?'-':'').$active_key; - - - -$this->title = 'My Yii Application'; + use common\models\Vacancy; + use kartik\select2\Select2; + use yii\helpers\ArrayHelper; + use \yii\helpers\Html; + use yii\helpers\Url; + use yii\jui\SliderInput; + use yii\web\JsExpression; + use yii\widgets\ActiveForm; + use yii\widgets\LinkSorter; + use yii\widgets\ListView; + + /* @var $this yii\web\View */ + + $sort_array = $dataProvider->sort->getAttributeOrders(); + $active_key = array_keys($sort_array)[ 0 ]; + $active_value = $sort_array[ $active_key ]; + $sort_name = ( ( $active_value == 4 ) ? '-' : '' ) . $active_key; + + $this->title = 'My Yii Application'; ?>
    @@ -29,167 +27,165 @@ $this->title = 'My Yii Application';
    ['class'=>'search-work-form'],'action'=>[''], 'method'=>'get']); + $form = ActiveForm::begin([ + 'options' => [ 'class' => 'search-work-form' ], + 'action' => [ '' ], + 'method' => 'get', + ]); ?> - field($model, 'city') - ->widget(Select2::classname(), [ - 'options' => [ 'placeholder' => 'Выбор города ...' ], - 'pluginOptions' => [ - 'allowClear' => true, - 'minimumInputLength' => 3, - 'ajax' => [ - 'url' => \yii\helpers\Url::to([ 'site/city' ]), - 'dataType' => 'json', - 'data' => new JsExpression('function(params) { return {q:params.term}; }'), - ], - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), - 'templateResult' => new JsExpression('function(city) { return city.text; }'), - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), - ], - ]); ?> - - - field($model, 'specialization') - ->dropDownList($specialization, ['prompt' => 'Любая']); - ?> - - - field($model, 'type') - ->dropDownList(['1'=>'Частное лицо','2'=>'Компания'], ['prompt' => 'Любой']); - ?> - - - - field ($model, 'working_conditions') - ->checkboxList ( - [ - 'guarantee' => 'С гарантией', - 'contract' => 'С договором', - 'estimate' => 'Со сметой', - 'prepayment' => 'Без предоплаты' - ], - [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
    '; - $return .= ''; - $return .= ''; - $return .= '
    '; - return $return; - } - ] - ); - ?> + field($model, 'city') + ->widget(Select2::classname(), [ + 'options' => [ 'placeholder' => 'Выбор города ...' ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'ajax' => [ + 'url' => \yii\helpers\Url::to([ 'site/city' ]), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), + ], + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), + 'templateResult' => new JsExpression('function(city) { return city.text; }'), + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), + ], + ]); ?> + + + field($model, 'specialization') + ->dropDownList($specialization, [ 'prompt' => 'Любая' ]); ?> + + + field($model, 'type') + ->dropDownList([ + '1' => 'Частное лицо', + '2' => 'Компания', + ], [ 'prompt' => 'Любой' ]); ?> + + + + field($model, 'working_conditions') + ->checkboxList([ + 'guarantee' => 'С гарантией', + //'contract' => 'С договором', + //'estimate' => 'Со сметой', + 'prepayment' => 'Без предоплаты', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
    '; + $return .= ''; + $return .= ''; + $return .= '
    '; + return $return; + }, + ]); ?>
    field($model, 'rating', [ - 'template' => "{label}
    {$model->rating}

    {input}\n{hint}\n{error}", - 'labelOptions' => [ - 'class' => 'blocks-check-title', - ], - ]) - ->widget(SliderInput::className(), [ - 'clientOptions' => [ - 'min' => 0, - 'max' => 5, - 'step' => 0.5, + echo $form->field($model, 'rating', [ + 'template' => "{label}
    {$model->rating}

    {input}\n{hint}\n{error}", + 'labelOptions' => [ + 'class' => 'blocks-check-title', ], - 'clientEvents' => [ - 'slide' => "function( event, ui ) { + ]) + ->widget(SliderInput::className(), [ + 'clientOptions' => [ + 'min' => 0, + 'max' => 5, + 'step' => 0.5, + ], + 'clientEvents' => [ + 'slide' => "function( event, ui ) { $( '#{$form->id}-rating' ).text(ui.value); $('input[name=\"{$model->formName()}[rating]\"]').val(ui.value); }", - ], - ]); + ], + ]); ?>
    - - field($model, 'online', [ - 'options' => [ - 'class' => 'blocks-check-list-wrapp', - ], - 'template' => "
    {label}
    \n{input}\n{hint}\n{error}", - ]) - ->radioList([ - '' => 'Все', - 1 => 'Онлайн', - ], [ - 'item' => function($index, $label, $name, $checked, $value) use ($model) { - return "
    "; - }, - 'unselect' => NULL, - ]); - ?> - - - - field ($model, 'additional_parameters') - ->checkboxList ( - [ - 'with_portfolio' => 'Только с портфолио', - 'with_comments' => 'Только с отзывами', - 'only_free' => 'Только свободные', - ], - [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
    '; - $return .= ''; - $return .= ''; - $return .= '
    '; - return $return; - } - ] - ); - ?> + field($model, 'online', [ + 'options' => [ + 'class' => 'blocks-check-list-wrapp', + ], + 'template' => "
    {label}
    \n{input}\n{hint}\n{error}", + ]) + ->radioList([ + '' => 'Все', + 1 => 'Онлайн', + ], [ + 'item' => function($index, $label, $name, $checked, $value) use ($model) { + return "
    "; + }, + 'unselect' => NULL, + ]); ?> + + + + field($model, 'additional_parameters') + ->checkboxList([ + 'with_portfolio' => 'Только с портфолио', + 'with_comments' => 'Только с отзывами', + 'only_free' => 'Только свободные', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
    '; + $return .= ''; + $return .= ''; + $return .= '
    '; + return $return; + }, + ]); ?>
    - end(); - ?> + end(); + ?>
    Найти исполнителя
    -
    Проектанты готовые приступить к работе totalCount ?>
    +
    Проектанты готовые приступить к работе + totalCount ?>
    'get', 'action' => [''], 'options' => ['class' => 'search-worker-form']]); + $form2 = ActiveForm::begin([ + 'method' => 'get', + 'action' => [ '' ], + 'options' => [ 'class' => 'search-worker-form' ], + ]); ?> - field($model, 'search', ['options' => ['tag' => 'span']])->label(false)->textInput(['placeholder' => $model->getAttributeLabel('search')]);?> + field($model, 'search', [ 'options' => [ 'tag' => 'span' ] ]) + ->label(false) + ->textInput([ 'placeholder' => $model->getAttributeLabel('search') ]); ?> - + end(); + $form2->end(); ?> - 'add-to-catalog-search-worker'])?> + 'add-to-catalog-search-worker' ]) ?>
    Сортировать: 
    • - +
    • @@ -201,14 +197,11 @@ $this->title = 'My Yii Application'; $dataProvider, - 'itemView'=>'_performer_list_view', - 'layout' => "{items}\n" - ] ); - ?> - - + ListView::widget([ + 'dataProvider' => $dataProvider, + 'itemView' => '_performer_list_view', + 'layout' => "{items}\n", + ]); ?>
    -- libgit2 0.21.4