first commit
This commit is contained in:
24
backend/modules/card/Card.php
Normal file
24
backend/modules/card/Card.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card;
|
||||
|
||||
/**
|
||||
* card module definition class
|
||||
*/
|
||||
class Card extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\card\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
138
backend/modules/card/controllers/UserCardController.php
Normal file
138
backend/modules/card/controllers/UserCardController.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\controllers;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValue;
|
||||
use Yii;
|
||||
use backend\modules\card\models\UserCard;
|
||||
use backend\modules\card\models\UserCardSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* UserCardController implements the CRUD actions for UserCard model.
|
||||
*/
|
||||
class UserCardController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all UserCard models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new UserCardSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single UserCard model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => FieldsValue::find()->where(['card_id' => $id])->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'modelFildValue' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UserCard model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserCard();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing UserCard model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing UserCard model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the UserCard model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return UserCard the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = UserCard::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
57
backend/modules/card/models/UserCard.php
Normal file
57
backend/modules/card/models/UserCard.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\models;
|
||||
|
||||
use common\models\FieldsValue;
|
||||
|
||||
class UserCard extends \common\models\UserCard
|
||||
{
|
||||
public $fields;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()->where(
|
||||
[
|
||||
'card_id' => \Yii::$app->request->get('id'),
|
||||
'project_id' => null,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if(!empty($fieldValue)){
|
||||
foreach ($fieldValue as $item){
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
}
|
||||
else{
|
||||
$this->fields = [
|
||||
[
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('UserCard');
|
||||
|
||||
FieldsValue::deleteAll(['card_id' => $this->id]);
|
||||
|
||||
foreach ( $post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->card_id = $this->id;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
77
backend/modules/card/models/UserCardSearch.php
Normal file
77
backend/modules/card/models/UserCardSearch.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\card\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\card\models\UserCard;
|
||||
|
||||
/**
|
||||
* UserCardSearch represents the model behind the search form of `backend\modules\card\models\UserCard`.
|
||||
*/
|
||||
class UserCardSearch extends UserCard
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'gender', 'status'], 'integer'],
|
||||
[['fio', 'passport', 'photo', 'email', 'dob', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserCard::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'gender' => $this->gender,
|
||||
'dob' => $this->dob,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'fio', $this->fio])
|
||||
->andFilterWhere(['like', 'passport', $this->passport])
|
||||
->andFilterWhere(['like', 'photo', $this->photo])
|
||||
->andFilterWhere(['like', 'email', $this->email]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
148
backend/modules/card/views/user-card/_form.php
Normal file
148
backend/modules/card/views/user-card/_form.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
use mihaildev\elfinder\InputFile;
|
||||
use unclead\multipleinput\MultipleInput;
|
||||
use unclead\multipleinput\examples\models\ExampleModel;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-card-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'passport')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="padding-bottom: 15px">
|
||||
<div class="imgUpload col-xs-6">
|
||||
<div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px"/></div>
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
'controller' => 'elfinder',
|
||||
// вставляем название контроллера, по умолчанию равен elfinder
|
||||
'filter' => 'image',
|
||||
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
|
||||
'name' => 'UserCard[photo]',
|
||||
'id' => 'usercard-photo',
|
||||
'template' => '<label>Аватар</label><div class="input-group">{input}<span class="span-btn">{button}</span></div>',
|
||||
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
|
||||
'buttonOptions' => ['class' => 'btn btn-primary'],
|
||||
'value' => $model->photo,
|
||||
'buttonName' => 'Выбрать изображение',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<!--<div class="media__upload_img"><img src="<?/*= $model->photo; */?>" width="100px"/></div>-->
|
||||
<?php
|
||||
echo InputFile::widget([
|
||||
'language' => 'ru',
|
||||
'controller' => 'elfinder',
|
||||
// вставляем название контроллера, по умолчанию равен elfinder
|
||||
'filter' => ['image','application/zip','application/pdf','application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
|
||||
'name' => 'UserCard[resume]',
|
||||
'id' => 'usercard-resume',
|
||||
'template' => '<label>Резюме</label><div class="input-group">{input}<span class="span-btn">{button}</span></div>',
|
||||
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
|
||||
'buttonOptions' => ['class' => 'btn btn-primary'],
|
||||
'value' => $model->photo,
|
||||
'buttonName' => 'Выбрать резюме',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'gender')->dropDownList($model->genders,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'dob')->input('date',
|
||||
[
|
||||
'placeholder' => 'Zadejte svůj Datum narození',
|
||||
'language' => 'en',
|
||||
"data-format" => "DD MMMM YYYY",
|
||||
|
||||
]) ?>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<?= $form->field($model, 'status')
|
||||
->dropDownList(\yii\helpers\ArrayHelper::map(
|
||||
\common\models\Status::find()
|
||||
->joinWith('useStatuses')
|
||||
->where(['`use_status`.`use`' => \common\models\UseStatus::USE_PROFILE])->all(), 'id', 'name'),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
|
||||
|
||||
'columns' => [
|
||||
[
|
||||
'name' => 'field_id',
|
||||
'type' => 'dropDownList',
|
||||
'title' => 'Поле',
|
||||
'defaultValue' => null,
|
||||
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\fields\models\AdditionalFields::find()
|
||||
->joinWith('useFields')
|
||||
->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROFILE])
|
||||
->all(),
|
||||
'id', 'name'),
|
||||
'options' => ['prompt' => 'Выберите']
|
||||
],
|
||||
[
|
||||
'name' => 'value',
|
||||
'title' => 'Значение',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'order',
|
||||
'title' => 'Приоритет',
|
||||
'enableError' => true,
|
||||
'options' => [
|
||||
'class' => 'input-priority'
|
||||
]
|
||||
]
|
||||
]
|
||||
])->label('Дополнительно');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
45
backend/modules/card/views/user-card/_search.php
Normal file
45
backend/modules/card/views/user-card/_search.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCardSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-card-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'fio') ?>
|
||||
|
||||
<?= $form->field($model, 'passport') ?>
|
||||
|
||||
<?= $form->field($model, 'photo') ?>
|
||||
|
||||
<?= $form->field($model, 'email') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'gender') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'dob') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
16
backend/modules/card/views/user-card/create.php
Normal file
16
backend/modules/card/views/user-card/create.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = 'Новый профиль';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Профили', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
39
backend/modules/card/views/user-card/index.php
Normal file
39
backend/modules/card/views/user-card/index.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Профили';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-index">
|
||||
|
||||
<p>
|
||||
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'fio',
|
||||
'passport',
|
||||
'photo',
|
||||
'email:email',
|
||||
//'gender',
|
||||
//'dob',
|
||||
//'status',
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
21
backend/modules/card/views/user-card/update.php
Normal file
21
backend/modules/card/views/user-card/update.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = 'Update User Card: ' . $model->id;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="user-card-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
68
backend/modules/card/views/user-card/view.php
Normal file
68
backend/modules/card/views/user-card/view.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\card\models\UserCard */
|
||||
|
||||
$this->title = $model->fio;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-card-view">
|
||||
|
||||
<p>
|
||||
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'fio',
|
||||
'passport',
|
||||
[
|
||||
'label' => 'Photo',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
|
||||
}
|
||||
],
|
||||
[
|
||||
'label' => 'Resume',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
|
||||
}
|
||||
],
|
||||
[
|
||||
'label' => 'gender',
|
||||
'value' => $model->gendersText,
|
||||
],
|
||||
|
||||
'email:email',
|
||||
|
||||
'dob',
|
||||
[
|
||||
'label' => 'status',
|
||||
'value' => $model->status0->name,
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<h2>Дополнительные сведения</h2>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $modelFildValue,
|
||||
'layout'=>"{items}",
|
||||
'columns' => [
|
||||
'field.name:text:Поле',
|
||||
'value',
|
||||
],
|
||||
]); ?>
|
||||
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user