new balance
This commit is contained in:
parent
a783be26d1
commit
2f4f92bdec
@ -5,7 +5,10 @@ namespace backend\modules\balance\controllers;
|
|||||||
use backend\modules\balance\models\Balance;
|
use backend\modules\balance\models\Balance;
|
||||||
use backend\modules\balance\models\BalanceSearch;
|
use backend\modules\balance\models\BalanceSearch;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
|
use common\models\FieldsValue;
|
||||||
|
use common\models\FieldsValueNew;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
@ -15,7 +18,7 @@ class BalanceController extends Controller
|
|||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
$searchModel = new BalanceSearch();
|
$searchModel = new BalanceSearch();
|
||||||
$dataProvider = $searchModel->search();
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
return $this->render('index',[
|
return $this->render('index',[
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
@ -25,8 +28,18 @@ class BalanceController extends Controller
|
|||||||
|
|
||||||
public function actionView($id)
|
public function actionView($id)
|
||||||
{
|
{
|
||||||
|
$dataProviderF = new ActiveDataProvider([
|
||||||
|
'query' => FieldsValueNew::find()
|
||||||
|
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_BALANCE])
|
||||||
|
->orderBy('order'),
|
||||||
|
'pagination' => [
|
||||||
|
'pageSize' => 200,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
return $this->render('view',[
|
return $this->render('view',[
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
|
'dataProviderF' => $dataProviderF
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +66,9 @@ class BalanceController extends Controller
|
|||||||
{
|
{
|
||||||
$model = $this->findModel($id);
|
$model = $this->findModel($id);
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post())) {
|
||||||
|
$model->dt_add = strtotime($model->dt_add);
|
||||||
|
$model->save();
|
||||||
return $this->redirect(['view', 'id' => $model->id]);
|
return $this->redirect(['view', 'id' => $model->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,20 +5,23 @@ namespace backend\modules\balance\models;
|
|||||||
|
|
||||||
|
|
||||||
use common\models\FieldsValue;
|
use common\models\FieldsValue;
|
||||||
|
use common\models\FieldsValueNew;
|
||||||
use common\models\ProjectUser;
|
use common\models\ProjectUser;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
class Balance extends \common\models\Balance
|
class Balance extends \common\models\Balance
|
||||||
{
|
{
|
||||||
|
public $fields;
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
$fieldValue = FieldsValue::find()
|
$fieldValue = FieldsValueNew::find()
|
||||||
->where(
|
->where(
|
||||||
[
|
[
|
||||||
'balance_id' => \Yii::$app->request->get('id'),
|
//'balance_id' => \Yii::$app->request->get('id'),
|
||||||
'card_id' => null,
|
'item_id' => \Yii::$app->request->get('id'),
|
||||||
'company_id' => null,
|
'item_type' => FieldsValueNew::TYPE_BALANCE,
|
||||||
])
|
])
|
||||||
->all();
|
->all();
|
||||||
$array = [];
|
$array = [];
|
||||||
@ -37,12 +40,12 @@ class Balance extends \common\models\Balance
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = ArrayHelper::getColumn(ProjectUser::find()->where(['project_id' => \Yii::$app->request->get('id')])->all(),
|
// $user = ArrayHelper::getColumn(ProjectUser::find()->where(['project_id' => \Yii::$app->request->get('id')])->all(),
|
||||||
'card_id');
|
// 'card_id');
|
||||||
|
//
|
||||||
if (!empty($user)) {
|
// if (!empty($user)) {
|
||||||
$this->user = $user;
|
// $this->user = $user;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,30 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace backend\modules\balance\models;
|
namespace backend\modules\balance\models;
|
||||||
|
|
||||||
|
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
|
use backend\modules\balance\models\Balance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BalanceSearch represents the model behind the search form of `backend\modules\balance\models\Balance`.
|
||||||
|
*/
|
||||||
class BalanceSearch extends Balance
|
class BalanceSearch extends Balance
|
||||||
{
|
{
|
||||||
public function scenarios()
|
public $summ_from;
|
||||||
|
public $summ_to;
|
||||||
|
public $dt_from;
|
||||||
|
public $dt_to;
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
{
|
{
|
||||||
return Model::scenarios(); // TODO: Change the autogenerated stub
|
return [
|
||||||
|
[['id', 'type', 'summ', 'summ_from', 'summ_to'], 'integer'],
|
||||||
|
[['dt_from', 'dt_to', 'dt_add'], 'safe'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search()
|
/**
|
||||||
|
* {@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 = Balance::find();
|
$query = Balance::find();
|
||||||
|
|
||||||
|
// add conditions that should always apply here
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($this->validate())
|
$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,
|
||||||
|
'type' => $this->type,
|
||||||
|
//'summ' => $this->summ,
|
||||||
|
'dt_add' => $this->dt_add,
|
||||||
|
]);
|
||||||
|
|
||||||
|
//Debug::dd($this);
|
||||||
|
|
||||||
|
if($this->dt_from && $this->dt_to){
|
||||||
|
$query->where(['between', 'dt_add', strtotime($this->$this->dt_from), strtotime($this->$this->dt_to)]);
|
||||||
|
}
|
||||||
|
if($this->dt_from){
|
||||||
|
$query->where(['>', 'dt_add', strtotime($this->$this->dt_from)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$summ_from = $this->summ_from ?: 0;
|
||||||
|
$summ_to = $this->summ_to ?: 9999999999;
|
||||||
|
|
||||||
|
$query->andFilterWhere(['between', 'summ', $summ_from, $summ_to]);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -17,12 +17,7 @@ use yii\widgets\ActiveForm;
|
|||||||
<?php $form = ActiveForm::begin(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'type')
|
<?= $form->field($model, 'type')
|
||||||
->dropDownList(
|
->dropDownList(\common\models\Balance::getTypeList())?>
|
||||||
[
|
|
||||||
'1' => 'активный',
|
|
||||||
'0' => 'пассивный',
|
|
||||||
]
|
|
||||||
)?>
|
|
||||||
|
|
||||||
<?= $form->field($model, 'summ')->textInput(['maxlength' => 9]) ?>
|
<?= $form->field($model, 'summ')->textInput(['maxlength' => 9]) ?>
|
||||||
|
|
||||||
|
33
backend/modules/balance/views/balance/_search.php
Normal file
33
backend/modules/balance/views/balance/_search.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\balance\models\BalanceSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="balance-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'type') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'summ') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'dt_add') ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use kartik\select2\Select2;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
@ -21,9 +22,34 @@ $this->params['breadcrumps'][] = $this->title;
|
|||||||
'filterModel' => $searchModel,
|
'filterModel' => $searchModel,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
['class' => 'yii\grid\SerialColumn'],
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
'type',
|
[
|
||||||
'summ',
|
'attribute' => 'type',
|
||||||
'dt_add',
|
'value' => function ($model) {
|
||||||
|
return \common\models\Balance::getTypeName($model->type);
|
||||||
|
},
|
||||||
|
'filter' => kartik\select2\Select2::widget([
|
||||||
|
'model' => $searchModel,
|
||||||
|
'attribute' => 'type',
|
||||||
|
'data' => \common\models\Balance::getTypeList(),
|
||||||
|
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||||
|
'pluginOptions' => [
|
||||||
|
'allowClear' => true
|
||||||
|
],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'summ',
|
||||||
|
'filter' => \backend\widgets\SummRangeWidget::widget([
|
||||||
|
'model' => $searchModel,
|
||||||
|
]),
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'dt_add',
|
||||||
|
'value' => 'dt_add',
|
||||||
|
'filter' => \yii\jui\DatePicker::widget(['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']),
|
||||||
|
'format' => 'html',
|
||||||
|
],
|
||||||
['class' => 'yii\grid\ActionColumn'],
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use yii\grid\GridView;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\DetailView;
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $dataProviderF \yii\data\ActiveDataProvider
|
||||||
/* @var $model backend\modules\balance\models\Balance */
|
/* @var $model backend\modules\balance\models\Balance */
|
||||||
|
|
||||||
$this->title = 'Баланс №' . $model->id;
|
$this->title = 'Баланс №' . $model->id;
|
||||||
@ -12,8 +14,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
?>
|
?>
|
||||||
<div class="balance-view">
|
<div class="balance-view">
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
|
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||||
'class' => 'btn btn-danger',
|
'class' => 'btn btn-danger',
|
||||||
'data' => [
|
'data' => [
|
||||||
'confirm' => 'Are you sure you want to delete this item?',
|
'confirm' => 'Are you sure you want to delete this item?',
|
||||||
@ -25,11 +28,30 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?= DetailView::widget([
|
<?= DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id',
|
//'id',
|
||||||
'type',
|
[
|
||||||
|
'attribute' => 'type',
|
||||||
|
'value' => function($model){
|
||||||
|
return \common\models\Balance::getTypeName($model->type);
|
||||||
|
}
|
||||||
|
],
|
||||||
'summ',
|
'summ',
|
||||||
'dt_add',
|
'dt_add',
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
<h2>Дополнительные сведения</h2>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProviderF,
|
||||||
|
'layout' => "{items}",
|
||||||
|
'columns' => [
|
||||||
|
'field.name:text:Поле',
|
||||||
|
[
|
||||||
|
'attribute' => 'value',
|
||||||
|
'label' => 'Значение'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
18
backend/widgets/DateRangeWidget.php
Normal file
18
backend/widgets/DateRangeWidget.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace backend\widgets;
|
||||||
|
|
||||||
|
|
||||||
|
use yii\base\Widget;
|
||||||
|
|
||||||
|
class DateRangeWidget extends Widget
|
||||||
|
{
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
return $this->render('date_range', ['model' => $this->model]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
backend/widgets/SummRangeWidget.php
Normal file
19
backend/widgets/SummRangeWidget.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace backend\widgets;
|
||||||
|
|
||||||
|
|
||||||
|
use yii\base\Widget;
|
||||||
|
|
||||||
|
class SummRangeWidget extends Widget
|
||||||
|
{
|
||||||
|
public $model;
|
||||||
|
public $range_attribute;
|
||||||
|
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
return $this->render('summ_range', ['model' => $this->model]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
backend/widgets/views/date_range.php
Normal file
21
backend/widgets/views/date_range.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var $model \yii\db\ActiveRecord
|
||||||
|
*/
|
||||||
|
use yii\jui\DatePicker;
|
||||||
|
|
||||||
|
echo DatePicker::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attribute' => 'dt_from',
|
||||||
|
'language' => 'ru',
|
||||||
|
'dateFormat' => 'dd-MM-yyyy',
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo " - ";
|
||||||
|
|
||||||
|
echo DatePicker::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attribute' => 'dt_to',
|
||||||
|
'language' => 'ru',
|
||||||
|
'dateFormat' => 'dd-MM-yyyy',
|
||||||
|
]);
|
12
backend/widgets/views/summ_range.php
Normal file
12
backend/widgets/views/summ_range.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var $model \yii\db\ActiveRecord
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo \yii\helpers\Html::activeTextInput($model, 'summ_from', [
|
||||||
|
'placeholder' => 'От',
|
||||||
|
]);
|
||||||
|
echo ' - ';
|
||||||
|
echo \yii\helpers\Html::activeTextInput($model, 'summ_to', [
|
||||||
|
'placeholder' => 'До',
|
||||||
|
]);
|
@ -15,6 +15,22 @@ use common\classes\Debug;
|
|||||||
*/
|
*/
|
||||||
class Balance extends \yii\db\ActiveRecord
|
class Balance extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
|
const TYPE_ACTIVE = 1;
|
||||||
|
const TYPE_PASSIVE = 0;
|
||||||
|
|
||||||
|
public static function getTypeName($id)
|
||||||
|
{
|
||||||
|
return self::getTypeList()[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTypeList()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::TYPE_ACTIVE => 'Актив',
|
||||||
|
self::TYPE_PASSIVE => 'Пассив',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public static function tableName()
|
public static function tableName()
|
||||||
{
|
{
|
||||||
return 'balance';
|
return 'balance';
|
||||||
@ -42,4 +58,32 @@ class Balance extends \yii\db\ActiveRecord
|
|||||||
parent::afterFind(); // TODO: Change the autogenerated stub
|
parent::afterFind(); // TODO: Change the autogenerated stub
|
||||||
$this->dt_add = date('d-m-Y', $this->dt_add);
|
$this->dt_add = date('d-m-Y', $this->dt_add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getFieldsValues()
|
||||||
|
{
|
||||||
|
return $this->hasMany(FieldsValueNew::class, ['item_id' => 'id', 'item_type' => FieldsValueNew::TYPE_BALANCE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterSave($insert, $changedAttributes)
|
||||||
|
{
|
||||||
|
$post = \Yii::$app->request->post('Balance');
|
||||||
|
|
||||||
|
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_BALANCE]);
|
||||||
|
|
||||||
|
foreach ($post['fields'] as $item) {
|
||||||
|
$fildsValue = new FieldsValueNew();
|
||||||
|
$fildsValue->field_id = $item['field_id'];
|
||||||
|
$fildsValue->value = $item['value'];
|
||||||
|
$fildsValue->order = $item['order'];
|
||||||
|
$fildsValue->item_id = $this->id;
|
||||||
|
$fildsValue->item_type = FieldsValueNew::TYPE_BALANCE;
|
||||||
|
|
||||||
|
$fildsValue->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
}
|
}
|
65
common/models/FieldsValueNew.php
Normal file
65
common/models/FieldsValueNew.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "fields_value_new".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $field_id
|
||||||
|
* @property int $item_id
|
||||||
|
* @property int $item_type
|
||||||
|
* @property int $order
|
||||||
|
* @property string $value
|
||||||
|
*/
|
||||||
|
class FieldsValueNew extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
const TYPE_PROFILE = 0;
|
||||||
|
const TYPE_PROJECT = 1;
|
||||||
|
const TYPE_COMPANY = 2;
|
||||||
|
const TYPE_BALANCE = 3;
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'fields_value_new';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['field_id', 'item_id', 'item_type'], 'required'],
|
||||||
|
[['field_id', 'item_id', 'item_type', 'order'], 'integer'],
|
||||||
|
[['value'], 'string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'field_id' => 'Field ID',
|
||||||
|
'item_id' => 'Item ID',
|
||||||
|
'item_type' => 'Item Type',
|
||||||
|
'order' => 'Order',
|
||||||
|
'value' => 'Value',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getField()
|
||||||
|
{
|
||||||
|
return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']);
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,8 @@
|
|||||||
"mihaildev/yii2-elfinder": "*",
|
"mihaildev/yii2-elfinder": "*",
|
||||||
"kartik-v/yii2-widget-select2": "@dev",
|
"kartik-v/yii2-widget-select2": "@dev",
|
||||||
"kavalar/hhapi": "@dev",
|
"kavalar/hhapi": "@dev",
|
||||||
"kartik-v/yii2-widget-datepicker": "@dev"
|
"kartik-v/yii2-widget-datepicker": "@dev",
|
||||||
|
"nkovacs/yii2-datetimepicker": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-debug": "~2.0.0",
|
"yiisoft/yii2-debug": "~2.0.0",
|
||||||
|
89
composer.lock
generated
89
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7c8e337361e574ba82a9b37a944713b9",
|
"content-hash": "7578e68130787df83321118c46ab02e6",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "almasaeed2010/adminlte",
|
"name": "almasaeed2010/adminlte",
|
||||||
@ -131,6 +131,46 @@
|
|||||||
"MIT"
|
"MIT"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "bower-asset/moment",
|
||||||
|
"version": "2.24.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/moment/moment.git",
|
||||||
|
"reference": "96d0d6791ab495859d09a868803d31a55c917de1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/moment/moment/zipball/96d0d6791ab495859d09a868803d31a55c917de1",
|
||||||
|
"reference": "96d0d6791ab495859d09a868803d31a55c917de1"
|
||||||
|
},
|
||||||
|
"type": "bower-asset",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bower-asset/nkovacs-bootstrap-datetimepicker",
|
||||||
|
"version": "5.0.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:nkovacs/bootstrap-datetimepicker.git",
|
||||||
|
"reference": "c7cae4e1ddcc56c42135f117bba15112f18a8c77"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nkovacs/bootstrap-datetimepicker/zipball/c7cae4e1ddcc56c42135f117bba15112f18a8c77",
|
||||||
|
"reference": "c7cae4e1ddcc56c42135f117bba15112f18a8c77"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"bower-asset/jquery": ">=1.8.3",
|
||||||
|
"bower-asset/moment": ">=2.9.0"
|
||||||
|
},
|
||||||
|
"type": "bower-asset",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "bower-asset/punycode",
|
"name": "bower-asset/punycode",
|
||||||
"version": "v1.3.2",
|
"version": "v1.3.2",
|
||||||
@ -896,6 +936,51 @@
|
|||||||
],
|
],
|
||||||
"time": "2018-10-01T17:00:54+00:00"
|
"time": "2018-10-01T17:00:54+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nkovacs/yii2-datetimepicker",
|
||||||
|
"version": "3.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nkovacs/yii2-datetimepicker.git",
|
||||||
|
"reference": "ea99923f6851ef7e4224f9fd4411df048d97275e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nkovacs/yii2-datetimepicker/zipball/ea99923f6851ef7e4224f9fd4411df048d97275e",
|
||||||
|
"reference": "ea99923f6851ef7e4224f9fd4411df048d97275e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"bower-asset/nkovacs-bootstrap-datetimepicker": "~5.0",
|
||||||
|
"php": ">=5.4.0",
|
||||||
|
"yiisoft/yii2": "^2.0.4",
|
||||||
|
"yiisoft/yii2-bootstrap": "*"
|
||||||
|
},
|
||||||
|
"type": "yii2-extension",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"nkovacs\\datetimepicker\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nikola Kovacs",
|
||||||
|
"email": "nikola.kovacs@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Bootstrap datetimepicker widget for Yii 2, based on Eonasdan/bootstrap-datetimepicker.",
|
||||||
|
"keywords": [
|
||||||
|
"DateTimePicker",
|
||||||
|
"bootstrap",
|
||||||
|
"extension",
|
||||||
|
"yii2"
|
||||||
|
],
|
||||||
|
"time": "2017-03-28T08:57:15+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "rmrevin/yii2-fontawesome",
|
"name": "rmrevin/yii2-fontawesome",
|
||||||
"version": "2.17.1",
|
"version": "2.17.1",
|
||||||
@ -3994,7 +4079,7 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=5.4.0"
|
"php": ">=7.1.0"
|
||||||
},
|
},
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
47
console/migrations/m190622_195218_fields_value_new.php
Normal file
47
console/migrations/m190622_195218_fields_value_new.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m190622_195218_fields_value_new
|
||||||
|
*/
|
||||||
|
class m190622_195218_fields_value_new extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('fields_value_new',[
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'field_id' => $this->integer(11)->notNull(),
|
||||||
|
'item_id' => $this->integer(11)->notNull(),
|
||||||
|
'item_type' => $this->integer(4)->notNull(),
|
||||||
|
'order' => $this->integer(11),
|
||||||
|
'value' => $this->text(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropTable('fields_value_new');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use up()/down() to run migration code without a transaction.
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m190622_195218_fields_value_new cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user