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 @@ -
+ +
+ + '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; = Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?> - = GridView::widget([ + $dataProvider, 'filterModel' => $searchModel, 'columns' => [ @@ -83,5 +85,7 @@ $this->params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\ActionColumn'], ], - ]); ?> + ]); + echo "