No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

280 líneas
13KB

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