Дипломная работа: Автоматизация управленческого учета в дошкольном образовательном учреждении (на примере ИП «Мельникова»)

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
102
protected function findModel($id)
{
if (($model = Test::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}
<?php
namespace backend\models;
use Yii;
/**
* This is the model class for table "{{%test}}".
*
* @property int $id
* @property int $parent_id
* @property int $child_id
* @property string $result
* @property string $duration
* @property string $date
*
* @property Report[] $reports
* @property Child $child
* @property Parent $parent
*/
class Test extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
103
return '{{%test}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['parent_id', 'child_id', 'result', 'duration', 'date'], 'required'],
[['parent_id', 'child_id'], 'integer'],
[['result'], 'string'],
[['duration', 'date'], 'safe'],
[['child_id'], 'exist', 'skipOnError' => true, 'targetClass' => Child::className(),
'targetAttribute' => ['child_id' => 'id']],
[['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Parent::className(),
'targetAttribute' => ['parent_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'parent_id' => 'Parent ID',
'child_id' => 'Child ID',
'result' => 'Result',
'duration' => 'Duration',
'date' => 'Date',
];
}
/**
* Gets query for [[Reports]].
104
*
* @return \yii\db\ActiveQuery
*/
public function getReports()
{
return $this->hasMany(Report::className(), ['test_id' => 'id']);
}
/**
* Gets query for [[Child]].
*
* @return \yii\db\ActiveQuery
*/
public function getChild()
{
return $this->hasOne(Child::className(), ['id' => 'child_id']);
}
/**
* Gets query for [[Parent]].
*
* @return \yii\db\ActiveQuery
*/
public function getParent()
{
return $this->hasOne(Parent::className(), ['id' => 'parent_id']);
}
}
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\Test */
/* @var $form yii\widgets\ActiveForm */
?>
105
<div class="test-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'parent_id')->textInput() ?>
<?= $form->field($model, 'child_id')->textInput() ?>
<?= $form->field($model, 'result')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'duration')->textInput() ?>
<?= $form->field($model, 'date')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\TestSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="test-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
106
'method' => 'get',
'options' => [
'data-pjax' => 1
],
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'parent_id') ?>
<?= $form->field($model, 'child_id') ?>
<?= $form->field($model, 'result') ?>
<?= $form->field($model, 'duration') ?>
<?php // echo $form->field($model, 'date') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-outline-secondary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\models\Test */
$this->title = 'Create Test';
$this->params['breadcrumbs'][] = ['label' => 'Tests', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
Источник: https://baza.diplomsite.ru/previewfile/571