Quellcode durchsuchen

organizations crud

Oleg K vor 5 Jahren
Ursprung
Commit
cb1d59ac70

+ 127 - 0
app/controllers/OrganizationsController.php

@@ -0,0 +1,127 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Organizations;
+use app\models\OrganizationsSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * OrganizationsController implements the CRUD actions for Organizations model.
+ */
+class OrganizationsController extends Controller
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Organizations models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new OrganizationsSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider->getModels(),
+        ]);
+    }
+
+    /**
+     * Displays a single Organizations 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 Organizations model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Organizations();
+
+        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 Organizations 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->render('update', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Deletes an existing Organizations 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 Organizations model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Organizations the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Organizations::findOne($id)) !== null) {
+            return $model;
+        }
+
+        throw new NotFoundHttpException('The requested page does not exist.');
+    }
+}

+ 91 - 0
app/models/Organizations.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%organizations}}".
+ *
+ * @property int $id
+ * @property string $name
+ * @property string|null $short_name
+ * @property int|null $vat
+ * @property int|null $edrpou
+ * @property string|null $address_1
+ * @property string|null $address_2
+ * @property string|null $address_3
+ * @property string|null $comment
+ * @property int|null $bank_id
+ * @property int|null $person_id
+ * @property int|null $created_at
+ * @property int|null $updated_at
+ * @property int|null $deleted_at
+ *
+ * @property Persons[] $persons
+ */
+class Organizations extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%organizations}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['name'], 'required'],
+            [['vat', 'edrpou', 'bank_id', 'person_id', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
+            [['comment'], 'string'],
+            [['name', 'short_name', 'address_1', 'address_2', 'address_3'], 'string', 'max' => 191],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'name' => 'Name',
+            'short_name' => 'Short Name',
+            'vat' => 'Vat',
+            'edrpou' => 'Edrpou',
+            'address_1' => 'Address 1',
+            'address_2' => 'Address 2',
+            'address_3' => 'Address 3',
+            'comment' => 'Comment',
+            'bank_id' => 'Bank ID',
+            'person_id' => 'Person ID',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+            'deleted_at' => 'Deleted At',
+        ];
+    }
+
+    /**
+     * Gets query for [[Persons]].
+     *
+     * @return \yii\db\ActiveQuery|PersonsQuery
+     */
+    public function getPersons()
+    {
+        return $this->hasMany(Persons::className(), ['org_id' => 'id'])->inverseOf('org');
+    }
+
+    /**
+     * {@inheritdoc}
+     * @return OrganizationsQuery the active query used by this AR class.
+     */
+    public static function find()
+    {
+        return new OrganizationsQuery(get_called_class());
+    }
+}

+ 34 - 0
app/models/OrganizationsQuery.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace app\models;
+
+/**
+ * This is the ActiveQuery class for [[Organizations]].
+ *
+ * @see Organizations
+ */
+class OrganizationsQuery extends \yii\db\ActiveQuery
+{
+    /*public function active()
+    {
+        return $this->andWhere('[[status]]=1');
+    }*/
+
+    /**
+     * {@inheritdoc}
+     * @return Organizations[]|array
+     */
+    public function all($db = null)
+    {
+        return parent::all($db);
+    }
+
+    /**
+     * {@inheritdoc}
+     * @return Organizations|array|null
+     */
+    public function one($db = null)
+    {
+        return parent::one($db);
+    }
+}

+ 80 - 0
app/models/OrganizationsSearch.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace app\models;
+
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Organizations;
+
+/**
+ * OrganizationsSearch represents the model behind the search form of `app\models\Organizations`.
+ */
+class OrganizationsSearch extends Organizations
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'vat', 'edrpou', 'bank_id', 'person_id', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
+            [['name', 'short_name', 'address_1', 'address_2', 'address_3', 'comment'], 'safe'],
+        ];
+    }
+
+    /**
+     * {@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 = Organizations::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,
+            'vat' => $this->vat,
+            'edrpou' => $this->edrpou,
+            'bank_id' => $this->bank_id,
+            'person_id' => $this->person_id,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+            'deleted_at' => $this->deleted_at,
+        ]);
+
+        $query->andFilterWhere(['like', 'name', $this->name])
+            ->andFilterWhere(['like', 'short_name', $this->short_name])
+            ->andFilterWhere(['like', 'address_1', $this->address_1])
+            ->andFilterWhere(['like', 'address_2', $this->address_2])
+            ->andFilterWhere(['like', 'address_3', $this->address_3])
+            ->andFilterWhere(['like', 'comment', $this->comment]);
+
+        return $dataProvider;
+    }
+}

+ 17 - 7
app/views/layouts/main.php

@@ -39,12 +39,16 @@ AdminLteAsset::register($this);
             'class' => 'main-header navbar navbar-expand navbar-white navbar-light',
         ],
     ]);
+
+    //foreach ($this->params['actionButtons'] as $button)
+    //$as = [['label' => 'Home', 'url' => ['/site/index']], $this->params['actionButtons']];
     echo Nav::widget([
         'encodeLabels' => false,
-        'options' => ['class' => 'navbar-nav'],
-        'items' => [
+        'options' => ['class' => 'navbar-nav w-100'],
+        'items' => array_merge(
+        [
             ['label' => '<i class="fas fa-bars"></i>', 'url' => '#', 'options' =>['data-widget' => 'pushmenu']],
-            ['label' => 'Home', 'url' => ['/site/index']],
+            //['label' => 'Home', 'url' => ['/site/index'], 'options' =>['class' => 'ml-auto']],
             /*['label' => 'About', 'url' => ['/site/about']],
             ['label' => 'Contact', 'url' => ['/site/contact']],
             Yii::$app->user->isGuest ? (
@@ -60,14 +64,20 @@ AdminLteAsset::register($this);
                 . '</li>'
             )*/
         ],
+            isset($this->params['actionButtons']) ? $this->params['actionButtons'] : [],
+        [
+                ['label' => 'Logout (' . Yii::$app->user->identity->username . ') <i class="fas fa-sign-out-alt"></i>', 'url' => ['/site/logout'], 'options' => ['class'=>'ml-auto']]
+]
+
+        )
     ]);
-    echo Nav::widget([
+    /*echo Nav::widget([
         'encodeLabels' => false,
         'options' => ['class' => 'navbar-nav ml-auto'],
         'items' => [
-            ['label' => 'Logout (' . Yii::$app->user->identity->username . ') <i class="fas fa-sign-out-alt"></i>', 'url' => ['/site/logout']],
+
         ],
-    ]);
+    ]);*/
     NavBar::end();
     ?>
 
@@ -99,7 +109,7 @@ AdminLteAsset::register($this);
                     'items' => [
                         ['label' => '<i class="nav-icon fas fa-tachometer-alt"></i> <p>Dashboard</p>', 'url' => ['/dashboard']], //'active' => $this->context->route;
                         ['label' => '<i class="nav-icon fas fa-file-invoice"></i> <p>Bills</p>', 'url' => ['/bills']],
-                        ['label' => '<i class="nav-icon fas fa-building"></i> <p>Organizations</p>', 'url' => ['/organizations']],
+                        ['label' => '<i class="nav-icon fas fa-building"></i> <p>Organizations</p>', 'url' => ['/organizations'], 'active' => Yii::$app->controller->id == 'organizations'],
                         ['label' => '<i class="nav-icon fas fa-address-book"></i> <p>Our contacts</p>', 'url' => ['/contacts']],
                         ['label' => '<i class="nav-icon fas fa-cogs"></i> <p>Settings</p>', 'url' => ['settings/'], 'active' => Yii::$app->controller->id == 'settings'],
                     ],

+ 47 - 0
app/views/organizations/_form.php

@@ -0,0 +1,47 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Organizations */
+/* @var $form yii\widgets\ActiveForm */
+?>
+
+<div class="organizations-form">
+
+    <?php $form = ActiveForm::begin(); ?>
+
+    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'short_name')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'vat')->textInput() ?>
+
+    <?= $form->field($model, 'edrpou')->textInput() ?>
+
+    <?= $form->field($model, 'address_1')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'address_2')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'address_3')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'comment')->textarea(['rows' => 6]) ?>
+
+    <?= $form->field($model, 'bank_id')->textInput() ?>
+
+    <?= $form->field($model, 'person_id')->textInput() ?>
+
+    <?= $form->field($model, 'created_at')->textInput() ?>
+
+    <?= $form->field($model, 'updated_at')->textInput() ?>
+
+    <?= $form->field($model, 'deleted_at')->textInput() ?>
+
+    <div class="form-group">
+        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>

+ 53 - 0
app/views/organizations/_search.php

@@ -0,0 +1,53 @@
+<?php
+
+use yii\helpers\Html;
+use yii\bootstrap4\ActiveForm;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\OrganizationsSearch */
+/* @var $form yii\widgets\ActiveForm */
+?>
+
+<div class="organizations-search">
+
+    <?php $form = ActiveForm::begin([
+        'action' => ['index'],
+        'method' => 'get',
+    ]); ?>
+
+    <?= $form->field($model, 'id') ?>
+
+    <?= $form->field($model, 'name') ?>
+
+    <?= $form->field($model, 'short_name') ?>
+
+    <?= $form->field($model, 'vat') ?>
+
+    <?= $form->field($model, 'edrpou') ?>
+
+    <?php // echo $form->field($model, 'address_1') ?>
+
+    <?php // echo $form->field($model, 'address_2') ?>
+
+    <?php // echo $form->field($model, 'address_3') ?>
+
+    <?php // echo $form->field($model, 'comment') ?>
+
+    <?php // echo $form->field($model, 'bank_id') ?>
+
+    <?php // echo $form->field($model, 'person_id') ?>
+
+    <?php // echo $form->field($model, 'created_at') ?>
+
+    <?php // echo $form->field($model, 'updated_at') ?>
+
+    <?php // echo $form->field($model, 'deleted_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>

+ 20 - 0
app/views/organizations/create.php

@@ -0,0 +1,20 @@
+<?php
+
+use yii\helpers\Html;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Organizations */
+
+$this->title = 'Create Organizations';
+$this->params['breadcrumbs'][] = ['label' => 'Organizations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="organizations-create">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?= $this->render('_form', [
+        'model' => $model,
+    ]) ?>
+
+</div>

+ 51 - 0
app/views/organizations/index.php

@@ -0,0 +1,51 @@
+<?php
+
+use yii\helpers\Html;
+use yii\grid\GridView;
+use yii\widgets\Pjax;
+/* @var $this yii\web\View */
+/* @var $searchModel app\models\OrganizationsSearch */
+/* @var $dataProvider yii\data\ActiveDataProvider */
+
+$this->title = 'Organizations';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="organizations-index">
+    <p>
+        <?= Html::a('Create Organizations', ['create'], ['class' => 'btn btn-success']) ?>
+    </p>
+
+    <?php //Pjax::begin(); ?>
+    <?php //echo $this->render('_search', ['model' => $searchModel]); ?>
+    <?php //Pjax::end(); ?>
+
+    <div class="row">
+    <?php foreach ($dataProvider as $org): ?>
+        <div class="col-md-3">
+            <div class="card card-outline card-primary collapsed-card">
+                <div class="card-header">
+                    <h3 class="card-title" data-toggle="tooltip" data-placement="top" title="<?= strlen($org['edrpou']) <= 8 ? 'EDRPOU' : 'INN'; ?>: <?= $org['edrpou']; ?>">
+                        <?= Html::a(
+                                $org['short_name'] . '<span class="d-block text-muted small">' . $org['name'] . '</span>',
+                                ['organizations/view', 'id'=> $org['id']],
+                                ['class'=>['text-dark']]);
+                        ?>
+                    </h3>
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="collapse">
+                            <i class="fas fa-plus"></i>
+                        </button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    <span class="text-muted"><?= strlen($org['edrpou']) <= 8 ? 'EDRPOU' : 'INN'; ?>:</span> <?= $org['edrpou']; ?>
+                </div>
+                <!-- /.card-body -->
+            </div>
+        </div>
+    <?php endforeach; ?>
+    </div>
+
+</div>

+ 21 - 0
app/views/organizations/update.php

@@ -0,0 +1,21 @@
+<?php
+
+use yii\helpers\Html;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Organizations */
+
+$this->title = 'Update Organizations: ' . $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Organizations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+?>
+<div class="organizations-update">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?= $this->render('_form', [
+        'model' => $model,
+    ]) ?>
+
+</div>

+ 190 - 0
app/views/organizations/view.php

@@ -0,0 +1,190 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/* @var $this yii\web\View */
+/* @var $model app\models\Organizations */
+
+$this->title = $model->short_name;
+$this->params['breadcrumbs'][] = ['label' => 'Organizations', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+$this->params['actionButtons'][] = ['label' => 'Create', 'url' => ['index'], 'linkOptions' => ['class' => 'text-white btn btn-success mx-1']];
+$this->params['actionButtons'][] = ['label' => 'Update', 'url' => ['index'], 'linkOptions' => ['class' => 'text-white btn btn-primary mx-1']];
+$this->params['actionButtons'][] = ['label' => 'Delete', 'url' => ['index'], 'linkOptions' => ['class' => 'text-white btn btn-danger mx-1']];
+\yii\web\YiiAsset::register($this);
+?>
+<div class="organizations-view">
+
+    <p>
+        <?= 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',
+            ],
+        ]) ?>
+    </p>
+
+    <div class="row">
+        <div class="col-md-9">
+
+            <div class="card card-outline card-primary">
+                <div class="card-header">
+                    <h3 class="card-title">Новые</h3>
+
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i>
+                        </button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body p-0">
+                    <table class="table table-head-fixed text-nowrap">
+                        <thead>
+                        <tr>
+                            <th class="collapsing">ID</th>
+                            <th>Отправитель</th>
+                            <th>Email</th>
+                            <th>Создан</th>
+                            <th>Отправка</th>
+                            <th class="collapsing">Тип</th>
+                            <th class="collapsing"></th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr>
+                            <td colspan="7">No data to show</td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+                <!-- /.card-body -->
+            </div>
+
+            <div class="card card-warning">
+                <div class="card-header">
+                    <h3 class="card-title">Ожидающие</h3>
+
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i>
+                        </button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    The body of the card
+                </div>
+                <!-- /.card-body -->
+            </div>
+
+            <div class="card card-outline card-primary">
+                <div class="card-header">
+                    <h3 class="card-title">Регулярные</h3>
+
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i>
+                        </button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    The body of the card
+                </div>
+                <!-- /.card-body -->
+            </div>
+
+            <div class="card card-success">
+                <div class="card-header">
+                    <h3 class="card-title">Выполненные</h3>
+
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="maximize"><i class="fas fa-expand"></i>
+                        </button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    The body of the card
+                </div>
+                <!-- /.card-body -->
+            </div>
+
+            <?= DetailView::widget([
+                'model' => $model,
+                'attributes' => [
+                    'id',
+                    'name',
+                    'short_name',
+                    'vat',
+                    'edrpou',
+                    'address_1',
+                    'address_2',
+                    'address_3',
+                    'comment:ntext',
+                    'bank_id',
+                    'person_id',
+                    'created_at',
+                    'updated_at',
+                    'deleted_at',
+                ],
+            ]) ?>
+        </div>
+        <div class="col-md-3">
+            <div class="card">
+                <div class="card-header">
+                    <h3 class="card-title">
+                        <?= $model->name; ?>
+                    </h3>
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    <?= isset($model->comment) ? '<div class="mb-lg-3">'.$model->comment.'</div>' : ''; ?>
+                    <dl>
+                        <?php if ($model->edrpou): ?>
+                        <dt><?= strlen($model->edrpou) <= 8 ? 'ЕДРПОУ' : 'инн'; ?></dt>
+                        <dd><?= $model->edrpou; ?></dd>
+                        <?php endif; ?>
+                        <?php if($model->person_id): ?>
+                        <dt>Представитель</dt>
+                        <dd><?= $model->person_id; ?></dd>
+                        <?php endif; ?>
+                        <?php if ($model->address_1 || $model->address_2 || $model->address_3) : ?>
+                            <dt>Адрес.</dt>
+                            <dd>
+                                <dl class="row">
+                                    <?php if ($model->address_1): ?><dt class="col-sm-2">Юр.</dt><dd class="col-sm-10"><?= $model->address_1; ?></dd><?php endif; ?>
+                                    <?php if ($model->address_2): ?><dt class="col-sm-2">Фк.</dt><dd class="col-sm-10"><?= $model->address_2; ?></dd><?php endif; ?>
+                                    <?php if ($model->address_3): ?><dt class="col-sm-2">Пч.</dt><dd class="col-sm-10"><?= $model->address_3; ?></dd><?php endif; ?>
+                                </dl>
+                            </dd>
+                        <?php endif; ?>
+                    </dl>
+                </div>
+                <!-- /.card-body -->
+            </div>
+
+            <div class="card card-default">
+                <div class="card-header">
+                    <h3 class="card-title">Email для отправки писем </h3>
+
+                    <div class="card-tools">
+                        <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
+                    </div>
+                    <!-- /.card-tools -->
+                </div>
+                <!-- /.card-header -->
+                <div class="card-body">
+                    The body of the card
+                </div>
+                <!-- /.card-body -->
+            </div>
+        </div>
+    </div>
+
+</div>

+ 24 - 0
app/widgets/ActionButtons.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace yyi\widgets;
+
+use yii\base\Widget;
+use yii\bootstrap4\Html;
+
+class ActionButtons extends Widget
+{
+    public $buttons;
+
+    public function run()
+    {
+        if (empty($this->buttons)) {
+            return;
+        }
+
+        $buttons = [];
+        foreach ($this->buttons as $button){
+            $buttons[] = Html::a($button->title);
+        }
+        echo implode('', $buttons);
+    }
+}

+ 22 - 3
reactcrmyii.sql

@@ -3,7 +3,7 @@
 -- https://www.phpmyadmin.net/
 --
 -- Хост: localhost
+-- Время создания: Дек 18 2020 г., 15:52
 -- Версия сервера: 10.4.16-MariaDB
 -- Версия PHP: 7.4.12
 
@@ -50,7 +50,7 @@ CREATE TABLE `organizations` (
   `name` varchar(191) NOT NULL,
   `short_name` varchar(191) DEFAULT NULL,
   `vat` tinyint(1) DEFAULT NULL,
-  `edrpou` int(11) DEFAULT NULL,
+  `edrpou` varchar(191) DEFAULT NULL,
   `address_1` varchar(191) DEFAULT NULL,
   `address_2` varchar(191) DEFAULT NULL,
   `address_3` varchar(191) DEFAULT NULL,
@@ -62,6 +62,14 @@ CREATE TABLE `organizations` (
   `deleted_at` int(11) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
+--
+-- Дамп данных таблицы `organizations`
+--
+
+INSERT INTO `organizations` (`id`, `name`, `short_name`, `vat`, `edrpou`, `address_1`, `address_2`, `address_3`, `comment`, `bank_id`, `person_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
+(1, 'ФОП \"Широкие Потребности\"', 'Ширпотреб', 3, '00000001', 'адрес 1', 'адрес 2', 'адрес 3', 'lispsum comment', NULL, NULL, NULL, NULL, NULL),
+(2, 'ФОП \"Абра Кадабра\"', 'Абракадабра', 1, '0000000010', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
 -- --------------------------------------------------------
 
 --
@@ -70,7 +78,7 @@ CREATE TABLE `organizations` (
 
 CREATE TABLE `persons` (
   `id` bigint(20) UNSIGNED NOT NULL,
-  `org_id` int(11) NOT NULL,
+  `org_id` int(11) UNSIGNED DEFAULT NULL,
   `first_name` varchar(191) DEFAULT NULL,
   `last_name` varchar(191) DEFAULT NULL,
   `position` varchar(191) DEFAULT NULL,
@@ -137,7 +145,7 @@ ALTER TABLE `settings`
 -- AUTO_INCREMENT для таблицы `organizations`
 --
 ALTER TABLE `organizations`
-  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
+  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
 
 --
 -- AUTO_INCREMENT для таблицы `persons`
@@ -150,6 +158,16 @@ ALTER TABLE `persons`
 --
 ALTER TABLE `settings`
   MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
+-- Ограничения внешнего ключа сохраненных таблиц
+--
+
+--
+-- Ограничения внешнего ключа таблицы `persons`
+--
+ALTER TABLE `persons`
+  ADD CONSTRAINT `fk_org_id` FOREIGN KEY (`org_id`) REFERENCES `organizations` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
 COMMIT;
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;