You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_form.php 7.8KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. use common\helpers\Image;
  3. use yii\helpers\Html;
  4. use yii\bootstrap\ActiveForm;
  5. use yii\helpers\ArrayHelper;
  6. use common\helpers\GlobalParam;
  7. use common\logic\Product\Product\Model\Product;
  8. use common\logic\PointSale\PointSale\Model\PointSale;
  9. $productCategoryModule = $this->getProductCategoryModule();
  10. $taxRateModule = $this->getTaxRateModule();
  11. ?>
  12. <div class="product-form">
  13. <?php $form = ActiveForm::begin([
  14. 'enableClientValidation' => false,
  15. 'options' => ['enctype' => 'multipart/form-data']
  16. ]); ?>
  17. <div>
  18. <div class="col-md-8">
  19. <?= $form->field($model, 'status')->radioList([1 => 'Oui', 0 => 'Non']) ?>
  20. <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>
  21. <?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?>
  22. <?= $form->field($model, 'id_product_category')->dropDownList($productCategoryModule->populateProductCategoriesDropdownList()); ?>
  23. <?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?>
  24. <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?>
  25. <?= $form->field($model, 'unit')
  26. ->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording'))
  27. ->label('Unité (pièce, poids ou volume)'); ?>
  28. <?php
  29. //Récupère la tva par défaut du producteur courant
  30. $producer = \common\helpers\GlobalParam::getCurrentProducer();
  31. $taxRateDefault = $producer->taxRate;
  32. $taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
  33. return $model->name;
  34. }));
  35. $taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateModule->findTaxRates(), 'id', function ($model) {
  36. return $model->value;
  37. }));
  38. foreach ($taxRateValuesArray as $key => $taxRateValue) {
  39. $taxRateValuesArrayFormatted[$key] = array('data-tax-rate-value' => $taxRateValue);
  40. }
  41. ?>
  42. <?php if ($taxRateDefault->value != 0): ?>
  43. <?= $form->field($model, 'id_tax_rate')->dropDownList($taxRateNamesArray, ['options' => $taxRateValuesArrayFormatted])->label('Taxe'); ?>
  44. <?php endif; ?>
  45. <?= $form->field($model, 'price', [
  46. 'template' => '
  47. <div class="row">
  48. <div class="col-xs-6">
  49. <label for="product-price" class="control-label without-tax"></label>
  50. <div class="input-group">
  51. {input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
  52. </div>
  53. </div>
  54. <div class="col-xs-6">
  55. <label for="product-price-with-tax" class="control-label with-tax"></label>
  56. <div class="input-group">
  57. <input type="text" id="product-price-with-tax" class="form-control" name="" value="">
  58. <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span>
  59. </div>
  60. </div>
  61. </div>
  62. ',
  63. ]) ?>
  64. <?= $form->field($model, 'step')->textInput()->hint('Définit ce qui est ajouté ou enlevé lors des changements de quantité.') ?>
  65. <?= $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.") ?>
  66. <div class="col-md-3">
  67. <?= $form->field($model, 'quantity_max')->textInput() ?>
  68. </div>
  69. <div class="col-md-3">
  70. <?= $form->field($model, 'quantity_max_monday')->textInput() ?>
  71. </div>
  72. <div class="col-md-3">
  73. <?= $form->field($model, 'quantity_max_tuesday')->textInput() ?>
  74. </div>
  75. <div class="col-md-3">
  76. <?= $form->field($model, 'quantity_max_wednesday')->textInput() ?>
  77. </div>
  78. <div class="col-md-3">
  79. <?= $form->field($model, 'quantity_max_thursday')->textInput() ?>
  80. </div>
  81. <div class="col-md-3">
  82. <?= $form->field($model, 'quantity_max_friday')->textInput() ?>
  83. </div>
  84. <div class="col-md-3">
  85. <?= $form->field($model, 'quantity_max_saturday')->textInput() ?>
  86. </div>
  87. <div class="col-md-3">
  88. <?= $form->field($model, 'quantity_max_sunday')->textInput() ?>
  89. </div>
  90. <div class="clr"></div>
  91. <?php
  92. if (!$model->isNewRecord) {
  93. echo $form->field($model, 'apply_distributions')
  94. ->checkbox()
  95. ->hint('Sélectionnez cette option si vous souhaitez que ces modifications (actif / non actif, quantité max) soient répercutées dans les distributions à venir déjà initialisées.');
  96. }
  97. ?>
  98. </div>
  99. <div class="col-md-4">
  100. <?= $form->field($model, 'photoFile')->fileInput() ?>
  101. <?php
  102. if (strlen($model->photo)) {
  103. echo '<img class="photo-product" src="' . Image::getThumbnailSmall($model->photo, true) . '" width="200px" /><br />';
  104. echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label>';
  105. }
  106. ?>
  107. <div id="days-production">
  108. <h2>Jours de distribution</h2>
  109. <?= $form->field($model, 'monday')->checkbox() ?>
  110. <?= $form->field($model, 'tuesday')->checkbox() ?>
  111. <?= $form->field($model, 'wednesday')->checkbox() ?>
  112. <?= $form->field($model, 'thursday')->checkbox() ?>
  113. <?= $form->field($model, 'friday')->checkbox() ?>
  114. <?= $form->field($model, 'saturday')->checkbox() ?>
  115. <?= $form->field($model, 'sunday')->checkbox() ?>
  116. </div>
  117. <div class="clr"></div>
  118. <div id="availability-points-sale">
  119. <h2>Disponibilité points de vente</h2>
  120. <?= $form->field($model, 'available_on_points_sale')->radioList([1 => 'Disponible', 0 => 'Indisponible']) ?>
  121. <strong id="label-availability-points-sale">Et
  122. <span><?php if ($model->available_on_points_sale): ?>indisponible<?php else: ?>disponible<?php endif; ?></span>
  123. sur les points de vente</strong>
  124. <?php $pointSaleArray = PointSale::find()
  125. ->where([
  126. 'id_producer' => GlobalParam::getCurrentProducerId(),
  127. 'status' => 1
  128. ])
  129. ->orderBy('is_bread_box ASC, name ASC')
  130. ->all(); ?>
  131. <?= Html::activeCheckboxList($model, 'pointsSale', ArrayHelper::map($pointSaleArray, 'id', function ($pointSale, $defaultValue) use ($model) {
  132. return Html::encode($pointSale->name);
  133. }), ['encode' => false, 'class' => '']) ?>
  134. </div>
  135. </div>
  136. <div class="clr"></div>
  137. </div>
  138. <?= $form->field($model, 'id_producer')->hiddenInput()->label('') ?>
  139. <div class="form-group form-actions">
  140. <?= Html::a('Retour', ['product/index'], ['class' => 'btn btn-default']) ?>
  141. <?= Html::submitButton($model->isNewRecord ? 'Créer' : 'Modifier', ['class' => 'btn btn-primary']) ?>
  142. </div>
  143. <?php ActiveForm::end(); ?>
  144. </div>