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 13KB

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