Oleg K пре 5 година
родитељ
комит
c6b36d7a90

+ 128 - 0
app/controllers/SettingsController.php

@@ -0,0 +1,128 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Settings;
+use app\models\SettingSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * SettingsController implements the CRUD actions for Settings model.
+ */
+class SettingsController extends Controller
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Settings models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        if (!Settings::find()->count()) {
+            //return $this->render('create', ['model' => new Settings()]);
+            $this->redirect('settings/create');
+        } else {
+            $this->redirect(['update', 'id' => Settings::find()->one()->id]);
+            //return $this->render('update', ['model' => Settings::find()->one()]);
+        }
+    }
+
+    /**
+     * Displays a single Settings model.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Settings model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Settings();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+
+        return $this->render('create', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Updates an existing Settings model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            //return $this->redirect(['view', 'id' => $model->id]);
+            return $this->redirect(['index']);
+        }
+
+        return $this->render('update', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Deletes an existing Settings model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Settings model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Settings the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Settings::findOne($id)) !== null) {
+            return $model;
+        }
+
+        throw new NotFoundHttpException('The requested page does not exist.');
+    }
+}

+ 70 - 0
app/models/SettingSearch.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace app\models;
+
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Settings;
+
+/**
+ * SettingSearch represents the model behind the search form of `app\models\Settings`.
+ */
+class SettingSearch extends Settings
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'invoce', 'act', 'time', 'created_at', 'updated_at'], 'integer'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Settings::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'invoce' => $this->invoce,
+            'act' => $this->act,
+            'time' => $this->time,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+        ]);
+
+        return $dataProvider;
+    }
+}

+ 66 - 0
app/models/Settings.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%settings}}".
+ *
+ * @property int $id
+ * @property int $invoce
+ * @property int $act
+ * @property int $time
+ * @property int $created_at
+ * @property int $updated_at
+ */
+class Settings extends ActiveRecord
+{
+    public function behaviors()
+    {
+        return [
+            'timestamp' => [
+                'class' => 'yii\behaviors\TimestampBehavior',
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%settings}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['invoce', 'act', 'time'], 'required'],
+            [['invoce', 'act', 'time', 'created_at', 'updated_at'], 'integer'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'invoce' => 'Invoce',
+            'act' => 'Act',
+            'time' => 'Time',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+        ];
+    }
+}

+ 39 - 0
app/views/settings/_form.php

@@ -0,0 +1,39 @@
+<?php
+
+use yii\helpers\Html;
+use yii\bootstrap4\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Settings */
+/* @var $form yii\widgets\ActiveForm */
+
+?>
+
+<div class="settings-form">
+
+    <?php $form = ActiveForm::begin(); ?>
+
+    <?php
+    $dayItems = [];
+    $timeItems = [];
+    for ($i = 1; $i <= 31; $i++){
+        $dayItems[$i] = $i;
+        if($i >= 8 && $i <= 18 ){
+            $timeItems[$i] = "${i}:00";
+        }
+    }
+    ?>
+
+    <div class="row">
+        <div class="col-4 col-xs-12"><?= $form->field($model, 'invoce')->dropDownList($dayItems, ['prompt' => 'select']); ?></div>
+        <div class="col-4 col-xs-12"><?= $form->field($model, 'act')->dropDownList($dayItems, ['prompt' => 'select']); ?></div>
+        <div class="col-4 col-xs-12"><?= $form->field($model, 'time')->dropDownList($timeItems, ['prompt' => 'select']); ?></div>
+    </div>
+
+    <div class="form-group">
+        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>

+ 37 - 0
app/views/settings/_search.php

@@ -0,0 +1,37 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\SettingSearch */
+/* @var $form yii\widgets\ActiveForm */
+?>
+
+<div class="settings-search">
+
+    <?php $form = ActiveForm::begin([
+        'action' => ['index'],
+        'method' => 'get',
+    ]); ?>
+
+    <?= $form->field($model, 'id') ?>
+
+    <?= $form->field($model, 'invoce') ?>
+
+    <?= $form->field($model, 'act') ?>
+
+    <?= $form->field($model, 'time') ?>
+
+    <?= $form->field($model, 'created_at') ?>
+
+    <?php // echo $form->field($model, 'updated_at') ?>
+
+    <div class="form-group">
+        <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
+        <?= Html::resetButton('Reset', ['class' => 'btn btn-outline-secondary']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>

+ 22 - 0
app/views/settings/create.php

@@ -0,0 +1,22 @@
+<?php
+
+use yii\helpers\Html;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Settings */
+
+$this->title = 'Create Settings';
+$this->params['breadcrumbs'][] = ['label' => 'Settings', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="settings-create">
+
+    <div class="card card-primary card-outline">
+        <div class="card-body">
+            <?= $this->render('_form', [
+                'model' => $model,
+            ]) ?>
+        </div>
+    </div>
+
+</div>

+ 40 - 0
app/views/settings/index.php

@@ -0,0 +1,40 @@
+<?php
+
+use yii\helpers\Html;
+use yii\grid\GridView;
+
+/* @var $this yii\web\View */
+/* @var $searchModel app\models\SettingSearch */
+/* @var $dataProvider yii\data\ActiveDataProvider */
+
+$this->title = 'Settings';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+<div class="settings-index">
+    <div class="card card-primary card-outline">
+        <div class="card-header">
+            <div class="card-tools">
+                <?= Html::a('Create Settings', ['create'], ['class' => 'btn btn-success']) ?>
+            </div>
+        </div>
+        <div class="card-body">
+            <?= GridView::widget([
+                'dataProvider' => $dataProvider,
+                'filterModel' => $searchModel,
+                'columns' => [
+                    ['class' => 'yii\grid\SerialColumn'],
+
+                    'id',
+                    'invoce',
+                    'act',
+                    'time:datetime',
+                    'created_at',
+                    //'updated_at',
+
+                    ['class' => 'yii\grid\ActionColumn'],
+                ],
+            ]); ?>
+        </div>
+    </div>
+</div>

+ 31 - 0
app/views/settings/update.php

@@ -0,0 +1,31 @@
+<?php
+
+use yii\helpers\Html;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Settings */
+
+$this->title = 'Update Settings: ' . $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Settings', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+
+$this->params['formId'] = 'settings-form';
+?>
+<div class="settings-update">
+
+    <div class="card card-primary card-outline">
+        <!--<div class="card-header">
+            <div class="card-tools">
+                <?/*= Html::submitButton('Save', ['class' => 'btn btn-success']) */?>
+                <?/*= Html::button('Saveeee', ['type' => 'submit', 'form' => $this->params['formId'],'class' => 'btn btn-success']) */?>
+            </div>
+        </div>-->
+        <div class="card-body">
+            <?= $this->render('_form', [
+                'model' => $model,
+            ]) ?>
+        </div>
+    </div>
+
+</div>

+ 44 - 0
app/views/settings/view.php

@@ -0,0 +1,44 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Settings */
+
+$this->title = $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Settings', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+<div class="settings-view">
+
+    <div class="card card-primary card-outline">
+        <div class="card-header">
+            <div class="card-tools">
+                <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+                <?= Html::a('Delete', ['delete', 'id' => $model->id], [
+                    'class' => 'btn btn-danger',
+                    'data' => [
+                        'confirm' => 'Are you sure you want to delete this item?',
+                        'method' => 'post',
+                    ],
+                ]) ?>
+            </div>
+        </div>
+        <div class="card-body">
+            <?= DetailView::widget([
+                'model' => $model,
+                'attributes' => [
+                    'id',
+                    'invoce',
+                    'act',
+                    'time',
+                    'created_at:datetime',
+                    'updated_at:datetime',
+                ],
+            ]) ?>
+        </div>
+    </div>
+
+</div>

+ 157 - 0
reactcrmyii.sql

@@ -0,0 +1,157 @@
+-- phpMyAdmin SQL Dump
+-- version 5.0.4
+-- https://www.phpmyadmin.net/
+--
+-- Хост: localhost
+-- Время создания: Дек 11 2020 г., 15:33
+-- Версия сервера: 10.4.16-MariaDB
+-- Версия PHP: 7.4.12
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+START TRANSACTION;
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- База данных: `reactcrmyii`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Структура таблицы `migration`
+--
+
+CREATE TABLE `migration` (
+  `version` varchar(180) NOT NULL,
+  `apply_time` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Дамп данных таблицы `migration`
+--
+
+INSERT INTO `migration` (`version`, `apply_time`) VALUES
+('m000000_000000_base', 1607420159);
+
+-- --------------------------------------------------------
+
+--
+-- Структура таблицы `organizations`
+--
+
+CREATE TABLE `organizations` (
+  `id` int(11) UNSIGNED NOT NULL,
+  `name` varchar(191) NOT NULL,
+  `short_name` varchar(191) DEFAULT NULL,
+  `vat` tinyint(1) DEFAULT NULL,
+  `edrpou` int(11) DEFAULT NULL,
+  `address_1` varchar(191) DEFAULT NULL,
+  `address_2` varchar(191) DEFAULT NULL,
+  `address_3` varchar(191) DEFAULT NULL,
+  `comment` text DEFAULT NULL,
+  `bank_id` int(11) DEFAULT NULL,
+  `person_id` int(11) DEFAULT NULL,
+  `created_at` int(11) DEFAULT NULL,
+  `updated_at` int(11) DEFAULT NULL,
+  `deleted_at` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- --------------------------------------------------------
+
+--
+-- Структура таблицы `persons`
+--
+
+CREATE TABLE `persons` (
+  `id` bigint(20) UNSIGNED NOT NULL,
+  `org_id` int(11) NOT NULL,
+  `first_name` varchar(191) DEFAULT NULL,
+  `last_name` varchar(191) DEFAULT NULL,
+  `position` varchar(191) DEFAULT NULL,
+  `created_at` int(11) DEFAULT NULL,
+  `updated_at` int(11) DEFAULT NULL,
+  `deleted_at` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- --------------------------------------------------------
+
+--
+-- Структура таблицы `settings`
+--
+
+CREATE TABLE `settings` (
+  `id` int(11) NOT NULL,
+  `invoce` int(11) NOT NULL,
+  `act` int(11) NOT NULL,
+  `time` int(11) NOT NULL,
+  `created_at` int(11) NOT NULL,
+  `updated_at` int(11) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+--
+-- Дамп данных таблицы `settings`
+--
+
+INSERT INTO `settings` (`id`, `invoce`, `act`, `time`, `created_at`, `updated_at`) VALUES
+(3, 17, 2, 16, 1607605415, 1607605612);
+
+--
+-- Индексы сохранённых таблиц
+--
+
+--
+-- Индексы таблицы `migration`
+--
+ALTER TABLE `migration`
+  ADD PRIMARY KEY (`version`);
+
+--
+-- Индексы таблицы `organizations`
+--
+ALTER TABLE `organizations`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- Индексы таблицы `persons`
+--
+ALTER TABLE `persons`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- Индексы таблицы `settings`
+--
+ALTER TABLE `settings`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- AUTO_INCREMENT для сохранённых таблиц
+--
+
+--
+-- AUTO_INCREMENT для таблицы `organizations`
+--
+ALTER TABLE `organizations`
+  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+--
+-- AUTO_INCREMENT для таблицы `persons`
+--
+ALTER TABLE `persons`
+  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
+
+--
+-- AUTO_INCREMENT для таблицы `settings`
+--
+ALTER TABLE `settings`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+COMMIT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;