commit
b1fdad1e1c
@ -30,11 +30,9 @@ class BalanceController extends Controller
|
||||
$searchModel->dt_to = date('Y-m-d', strtotime('last day of previous month'));
|
||||
}
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
$summ_info = $searchModel->getSummInfo();
|
||||
|
||||
return $this->render('index',[
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
return $this->render('index',compact('dataProvider', 'searchModel', 'summ_info'));
|
||||
}
|
||||
|
||||
public function actionView($id)
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace backend\modules\balance\models;
|
||||
|
||||
use backend\modules\balance\models\Balance;
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValueNew;
|
||||
use DateTime;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\balance\models\Balance;
|
||||
|
||||
/**
|
||||
* BalanceSearch represents the model behind the search form of `backend\modules\balance\models\Balance`.
|
||||
@ -21,6 +21,9 @@ class BalanceSearch extends Balance
|
||||
public $dt_to;
|
||||
public $field_name;
|
||||
public $field_value;
|
||||
public $active_summ;
|
||||
public $passive_summ;
|
||||
public $difference;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -87,4 +90,27 @@ class BalanceSearch extends Balance
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public function getSummInfo()
|
||||
{
|
||||
$query = Balance::find()
|
||||
->andFilterWhere(['>=','dt_add', strtotime($this->dt_from) ?: null])
|
||||
->andFilterWhere(['<=','dt_add', strtotime($this->dt_to) ?: null])
|
||||
->all();
|
||||
$active_summ = 0;
|
||||
$passive_summ = 0;
|
||||
$difference = 0;
|
||||
foreach ($query as $item)
|
||||
{
|
||||
if($item->type == 1)
|
||||
{
|
||||
$active_summ += $item->summ;
|
||||
} else {
|
||||
$passive_summ += $item->summ;
|
||||
}
|
||||
}
|
||||
$difference = $active_summ - $passive_summ;
|
||||
|
||||
return compact('active_summ', 'passive_summ', 'difference');
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,20 @@ $this->params['breadcrumps'][] = $this->title;
|
||||
<?= Html::a('Показать за прошлый месяц', ['index', 'previous_month' => true], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Показать за текущий месяц', ['index', 'month' => true], ['class' => 'btn btn-primary']) ?>
|
||||
</p>
|
||||
<!-- --><?php //\common\classes\Debug::dd($searchModel->fields); ?>
|
||||
<p>
|
||||
<?= Html::label('Актив: ' . $summ_info['active_summ']); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?= Html::label('Пассив: ' . $summ_info['passive_summ']); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?= Html::label('Разница: ' . $summ_info['difference']); ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
// 'layout'=> "{items}\n{summary}", // перемещение информации о записях под таблицу
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
|
@ -6,6 +6,7 @@ use common\classes\Debug;
|
||||
use common\models\AdditionalFields;
|
||||
use common\models\CardSkill;
|
||||
use common\models\FieldsValue;
|
||||
use common\models\FieldsValueNew;
|
||||
use common\models\Status;
|
||||
use Yii;
|
||||
use backend\modules\card\models\UserCard;
|
||||
@ -43,7 +44,6 @@ class UserCardController extends Controller
|
||||
public function actionIndex()
|
||||
{
|
||||
$status = new Status();
|
||||
//Debug::dd($status->getUseStatuses());
|
||||
$searchModel = new UserCardSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
@ -62,7 +62,9 @@ class UserCardController extends Controller
|
||||
public function actionView($id)
|
||||
{
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => FieldsValue::find()->where(['card_id' => $id])->orderBy('order'),
|
||||
'query' => FieldsValueNew::find()
|
||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
||||
->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
@ -105,7 +107,7 @@ class UserCardController extends Controller
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
// Debug::dd($model);
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace backend\modules\card\models;
|
||||
use backend\modules\settings\models\Skill;
|
||||
use common\models\CardSkill;
|
||||
use common\models\FieldsValue;
|
||||
use common\models\FieldsValueNew;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
class UserCard extends \common\models\UserCard
|
||||
@ -16,17 +17,20 @@ class UserCard extends \common\models\UserCard
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()->where(
|
||||
$fieldValue = FieldsValueNew::find()->where(
|
||||
[
|
||||
'card_id' => \Yii::$app->request->get('id'),
|
||||
'project_id' => null,
|
||||
'company_id' => null,
|
||||
'item_id' => \Yii::$app->request->get('id'),
|
||||
'item_type' => FieldsValueNew::TYPE_PROFILE,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if(!empty($fieldValue)){
|
||||
foreach ($fieldValue as $item){
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
array_push($array,
|
||||
['field_id' => $item->field_id,
|
||||
'value' => $item->value,
|
||||
'order' => $item->order,
|
||||
'field_name' => $item->field->name]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
}
|
||||
@ -36,6 +40,7 @@ class UserCard extends \common\models\UserCard
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
'field_name' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -54,17 +59,16 @@ class UserCard extends \common\models\UserCard
|
||||
{
|
||||
$post = \Yii::$app->request->post('UserCard');
|
||||
|
||||
|
||||
|
||||
if($post['fields']){
|
||||
FieldsValue::deleteAll(['card_id' => $this->id]);
|
||||
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROFILE]);
|
||||
|
||||
foreach ( $post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue = new FieldsValueNew();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->card_id = $this->id;
|
||||
$fildsValue->item_id = $this->id;
|
||||
$fildsValue->item_type = FieldsValueNew::TYPE_PROFILE;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class Company extends \common\models\Company
|
||||
{
|
||||
$post = \Yii::$app->request->post('Company');
|
||||
|
||||
FieldsValue::deleteAll(['company_id' => $this->id]);
|
||||
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_COMPANY]);
|
||||
|
||||
foreach ( $post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValueNew();
|
||||
|
@ -15,8 +15,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<div class="company-view">
|
||||
<p>
|
||||
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Update', ['update', 'id' => $model->id], ['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',
|
||||
'data' => [
|
||||
'confirm' => 'Are you sure you want to delete this item?',
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace backend\modules\project\controllers;
|
||||
|
||||
use common\models\FieldsValue;
|
||||
use common\models\FieldsValueNew;
|
||||
use common\models\Hh;
|
||||
use common\models\HhJob;
|
||||
use common\models\ProjectUser;
|
||||
@ -72,7 +73,9 @@ class ProjectController extends Controller
|
||||
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => FieldsValue::find()->where(['project_id' => $id])->orderBy('order'),
|
||||
'query' => FieldsValueNew::find()
|
||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROJECT])
|
||||
->orderBy('order'),
|
||||
'pagination' => [
|
||||
'pageSize' => 200,
|
||||
],
|
||||
|
@ -4,6 +4,7 @@ namespace backend\modules\project\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValue;
|
||||
use common\models\FieldsValueNew;
|
||||
use common\models\ProjectUser;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
@ -16,18 +17,21 @@ class Project extends \common\models\Project
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValue::find()
|
||||
$fieldValue = FieldsValueNew::find()
|
||||
->where(
|
||||
[
|
||||
'project_id' => \Yii::$app->request->get('id'),
|
||||
'card_id' => null,
|
||||
'company_id' => null,
|
||||
'item_id' => \Yii::$app->request->get('id'),
|
||||
'item_type' => FieldsValueNew::TYPE_PROJECT,
|
||||
])
|
||||
->all();
|
||||
$array = [];
|
||||
if (!empty($fieldValue)) {
|
||||
foreach ($fieldValue as $item) {
|
||||
array_push($array, ['field_id' => $item->field_id, 'value' => $item->value, 'order' => $item->order]);
|
||||
array_push($array, [
|
||||
'field_id' => $item->field_id,
|
||||
'value' => $item->value,
|
||||
'order' => $item->order,
|
||||
'field_name' => $item->field->name]);
|
||||
}
|
||||
$this->fields = $array;
|
||||
} else {
|
||||
@ -36,6 +40,7 @@ class Project extends \common\models\Project
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
'field_name' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -53,14 +58,15 @@ class Project extends \common\models\Project
|
||||
{
|
||||
$post = \Yii::$app->request->post('Project');
|
||||
|
||||
FieldsValue::deleteAll(['project_id' => $this->id]);
|
||||
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROJECT]);
|
||||
|
||||
foreach ($post['fields'] as $item) {
|
||||
$fildsValue = new FieldsValue();
|
||||
$fildsValue = new FieldsValueNew();
|
||||
$fildsValue->field_id = $item['field_id'];
|
||||
$fildsValue->value = $item['value'];
|
||||
$fildsValue->order = $item['order'];
|
||||
$fildsValue->project_id = $this->id;
|
||||
$fildsValue->item_id = $this->id;
|
||||
$fildsValue->item_type = FieldsValueNew::TYPE_PROJECT;
|
||||
|
||||
$fildsValue->save();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace backend\modules\settings\controllers;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\UseField;
|
||||
use Yii;
|
||||
use backend\modules\settings\models\AdditionalFields;
|
||||
|
@ -25,7 +25,7 @@
|
||||
'label' => 'Профили', 'icon' => 'users', 'url' => '#',
|
||||
'items' => $menuItems,
|
||||
],
|
||||
['label' => 'Пректы', 'icon' => 'files-o', 'url' => ['/project/project']],
|
||||
['label' => 'Проекты', 'icon' => 'files-o', 'url' => ['/project/project']],
|
||||
['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']],
|
||||
[
|
||||
'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#',
|
||||
|
@ -86,7 +86,7 @@ class Company extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::className(), ['company_id' => 'id']);
|
||||
return $this->hasMany(FieldsValueNew::class, ['item_id' => 'id'])->where(['item_type' => FieldsValueNew::TYPE_COMPANY])->with('field');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::class, ['project_id' => 'id']);
|
||||
return $this->hasMany(FieldsValueNew::class, ['item_id' => 'id'])->where(['item_type' => FieldsValueNew::TYPE_PROJECT])->with('field');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::class, ['card_id' => 'id']);
|
||||
return $this->hasMany(FieldsValueNew::class, ['item_id' => 'id'])->where(['item_type' => FieldsValueNew::TYPE_PROFILE])->with('field');
|
||||
}
|
||||
|
||||
/**
|
||||
|
49
console/controllers/MovingController.php
Normal file
49
console/controllers/MovingController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace console\controllers;
|
||||
|
||||
use common\models\FieldsValueNew;
|
||||
use yii\console\Controller;
|
||||
|
||||
class MovingController extends Controller
|
||||
{
|
||||
/*const TYPE_PROFILE = 0;
|
||||
const TYPE_PROJECT = 1;
|
||||
const TYPE_COMPANY = 2;
|
||||
const TYPE_BALANCE = 3;*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$field_value = \common\models\FieldsValue::find()->all();
|
||||
|
||||
foreach ($field_value as $item)
|
||||
{
|
||||
$new_value = new FieldsValueNew();
|
||||
$new_value->order = $item->order;
|
||||
$new_value->field_id = $item->field_id;
|
||||
$new_value->value = $item->value;
|
||||
|
||||
if($item->card_id != null)
|
||||
{
|
||||
$new_value->item_type = 0;
|
||||
$new_value->item_id = $item->card_id;
|
||||
}
|
||||
if($item->balance_id != null)
|
||||
{
|
||||
$new_value->item_type = 3 ;
|
||||
$new_value->item_id = $item->balance_id;
|
||||
}
|
||||
if($item->project_id != null)
|
||||
{
|
||||
$new_value->item_type = 1;
|
||||
$new_value->item_id = $item->project_id;
|
||||
}
|
||||
if($item->company_id!= null)
|
||||
{
|
||||
$new_value->item_type = 2;
|
||||
$new_value->item_id = $item->company_id;
|
||||
}
|
||||
|
||||
$new_value->save();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user