first commit
This commit is contained in:
12
backend/modules/product/views/default/index.php
Executable file
12
backend/modules/product/views/default/index.php
Executable file
@ -0,0 +1,12 @@
|
||||
<div class="product-default-index">
|
||||
<h1><?= $this->context->action->uniqueId ?></h1>
|
||||
<p>
|
||||
This is the view content for action "<?= $this->context->action->id ?>".
|
||||
The action belongs to the controller "<?= get_class($this->context) ?>"
|
||||
in the "<?= $this->context->module->id ?>" module.
|
||||
</p>
|
||||
<p>
|
||||
You may customize this page by editing the following file:<br>
|
||||
<code><?= __FILE__ ?></code>
|
||||
</p>
|
||||
</div>
|
66
backend/modules/product/views/product/_form.php
Executable file
66
backend/modules/product/views/product/_form.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use kartik\widgets\FileInput;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\Product $model */
|
||||
/** @var yii\widgets\ActiveForm $form */
|
||||
?>
|
||||
|
||||
<div class="product-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'type')->dropDownList(
|
||||
$model::TypesWithLabels(),
|
||||
[
|
||||
'prompt' => 'Выберите Тип...',
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'price')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList([1 => 'Активен', 0 => 'Не активен'])?>
|
||||
|
||||
<?= $form->field($model, 'photo')->widget(FileInput::class, [
|
||||
'pluginOptions' => [
|
||||
'showZoom' => false,
|
||||
'initialPreview' => [
|
||||
$model->photo != null ? Html::img('@frontend/web/images/product/' . $model->photo, ['class' => 'file-preview-image']) : null,
|
||||
],
|
||||
'overwriteInitial' => true,
|
||||
'showCaption' => false,
|
||||
'showUpload' => false,
|
||||
'showRemove' => true,
|
||||
'showDetails' => true,
|
||||
'browseClass' => 'btn btn-primary btn-block',
|
||||
'browseIcon' => '<i class="fa fa-camera"></i> ',
|
||||
'browseLabel' => 'Выберите фото',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= $form->field($model, 'quantity')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'taste')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'strength')->dropDownList(
|
||||
$model::TabacooStrengthWithLabel()
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'category_id')->dropDownList(
|
||||
\yii\helpers\ArrayHelper::map(\common\models\Category::find()->asArray()->all(), 'id', 'name')
|
||||
) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
20
backend/modules/product/views/product/create.php
Executable file
20
backend/modules/product/views/product/create.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\Product $model */
|
||||
|
||||
$this->title = 'Create Product';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Products', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="product-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
49
backend/modules/product/views/product/index.php
Executable file
49
backend/modules/product/views/product/index.php
Executable file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use common\models\Product;
|
||||
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 = 'Products';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="product-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Create Product', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'type',
|
||||
'name',
|
||||
'description',
|
||||
'price',
|
||||
//'status',
|
||||
//'quantity',
|
||||
//'taste',
|
||||
//'strength',
|
||||
//'category_id',
|
||||
[
|
||||
'class' => ActionColumn::className(),
|
||||
'urlCreator' => function ($action, Product $model, $key, $index, $column) {
|
||||
return Url::toRoute([$action, 'id' => $model->id]);
|
||||
}
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
|
||||
</div>
|
21
backend/modules/product/views/product/update.php
Executable file
21
backend/modules/product/views/product/update.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\Product $model */
|
||||
|
||||
$this->title = 'Update Product: ' . $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Products', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="product-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
45
backend/modules/product/views/product/view.php
Executable file
45
backend/modules/product/views/product/view.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\Product $model */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Products', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
<div class="product-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<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>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'type',
|
||||
'name',
|
||||
'description',
|
||||
'price',
|
||||
'status',
|
||||
'quantity',
|
||||
'taste',
|
||||
'strength',
|
||||
'category_id',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user