diff --git a/backend/assets/AppAsset.php b/backend/assets/AppAsset.php index 940c0af..21e4b4b 100755 --- a/backend/assets/AppAsset.php +++ b/backend/assets/AppAsset.php @@ -15,6 +15,7 @@ class AppAsset extends AssetBundle 'css/site.css', ]; public $js = [ + 'js/site.js', ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/backend/config/main.php b/backend/config/main.php index f00ca39..1a97a25 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -41,6 +41,9 @@ return [ 'notes' => [ 'class' => 'backend\modules\notes\Notes', ], + 'calendar' => [ + 'class' => 'backend\modules\calendar\Calendar', + ], ], 'components' => [ 'request' => [ diff --git a/backend/modules/accesses/models/Accesses.php b/backend/modules/accesses/models/Accesses.php index 93aed81..741b21e 100755 --- a/backend/modules/accesses/models/Accesses.php +++ b/backend/modules/accesses/models/Accesses.php @@ -4,6 +4,7 @@ namespace app\modules\accesses\models; use common\classes\Debug; +use common\models\FieldsValueNew; use Yii; /** @@ -17,5 +18,73 @@ use Yii; 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 + } } \ No newline at end of file diff --git a/backend/modules/accesses/views/accesses/_form.php b/backend/modules/accesses/views/accesses/_form.php index 51f16f9..0cd4345 100755 --- a/backend/modules/accesses/views/accesses/_form.php +++ b/backend/modules/accesses/views/accesses/_form.php @@ -1,5 +1,7 @@ -
Пользователи diff --git a/backend/modules/calendar/Calendar.php b/backend/modules/calendar/Calendar.php new file mode 100644 index 0000000..f16ab3d --- /dev/null +++ b/backend/modules/calendar/Calendar.php @@ -0,0 +1,24 @@ +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, + ]); + } +} diff --git a/backend/modules/calendar/views/calendar/index.php b/backend/modules/calendar/views/calendar/index.php new file mode 100644 index 0000000..ead41d5 --- /dev/null +++ b/backend/modules/calendar/views/calendar/index.php @@ -0,0 +1,42 @@ +
+ +

+ +

+ + 'reload']); +echo GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'fio', + 'dob', + ['class' => 'yii\grid\ActionColumn'], + ], +]); +Pjax::end(); +?> \ No newline at end of file diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index 094d4d8..6c4f95f 100755 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -47,9 +47,21 @@ class UserCardController extends Controller $searchModel = new UserCardSearch(); $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', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, + 'total' => $total, ]); } diff --git a/backend/modules/card/models/UserCard.php b/backend/modules/card/models/UserCard.php index 9365b92..ebee681 100755 --- a/backend/modules/card/models/UserCard.php +++ b/backend/modules/card/models/UserCard.php @@ -105,7 +105,7 @@ class UserCard extends \common\models\UserCard parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub } - public function generateUser($email, $status) + public static function generateUser($email, $status) { $user = new User(); $auth_key = Yii::$app->security->generateRandomString(); @@ -121,18 +121,18 @@ class UserCard extends \common\models\UserCard $user->save(); $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; } - public function genereateLinlkOnUser($user_card, $user_id) + public static function genereateLinlkOnUser($user_card, $user_id) { $user_card->id_user = $user_id; $user_card->save(); } - public function generateUserForUserCard($card_id = null) + public static function generateUserForUserCard($card_id = null) { $userCardQuery = UserCard::find(); $card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]); diff --git a/backend/modules/card/views/user-card/index.php b/backend/modules/card/views/user-card/index.php index 622adeb..daa3136 100755 --- a/backend/modules/card/views/user-card/index.php +++ b/backend/modules/card/views/user-card/index.php @@ -8,6 +8,7 @@ use yii\widgets\ListView; /* @var $this yii\web\View */ /* @var $searchModel backend\modules\card\models\UserCardSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ +/* @var $total */ $this->title = 'Профили'; $this->params['breadcrumbs'][] = $this->title; @@ -19,7 +20,8 @@ $this->params['breadcrumbs'][] = $this->title; 'btn btn-success']) ?>

- $dataProvider, 'filterModel' => $searchModel, 'columns' => [ @@ -83,5 +85,7 @@ $this->params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\ActionColumn'], ], - ]); ?> + ]); + echo "

Сумма зарплат: " . $total . "

"; + ?>
\ No newline at end of file diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index 7dea35c..9a4d4f9 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -47,6 +47,7 @@ ['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' => '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' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']], diff --git a/backend/web/js/site.js b/backend/web/js/site.js new file mode 100644 index 0000000..510e486 --- /dev/null +++ b/backend/web/js/site.js @@ -0,0 +1,7 @@ +$(function(){ + $('#options').change(function(){ + month = $('#options :selected').val(); + history.pushState({}, '', month); + $.pjax.reload({container:"#reload"}); + }) +}); \ No newline at end of file diff --git a/common/models/FieldsValueNew.php b/common/models/FieldsValueNew.php index ca60f82..0dd7d32 100755 --- a/common/models/FieldsValueNew.php +++ b/common/models/FieldsValueNew.php @@ -26,6 +26,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord const TYPE_COMPANY = 2; const TYPE_BALANCE = 3; const TYPE_NOTE = 4; + const TYPE_ACCESS = 5; /** * {@inheritdoc} diff --git a/common/models/UseField.php b/common/models/UseField.php index c451261..1209d3a 100755 --- a/common/models/UseField.php +++ b/common/models/UseField.php @@ -23,6 +23,7 @@ class UseField extends \yii\db\ActiveRecord const USE_COMPANY = 2; const USE_BALANCE = 3; const USE_NOTE = 4; + const USE_ACCESS = 5; /** @@ -72,7 +73,8 @@ class UseField extends \yii\db\ActiveRecord self::USE_PROJECT => 'Проект', self::USE_COMPANY => 'Компания', self::USE_BALANCE => 'Баланс', - self::USE_NOTE => 'Заметка' + self::USE_NOTE => 'Заметка', + self::USE_ACCESS => 'Доступ' ]; } diff --git a/frontend/web/log.txt b/frontend/web/log.txt new file mode 100755 index 0000000..e69de29