+++ /dev/null
-<?php
-
-namespace app\controllers;
-
-use yii_app\records\AdminPositions;
-use yii\data\ActiveDataProvider;
-use yii\web\Controller;
-use yii\web\NotFoundHttpException;
-use yii\filters\VerbFilter;
-
-/**
- * AdminPositionsController implements the CRUD actions for AdminPositions model.
- */
-class AdminPositionsController extends Controller
-{
- /**
- * @inheritDoc
- */
- public function behaviors()
- {
- return array_merge(
- parent::behaviors(),
- [
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
- ],
- ],
- ]
- );
- }
-
- /**
- * Lists all AdminPositions models.
- *
- * @return string
- */
- public function actionIndex()
- {
- $dataProvider = new ActiveDataProvider([
- 'query' => AdminPositions::find(),
- /*
- 'pagination' => [
- 'pageSize' => 50
- ],
- 'sort' => [
- 'defaultOrder' => [
- 'id' => SORT_DESC,
- ]
- ],
- */
- ]);
-
- return $this->render('index', [
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- /**
- * Displays a single AdminPositions model.
- * @param int $id ID
- * @return string
- * @throws NotFoundHttpException if the model cannot be found
- */
- public function actionView($id)
- {
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
-
- /**
- * Creates a new AdminPositions model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return string|\yii\web\Response
- */
- public function actionCreate()
- {
- $model = new AdminPositions();
-
- if ($this->request->isPost) {
- if ($model->load($this->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->id]);
- }
- } else {
- $model->loadDefaultValues();
- }
-
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
-
- /**
- * Updates an existing AdminPositions model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param int $id ID
- * @return string|\yii\web\Response
- * @throws NotFoundHttpException if the model cannot be found
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
-
- if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->id]);
- }
-
- return $this->render('update', [
- 'model' => $model,
- ]);
- }
-
- /**
- * Deletes an existing AdminPositions model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param int $id ID
- * @return \yii\web\Response
- * @throws NotFoundHttpException if the model cannot be found
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
-
- return $this->redirect(['index']);
- }
-
- /**
- * Finds the AdminPositions model based on its primary key value.
- * If the model is not found, a 404 HTTP exception will be thrown.
- * @param int $id ID
- * @return AdminPositions the loaded model
- * @throws NotFoundHttpException if the model cannot be found
- */
- protected function findModel($id)
- {
- if (($model = AdminPositions::findOne(['id' => $id])) !== null) {
- return $model;
- }
-
- throw new NotFoundHttpException('The requested page does not exist.');
- }
-}
+++ /dev/null
-<?php
-
-use yii\db\Migration;
-
-/**
- * Handles the creation of table `{{%admin_positions}}`.
- */
-class m251027_071121_create_admin_positions_table extends Migration
-{
- /**
- * {@inheritdoc}
- */
- const TABLE_NAME = 'erp24.admin_positions';
-
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
-
- if (!isset($tableSchema)) {
- $this->createTable(self::TABLE_NAME, [
- 'id' => $this->primaryKey(),
- 'name' => $this->string()->notNull()->comment('Наименование должности'),
- 'alias' => $this->string()->notNull()->comment('Алиас должности'),
- 'salary' => $this->decimal(10, 2)->notNull()->comment('Ставка в рублях'),
- 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
- 'created_by' => $this->integer()->notNull()->comment('ИД создателя'),
- 'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
- 'updated_by' => $this->integer()->null()->comment('ИД редактировавшего'),
- ]);
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- $this->dropTable('{{%admin_positions}}');
- }
-}
+++ /dev/null
-<?php
-
-use yii\helpers\Html;
-use yii\widgets\ActiveForm;
-
-/** @var yii\web\View $this */
-/** @var yii_app\records\AdminPositions $model */
-/** @var yii\widgets\ActiveForm $form */
-?>
-
-<div class="admin-positions-form">
-
- <?php $form = ActiveForm::begin(); ?>
-
- <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
-
- <?= $form->field($model, 'alias')->hiddenInput()->label(false) ?>
-
- <?= $form->field($model, 'salary')->textInput() ?>
-
- <div class="form-group">
- <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
- </div>
-
- <?php ActiveForm::end(); ?>
-
-</div>
-
-<?php
-$this->registerJs("
-$(document).ready(function() {
- // Функция транслитерации русского текста в латиницу
- function transliterate(text) {
- var translitMap = {
- 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'e',
- 'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm',
- 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
- 'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch',
- 'ъ': '', 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya',
- 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'E',
- 'Ж': 'Zh', 'З': 'Z', 'И': 'I', 'Й': 'Y', 'К': 'K', 'Л': 'L', 'М': 'M',
- 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U',
- 'Ф': 'F', 'Х': 'Kh', 'Ц': 'Ts', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Shch',
- 'Ъ': '', 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya'
- };
-
- return text.split('').map(function(char) {
- return translitMap[char] || char;
- }).join('').replace(/[^a-zA-Z0-9-_]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
- }
-
- // Обработчик изменения поля name
- $('#adminpositions-name').on('input', function() {
- var nameValue = $(this).val();
- var aliasValue = transliterate(nameValue);
- $('#adminpositions-alias').val(aliasValue);
- });
-});
-");
-?>
+++ /dev/null
-<?php
-
-use yii\helpers\Html;
-
-/** @var yii\web\View $this */
-/** @var yii_app\records\AdminPositions $model */
-
-$this->title = 'Создание должности сотрудников';
-$this->params['breadcrumbs'][] = ['label' => 'Admin Positions', 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-<div class="admin-positions-create p-4">
-
- <h1><?= Html::encode($this->title) ?></h1>
-
- <?= $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-</div>
+++ /dev/null
-<?php
-
-use yii_app\records\AdminPositions;
-use yii\helpers\Html;
-use yii\helpers\Url;
-use yii\grid\ActionColumn;
-use yii\grid\GridView;
-
-/** @var yii\web\View $this */
-/** @var yii\data\ActiveDataProvider $dataProvider */
-
-$this->title = 'Должности сотрудников';
-$this->params['breadcrumbs'][] = $this->title;
-?>
-<div class="admin-positions-index p-4">
-
- <h1><?= Html::encode($this->title) ?></h1>
-
- <p>
- <?= Html::a('Добавить должность', ['create'], ['class' => 'btn btn-success']) ?>
- </p>
-
-
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
-
- 'id',
- 'name',
- 'alias',
- 'salary',
- 'created_at',
- 'created_by',
- 'updated_at',
- 'updated_by',
- [
- 'class' => ActionColumn::class,
- 'urlCreator' => function ($action, AdminPositions $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model->id]);
- }
- ],
- ],
- ]); ?>
-
-
-</div>
+++ /dev/null
-<?php
-
-use yii\helpers\Html;
-
-/** @var yii\web\View $this */
-/** @var yii_app\records\AdminPositions $model */
-
-$this->title = 'Изменение должности: ' . $model->name;
-$this->params['breadcrumbs'][] = ['label' => 'Admin Positions', 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
-$this->params['breadcrumbs'][] = 'Update';
-?>
-<div class="admin-positions-update p-4">
-
- <h1><?= Html::encode($this->title) ?></h1>
-
- <?= $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-</div>
+++ /dev/null
-<?php
-
-use yii\helpers\Html;
-use yii\widgets\DetailView;
-
-/** @var yii\web\View $this */
-/** @var yii_app\records\AdminPositions $model */
-
-$this->title = $model->name;
-$this->params['breadcrumbs'][] = ['label' => 'Admin Positions', 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-\yii\web\YiiAsset::register($this);
-?>
-<div class="admin-positions-view p-4">
-<?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary mb-4']) ?>
- <h1><?= Html::encode($this->title) ?></h1>
-
- <p>
- <?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
- <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => 'Вы уверены что хотите удалить?',
- 'method' => 'post',
- ],
- ]) ?>
- </p>
-
- <?= DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'id',
- 'name',
- 'alias',
- 'salary',
- 'created_at',
- 'created_by',
- 'updated_at',
- 'updated_by',
- ],
- ]) ?>
-
-</div>