Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

253 lines
12KB

  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-repeat"></i>
  179. Abonnements
  180. </h3>
  181. </div>
  182. <div class="panel-body">
  183. <?= $form->field($model, 'is_available_for_subscriptions')->widget(Toggle::class,
  184. [
  185. 'options' => [
  186. 'data-id' => $model->id,
  187. 'data-on' => 'Oui',
  188. 'data-off' => 'Non',
  189. ],
  190. ]
  191. ); ?>
  192. </div>
  193. </div>
  194. <div class="panel panel-default">
  195. <div class="panel-heading">
  196. <h3 class="panel-title">
  197. <i class="fa fa-map-marker"></i>
  198. Disponibilité par point de vente
  199. </h3>
  200. </div>
  201. <div class="panel-body">
  202. <div id="availability-points-sale">
  203. <?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?>
  204. <strong id="label-availability-points-sale">Et
  205. <span><?php if ($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span>
  206. sur les points de vente</strong>
  207. <?php $pointSaleArray = PointSale::find()
  208. ->where([
  209. 'id_producer' => GlobalParam::getCurrentProducerId(),
  210. 'status' => 1
  211. ])
  212. ->orderBy('is_bread_box ASC, name ASC')
  213. ->all(); ?>
  214. <?= Html::activeCheckboxList($model, 'pointsSale', ArrayHelper::map($pointSaleArray, 'id', function ($pointSale, $defaultValue) use ($model) {
  215. return Html::encode($pointSale->name);
  216. }), ['encode' => false, 'class' => '']) ?>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. <div class="clr"></div>
  222. </div>
  223. <?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?>
  224. <?= $this->render('@backend/views/_include/form_actions.php',[
  225. 'model' => $model,
  226. ]); ?>
  227. <?php ActiveForm::end(); ?>
  228. </div>