|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
-
- use common\helpers\GlobalParam;
- use common\helpers\Image;
- use domain\PointSale\PointSale\PointSale;
- use lo\widgets\Toggle;
- use domain\Product\Product\Product;
- use yii\bootstrap\ActiveForm;
- use yii\helpers\ArrayHelper;
- use yii\helpers\Html;
-
- $producerModule = $this->getProducerModule();
- $productCategoryModule = $this->getProductCategoryModule();
- $taxRateModule = $this->getTaxRateModule();
-
- ?>
-
- <div class="product-form">
-
- <?php $form = ActiveForm::begin([
- 'enableClientValidation' => false,
- 'options' => ['enctype' => 'multipart/form-data']
- ]); ?>
-
- <div>
- <div class="col-md-8">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-th-list"></i>
- Général
- </h3>
- </div>
- <div class="panel-body">
- <?= $form->field($model, 'status')->widget(Toggle::class,
- [
- 'options' => [
- 'data-id' => $model->id,
- 'data-on' => 'Oui',
- 'data-off' => 'Non',
- ],
- ]
- ); ?>
-
- <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
- <?php if($producerModule->getSolver()->getConfig('option_export_display_product_reference')): ?>
- <?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?>
- <?php endif; ?>
- <?= $form->field($model, 'id_product_category')->dropDownList($productCategoryModule->populateProductCategoriesDropdownList()); ?>
- <?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
- <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>
- <?= $form->field($model, 'unit')
- ->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording'))
- ->label('Unité (pièce, poids ou volume)'); ?>
- <?= $form->field($model, 'step')->textInput()->hint('Définit ce qui est ajouté ou enlevé lors des changements de quantité.') ?>
- <?= $form->field($model, 'weight')->textInput()->label('Poids (g)')->hint("Si unité au poids ou volume, utilisé pour déterminer le nombre de pièces dans les exports.") ?>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-euro"></i> Prix
-
- <a href="<?= Yii::$app->urlManager->createUrl(['product/prices-list', 'id' => $model->id]) ?>"
- class="btn btn-default btn-xs">
- Prix spécifiques (<?= count($model->productPrice) ?>)
- </a>
- </h3>
- </div>
- <div class="panel-body">
- <?php
-
- //Récupère la tva par défaut du producteur courant
- $producer = \common\helpers\GlobalParam::getCurrentProducer();
- $taxRateDefault = $producer->taxRate;
-
- $taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
- return $model->name;
- }));
- $taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
- return $model->value;
- }));
- foreach ($taxRateValuesArray as $key => $taxRateValue) {
- $taxRateValuesArrayFormatted[$key] = array('data-tax-rate-value' => $taxRateValue);
- }
-
- ?>
-
- <?php if ($taxRateDefault->value != 0): ?>
- <?= $form->field($model, 'id_tax_rate')->dropDownList($taxRateNamesArray, ['options' => $taxRateValuesArrayFormatted])->label('Taxe'); ?>
- <?php endif; ?>
-
- <?= $form->field($model, 'price', [
- 'template' => '
- <div class="row">
- <div class="col-xs-6">
- <label for="product-price" class="control-label without-tax"></label>
- <div class="input-group">
- {input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
- </div>
- </div>
- <div class="col-xs-6">
- <label for="product-price-with-tax" class="control-label with-tax"></label>
- <div class="input-group">
- <input type="text" id="product-price-with-tax" class="form-control" name="" value="">
- <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
- </div>
- </div>
- </div>
- ',
- ]) ?>
- </div>
- </div>
-
- <?php if (!$model->isNewRecord): ?>
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-edit"></i>
- Distributions à venir
- </h3>
- </div>
- <div class="panel-body">
- <?= $form->field($model, 'apply_distributions')
- ->checkbox()
- ->hint('Sélectionnez cette option si vous souhaitez que ces modifications (actif / non actif, quantités maximum) soient répercutées dans les distributions à venir.'); ?>
- </div>
- </div>
- <?php endif; ?>
- </div>
- <div class="col-md-4">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-image"></i>
- Photo
- </h3>
- </div>
- <div class="panel-body">
- <?= $form->field($model, 'photoFile')->fileInput()->label('') ?>
- <?php
- if (strlen($model->photo)) {
- echo '<img class="photo-product" src="' . Image::getThumbnailSmall($model->photo, true) . '" width="200px" /><br />';
- echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label>';
- }
- ?>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-calendar"></i>
- Jours de production
- </h3>
- </div>
- <div class="panel-body">
- <div id="days-production">
- <?= $form->field($model, 'monday')->checkbox() ?>
- <?= $form->field($model, 'tuesday')->checkbox() ?>
- <?= $form->field($model, 'wednesday')->checkbox() ?>
- <?= $form->field($model, 'thursday')->checkbox() ?>
- <?= $form->field($model, 'friday')->checkbox() ?>
- <?= $form->field($model, 'saturday')->checkbox() ?>
- <?= $form->field($model, 'sunday')->checkbox() ?>
- </div>
- <div class="clr"></div>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-balance-scale"></i>
- Quantités maximum par jour
- </h3>
- </div>
- <div class="panel-body">
- <div id="maximum-quantities">
- <?= $form->field($model, 'quantity_max')->textInput() ?>
- <?= $form->field($model, 'quantity_max_monday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_tuesday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_wednesday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_thursday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_friday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_saturday')->textInput() ?>
- <?= $form->field($model, 'quantity_max_sunday')->textInput() ?>
- </div>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-repeat"></i>
- Abonnements
- </h3>
- </div>
- <div class="panel-body">
- <?= $form->field($model, 'is_available_for_subscriptions')->widget(Toggle::class,
- [
- 'options' => [
- 'data-id' => $model->id,
- 'data-on' => 'Oui',
- 'data-off' => 'Non',
- ],
- ]
- ); ?>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <i class="fa fa-map-marker"></i>
- Disponibilité par point de vente
- </h3>
- </div>
- <div class="panel-body">
- <div id="availability-points-sale">
- <?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?>
- <strong id="label-availability-points-sale">Et
- <span><?php if ($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span>
- sur les points de vente</strong>
- <?php $pointSaleArray = PointSale::find()
- ->where([
- 'id_producer' => GlobalParam::getCurrentProducerId(),
- 'status' => 1
- ])
- ->orderBy('is_bread_box ASC, name ASC')
- ->all(); ?>
- <?= Html::activeCheckboxList($model, 'pointsSale', ArrayHelper::map($pointSaleArray, 'id', function ($pointSale, $defaultValue) use ($model) {
- return Html::encode($pointSale->name);
- }), ['encode' => false, 'class' => '']) ?>
- </div>
- </div>
- </div>
-
- </div>
- <div class="clr"></div>
- </div>
-
- <?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?>
-
- <?= $this->render('@backend/views/_include/form_actions.php',[
- 'model' => $model,
- ]); ?>
-
- <?php ActiveForm::end(); ?>
-
- </div>
|