選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

_form.php 11KB

10ヶ月前
10ヶ月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. use common\helpers\GlobalParam;
  3. use common\helpers\Image;
  4. use domain\PointSale\PointSale\PointSale;
  5. use lo\widgets\Toggle;
  6. use domain\Product\Product\Product;
  7. use yii\bootstrap\ActiveForm;
  8. use yii\helpers\ArrayHelper;
  9. use yii\helpers\Html;
  10. $producerModule = $this->getProducerModule();
  11. $productCategoryModule = $this->getProductCategoryModule();
  12. $taxRateModule = $this->getTaxRateModule();
  13. ?>
  14. <div class="product-form">
  15. <?php $form = ActiveForm::begin([
  16. 'enableClientValidation' => false,
  17. 'options' => ['enctype' => 'multipart/form-data']
  18. ]); ?>
  19. <div>
  20. <div class="col-md-8">
  21. <div class="panel panel-default">
  22. <div class="panel-heading">
  23. <h3 class="panel-title">
  24. <i class="fa fa-th-list"></i>
  25. Général
  26. </h3>
  27. </div>
  28. <div class="panel-body">
  29. <?= $form->field($model, 'status')->widget(Toggle::class,
  30. [
  31. 'options' => [
  32. 'data-id' => $model->id,
  33. 'data-on' => 'Oui',
  34. 'data-off' => 'Non',
  35. ],
  36. ]
  37. ); ?>
  38. <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
  39. <?php if($producerModule->getSolver()->getConfig('option_export_display_product_reference')): ?>
  40. <?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?>
  41. <?php endif; ?>
  42. <?= $form->field($model, 'id_product_category')->dropDownList($productCategoryModule->populateProductCategoriesDropdownList()); ?>
  43. <?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
  44. <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>
  45. <?= $form->field($model, 'unit')
  46. ->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording'))
  47. ->label('Unité (pièce, poids ou volume)'); ?>
  48. <?= $form->field($model, 'step')->textInput()->hint('Définit ce qui est ajouté ou enlevé lors des changements de quantité.') ?>
  49. <?= $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.") ?>
  50. </div>
  51. </div>
  52. <div class="panel panel-default">
  53. <div class="panel-heading">
  54. <h3 class="panel-title">
  55. <i class="fa fa-euro"></i> Prix
  56. <a href="<?= Yii::$app->urlManager->createUrl(['product/prices-list', 'id' => $model->id]) ?>"
  57. class="btn btn-default btn-xs">
  58. Prix spécifiques (<?= count($model->productPrice) ?>)
  59. </a>
  60. </h3>
  61. </div>
  62. <div class="panel-body">
  63. <?php
  64. //Récupère la tva par défaut du producteur courant
  65. $producer = \common\helpers\GlobalParam::getCurrentProducer();
  66. $taxRateDefault = $producer->taxRate;
  67. $taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
  68. return $model->name;
  69. }));
  70. $taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
  71. return $model->value;
  72. }));
  73. foreach ($taxRateValuesArray as $key => $taxRateValue) {
  74. $taxRateValuesArrayFormatted[$key] = array('data-tax-rate-value' => $taxRateValue);
  75. }
  76. ?>
  77. <?php if ($taxRateDefault->value != 0): ?>
  78. <?= $form->field($model, 'id_tax_rate')->dropDownList($taxRateNamesArray, ['options' => $taxRateValuesArrayFormatted])->label('Taxe'); ?>
  79. <?php endif; ?>
  80. <?= $form->field($model, 'price', [
  81. 'template' => '
  82. <div class="row">
  83. <div class="col-xs-6">
  84. <label for="product-price" class="control-label without-tax"></label>
  85. <div class="input-group">
  86. {input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
  87. </div>
  88. </div>
  89. <div class="col-xs-6">
  90. <label for="product-price-with-tax" class="control-label with-tax"></label>
  91. <div class="input-group">
  92. <input type="text" id="product-price-with-tax" class="form-control" name="" value="">
  93. <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
  94. </div>
  95. </div>
  96. </div>
  97. ',
  98. ]) ?>
  99. </div>
  100. </div>
  101. <?php if (!$model->isNewRecord): ?>
  102. <div class="panel panel-default">
  103. <div class="panel-heading">
  104. <h3 class="panel-title">
  105. <i class="fa fa-edit"></i>
  106. Distributions à venir
  107. </h3>
  108. </div>
  109. <div class="panel-body">
  110. <?= $form->field($model, 'apply_distributions')
  111. ->checkbox()
  112. ->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.'); ?>
  113. </div>
  114. </div>
  115. <?php endif; ?>
  116. </div>
  117. <div class="col-md-4">
  118. <div class="panel panel-default">
  119. <div class="panel-heading">
  120. <h3 class="panel-title">
  121. <i class="fa fa-image"></i>
  122. Photo
  123. </h3>
  124. </div>
  125. <div class="panel-body">
  126. <?= $form->field($model, 'photoFile')->fileInput()->label('') ?>
  127. <?php
  128. if (strlen($model->photo)) {
  129. echo '<img class="photo-product" src="' . Image::getThumbnailSmall($model->photo, true) . '" width="200px" /><br />';
  130. echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label>';
  131. }
  132. ?>
  133. </div>
  134. </div>
  135. <div class="panel panel-default">
  136. <div class="panel-heading">
  137. <h3 class="panel-title">
  138. <i class="fa fa-calendar"></i>
  139. Jours de production
  140. </h3>
  141. </div>
  142. <div class="panel-body">
  143. <div id="days-production">
  144. <?= $form->field($model, 'monday')->checkbox() ?>
  145. <?= $form->field($model, 'tuesday')->checkbox() ?>
  146. <?= $form->field($model, 'wednesday')->checkbox() ?>
  147. <?= $form->field($model, 'thursday')->checkbox() ?>
  148. <?= $form->field($model, 'friday')->checkbox() ?>
  149. <?= $form->field($model, 'saturday')->checkbox() ?>
  150. <?= $form->field($model, 'sunday')->checkbox() ?>
  151. </div>
  152. <div class="clr"></div>
  153. </div>
  154. </div>
  155. <div class="panel panel-default">
  156. <div class="panel-heading">
  157. <h3 class="panel-title">
  158. <i class="fa fa-balance-scale"></i>
  159. Quantités maximum par jour
  160. </h3>
  161. </div>
  162. <div class="panel-body">
  163. <div id="maximum-quantities">
  164. <?= $form->field($model, 'quantity_max')->textInput() ?>
  165. <?= $form->field($model, 'quantity_max_monday')->textInput() ?>
  166. <?= $form->field($model, 'quantity_max_tuesday')->textInput() ?>
  167. <?= $form->field($model, 'quantity_max_wednesday')->textInput() ?>
  168. <?= $form->field($model, 'quantity_max_thursday')->textInput() ?>
  169. <?= $form->field($model, 'quantity_max_friday')->textInput() ?>
  170. <?= $form->field($model, 'quantity_max_saturday')->textInput() ?>
  171. <?= $form->field($model, 'quantity_max_sunday')->textInput() ?>
  172. </div>
  173. </div>
  174. </div>
  175. <div class="panel panel-default">
  176. <div class="panel-heading">
  177. <h3 class="panel-title">
  178. <i class="fa fa-map-marker"></i>
  179. Disponibilité par point de vente
  180. </h3>
  181. </div>
  182. <div class="panel-body">
  183. <div id="availability-points-sale">
  184. <?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?>
  185. <strong id="label-availability-points-sale">Et
  186. <span><?php if ($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span>
  187. sur les points de vente</strong>
  188. <?php $pointSaleArray = PointSale::find()
  189. ->where([
  190. 'id_producer' => GlobalParam::getCurrentProducerId(),
  191. 'status' => 1
  192. ])
  193. ->orderBy('is_bread_box ASC, name ASC')
  194. ->all(); ?>
  195. <?= Html::activeCheckboxList($model, 'pointsSale', ArrayHelper::map($pointSaleArray, 'id', function ($pointSale, $defaultValue) use ($model) {
  196. return Html::encode($pointSale->name);
  197. }), ['encode' => false, 'class' => '']) ?>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="clr"></div>
  203. </div>
  204. <?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?>
  205. <div class="form-group form-actions">
  206. <?= Html::a('Retour', ['product/index'], ['class' => 'btn btn-default']) ?>
  207. <?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
  208. </div>
  209. <?php ActiveForm::end(); ?>
  210. </div>