bd calendar and salary sum
This commit is contained in:
parent
88b0b13a2a
commit
188758c79c
@ -15,6 +15,7 @@ class AppAsset extends AssetBundle
|
|||||||
'css/site.css',
|
'css/site.css',
|
||||||
];
|
];
|
||||||
public $js = [
|
public $js = [
|
||||||
|
'js/site.js',
|
||||||
];
|
];
|
||||||
public $depends = [
|
public $depends = [
|
||||||
'yii\web\YiiAsset',
|
'yii\web\YiiAsset',
|
||||||
|
@ -41,6 +41,9 @@ return [
|
|||||||
'notes' => [
|
'notes' => [
|
||||||
'class' => 'backend\modules\notes\Notes',
|
'class' => 'backend\modules\notes\Notes',
|
||||||
],
|
],
|
||||||
|
'calendar' => [
|
||||||
|
'class' => 'backend\modules\calendar\Calendar',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'components' => [
|
'components' => [
|
||||||
'request' => [
|
'request' => [
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
namespace app\modules\accesses\models;
|
namespace app\modules\accesses\models;
|
||||||
|
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
|
use common\models\FieldsValueNew;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,5 +18,73 @@ use Yii;
|
|||||||
|
|
||||||
class Accesses extends \common\models\Accesses
|
class Accesses extends \common\models\Accesses
|
||||||
{
|
{
|
||||||
|
public $fields;
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
$fieldValue = FieldsValueNew::find()->where(
|
||||||
|
[
|
||||||
|
'item_id' => \Yii::$app->request->get('id'),
|
||||||
|
'item_type' => FieldsValueNew::TYPE_ACCESS,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->all();
|
||||||
|
$array = [];
|
||||||
|
if (!empty($fieldValue)) {
|
||||||
|
foreach ($fieldValue as $item) {
|
||||||
|
array_push(
|
||||||
|
$array,
|
||||||
|
[
|
||||||
|
'field_id' => $item->field_id,
|
||||||
|
'value' => $item->value,
|
||||||
|
'order' => $item->order,
|
||||||
|
'type_file' => $item->type_file,
|
||||||
|
'field_name' => $item->field->name
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->fields = $array;
|
||||||
|
} else {
|
||||||
|
$this->fields = [
|
||||||
|
[
|
||||||
|
'field_id' => null,
|
||||||
|
'value' => null,
|
||||||
|
'order' => null,
|
||||||
|
'field_name' => null,
|
||||||
|
'type_file' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterSave($insert, $changedAttributes)
|
||||||
|
{
|
||||||
|
$post = \Yii::$app->request->post('Aceesses');
|
||||||
|
|
||||||
|
if ($post['fields']) {
|
||||||
|
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_ACCESS]);
|
||||||
|
foreach ($post['fields'] as $item) {
|
||||||
|
$item['value'] = urldecode($item['value']);
|
||||||
|
|
||||||
|
$fieldsValue = new FieldsValueNew();
|
||||||
|
$fieldsValue->field_id = $item['field_id'];
|
||||||
|
$fieldsValue->value = $item['value'];
|
||||||
|
$fieldsValue->order = $item['order'];
|
||||||
|
$fieldsValue->item_id = $this->id;
|
||||||
|
$fieldsValue->item_type = FieldsValueNew::TYPE_ACCESS;
|
||||||
|
if (is_file(Yii::getAlias('@frontend') . '/web/' . $item['value'])) {
|
||||||
|
$fieldsValue->type_file = 'file';
|
||||||
|
} else {
|
||||||
|
$fieldsValue->type_file = 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
$fieldsValue->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use mihaildev\elfinder\InputFile;
|
||||||
|
use unclead\multipleinput\MultipleInput;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
use kartik\select2\Select2;
|
use kartik\select2\Select2;
|
||||||
@ -34,7 +36,6 @@ use kartik\select2\Select2;
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<text>Пользователи</text>
|
<text>Пользователи</text>
|
||||||
|
24
backend/modules/calendar/Calendar.php
Normal file
24
backend/modules/calendar/Calendar.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\calendar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calendar module definition class
|
||||||
|
*/
|
||||||
|
class Calendar extends \yii\base\Module
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public $controllerNamespace = 'backend\modules\calendar\controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
// custom initialization code goes here
|
||||||
|
}
|
||||||
|
}
|
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\calendar\controllers;
|
||||||
|
|
||||||
|
use backend\modules\card\models\UserCardSearch;
|
||||||
|
use common\classes\Debug;
|
||||||
|
use Yii;
|
||||||
|
use yii\data\ArrayDataProvider;
|
||||||
|
use yii\web\Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default controller for the `calendar` module
|
||||||
|
*/
|
||||||
|
class CalendarController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Renders the index view for the module
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
$searchModel = new UserCardSearch();
|
||||||
|
$user_card = \common\models\UserCard::find()->all();
|
||||||
|
$user_array = array();
|
||||||
|
try {
|
||||||
|
if($_GET['month'] == 00)
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
else {
|
||||||
|
foreach ($user_card as $value) {
|
||||||
|
if (substr(substr($value->dob, 5), 0, 2) == $_GET['month'])
|
||||||
|
array_push($user_array, $value);
|
||||||
|
}
|
||||||
|
$dataProvider = new ArrayDataProvider([
|
||||||
|
'allModels' => $user_array,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
42
backend/modules/calendar/views/calendar/index.php
Normal file
42
backend/modules/calendar/views/calendar/index.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<div class="calendar-default-index">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<select id="options" class="btn btn-secondary dropdown-toggle">
|
||||||
|
<option selected="selected">Выберите месяц</option>
|
||||||
|
<option value="?month=00">Показать все</option>
|
||||||
|
<option value="?month=01">январь</option>
|
||||||
|
<option value="?month=02">февраль</option>
|
||||||
|
<option value="?month=03">март</option>
|
||||||
|
<option value="?month=04">апрель</option>
|
||||||
|
<option value="?month=05">май</option>
|
||||||
|
<option value="?month=06">июнь</option>
|
||||||
|
<option value="?month=07">июль</option>
|
||||||
|
<option value="?month=08">август</option>
|
||||||
|
<option value="?month=09">сентябрь</option>
|
||||||
|
<option value="?month=10">октябрь</option>
|
||||||
|
<option value="?month=11">ноябрь</option>
|
||||||
|
<option value="?month=12">декабрь</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\widgets\Pjax;
|
||||||
|
|
||||||
|
Pjax::begin(['id' => 'reload']);
|
||||||
|
echo GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
'fio',
|
||||||
|
'dob',
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
Pjax::end();
|
||||||
|
?>
|
@ -47,9 +47,21 @@ class UserCardController extends Controller
|
|||||||
$searchModel = new UserCardSearch();
|
$searchModel = new UserCardSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
$total = 0;
|
||||||
|
if(Yii::$app->request->queryParams)
|
||||||
|
foreach (Yii::$app->request->queryParams as $params)
|
||||||
|
$total = \common\models\UserCard::find()->filterWhere([
|
||||||
|
'fio' => $params['fio'],
|
||||||
|
'email' => $params['email'],
|
||||||
|
'status' => $params['status'],
|
||||||
|
'skills' => $params['skills'],
|
||||||
|
])->sum('salary');
|
||||||
|
else $total = \common\models\UserCard::find()->sum('salary');
|
||||||
|
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
|
'total' => $total,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class UserCard extends \common\models\UserCard
|
|||||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateUser($email, $status)
|
public static function generateUser($email, $status)
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$auth_key = Yii::$app->security->generateRandomString();
|
$auth_key = Yii::$app->security->generateRandomString();
|
||||||
@ -121,18 +121,18 @@ class UserCard extends \common\models\UserCard
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$log = "Логин: " . $email . " Пароль: " . $password . " | ";
|
$log = "Логин: " . $email . " Пароль: " . $password . " | ";
|
||||||
file_put_contents("log.txt", $log, FILE_APPEND | LOCK_EX);
|
//file_put_contents("log.txt", $log, FILE_APPEND | LOCK_EX);
|
||||||
|
|
||||||
return $user->id;
|
return $user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genereateLinlkOnUser($user_card, $user_id)
|
public static function genereateLinlkOnUser($user_card, $user_id)
|
||||||
{
|
{
|
||||||
$user_card->id_user = $user_id;
|
$user_card->id_user = $user_id;
|
||||||
$user_card->save();
|
$user_card->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateUserForUserCard($card_id = null)
|
public static function generateUserForUserCard($card_id = null)
|
||||||
{
|
{
|
||||||
$userCardQuery = UserCard::find();
|
$userCardQuery = UserCard::find();
|
||||||
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
|
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
|
||||||
|
@ -8,6 +8,7 @@ use yii\widgets\ListView;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
/* @var $total */
|
||||||
|
|
||||||
$this->title = 'Профили';
|
$this->title = 'Профили';
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
@ -19,7 +20,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
|
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?php
|
||||||
|
echo GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'filterModel' => $searchModel,
|
'filterModel' => $searchModel,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
@ -83,5 +85,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn'],
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
],
|
],
|
||||||
]); ?>
|
]);
|
||||||
|
echo "<h3>Сумма зарплат: " . $total . "</h3>";
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
@ -47,6 +47,7 @@
|
|||||||
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday'],
|
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday'],
|
||||||
['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'],
|
['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'],
|
||||||
['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'],
|
['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'],
|
||||||
|
['label' => 'Календарь ДР', 'icon' => 'calendar', 'url' => ['/calendar/calendar'], 'active' => \Yii::$app->controller->id == 'calendar'],
|
||||||
|
|
||||||
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
|
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
|
||||||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],
|
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],
|
||||||
|
7
backend/web/js/site.js
Normal file
7
backend/web/js/site.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
$(function(){
|
||||||
|
$('#options').change(function(){
|
||||||
|
month = $('#options :selected').val();
|
||||||
|
history.pushState({}, '', month);
|
||||||
|
$.pjax.reload({container:"#reload"});
|
||||||
|
})
|
||||||
|
});
|
@ -26,6 +26,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord
|
|||||||
const TYPE_COMPANY = 2;
|
const TYPE_COMPANY = 2;
|
||||||
const TYPE_BALANCE = 3;
|
const TYPE_BALANCE = 3;
|
||||||
const TYPE_NOTE = 4;
|
const TYPE_NOTE = 4;
|
||||||
|
const TYPE_ACCESS = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -23,6 +23,7 @@ class UseField extends \yii\db\ActiveRecord
|
|||||||
const USE_COMPANY = 2;
|
const USE_COMPANY = 2;
|
||||||
const USE_BALANCE = 3;
|
const USE_BALANCE = 3;
|
||||||
const USE_NOTE = 4;
|
const USE_NOTE = 4;
|
||||||
|
const USE_ACCESS = 5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +73,8 @@ class UseField extends \yii\db\ActiveRecord
|
|||||||
self::USE_PROJECT => 'Проект',
|
self::USE_PROJECT => 'Проект',
|
||||||
self::USE_COMPANY => 'Компания',
|
self::USE_COMPANY => 'Компания',
|
||||||
self::USE_BALANCE => 'Баланс',
|
self::USE_BALANCE => 'Баланс',
|
||||||
self::USE_NOTE => 'Заметка'
|
self::USE_NOTE => 'Заметка',
|
||||||
|
self::USE_ACCESS => 'Доступ'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
frontend/web/log.txt
Executable file
0
frontend/web/log.txt
Executable file
Loading…
Reference in New Issue
Block a user