_form.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use yii\helpers\ArrayHelper;
  5. use kartik\file\FileInput;
  6. use app\models\Units;
  7. use app\models\Category;
  8. /* @var $this yii\web\View */
  9. /* @var $model app\models\Lots */
  10. /* @var $model app\models\Category */
  11. /* @var $form yii\widgets\ActiveForm */
  12. $this->registerJs(<<<JS
  13. function recalculateSum(){
  14. $('#count-input').val($('#count-input').val());
  15. $('#lots-price_per_one').val($('#lots-price_per_one').val());
  16. var value = $('#lots-price_per_one').val() * $('#count-input').val();
  17. $('#lots-start_price').val(value || '');
  18. }
  19. $('input[name="price_type"]').on('change', function(e){
  20. var type = $('input[name="price_type"]:checked').val();
  21. $('.per_one input, .per_one select').prop('readonly', type === 'total' ? 'readonly': false);
  22. $('#lots-start_price').prop('readonly', type === 'total' ? false : 'readonly');
  23. $('.per_one input, .per_one select').val('');
  24. });
  25. $('#count-input, #lots-price_per_one').on('keyup', function(e){
  26. recalculateSum();
  27. });
  28. JS
  29. );
  30. ?>
  31. <div class="lots-form">
  32. <?php
  33. $files = new \app\models\Files();
  34. $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]); ?>
  35. <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id]) ?>
  36. <?= $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()
  37. ->where(['user_id' => Yii::$app->user->identity->id])->orderBy('id DESC')->all(), 'name', 'name')) ?>
  38. <!-- ivakhnov -->
  39. <?= $form->field($model, 'num')->textInput(['maxlength' => 255])->label(Yii::t('app','AucNumber ID')) ?>
  40. <?= $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name')) ?>
  41. <?= $form->field($model, 'name')->textInput(['maxlength' => 255])->label(Yii::t('app','LotName ID')) ?>
  42. <?= $form->field($model, 'description')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
  43. <div class="row">
  44. <div class="col-sm-12">
  45. <div class="row">
  46. <div class="col-sm-3">
  47. <label class="price_type-input">
  48. <?= Yii::t('app', 'За одиницю'); ?>
  49. <?= Html::radio('price_type', true, ['value' => 'per_one']); ?>
  50. </label>
  51. </div>
  52. <div class="col-sm-9 per_one">
  53. <div class="row">
  54. <div class="col-sm-4">
  55. <div class="form-group">
  56. <label for=""><?= Yii::t('app', 'Кількість'); ?></label>
  57. <?= Html::activeInput('number', $model, 'count', [
  58. 'class' => 'form-control',
  59. 'id' => 'count-input',
  60. 'min' => 1,
  61. 'max' => 99999999999999999999999,
  62. 'step' => 1,
  63. 'readonly' => 'readonly',
  64. ]); ?>
  65. </div>
  66. </div>
  67. <div class="col-sm-4">
  68. <?= $form->field($model, 'price_per_one', ['inputOptions' => ['readonly' => 'readonly', 'class' => 'form-control']])->label(Yii::t('app', 'Ціна за одиницю')); ?>
  69. </div>
  70. <div class="col-sm-4">
  71. <div class="form-group">
  72. <label><?= Yii::t('app', 'Одиниці виміру'); ?></label>
  73. <?= Html::activeDropDownList($model, 'unitId', ArrayHelper::merge(['' => Yii::t('app', 'Оберіть')], ArrayHelper::map(Units::find()->all(), 'id', 'name')), [
  74. 'class' => 'form-control',
  75. 'readonly' => 'readonly',
  76. ]); ?>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="col-sm-12">
  84. <div class="row">
  85. <div class="col-sm-3">
  86. <label class="price_type-input">
  87. <?= Yii::t('app', 'Загальна вартість'); ?>
  88. <?= Html::radio('price_type', true, ['value' => 'total']); ?>
  89. </label>
  90. </div>
  91. <div class="col-sm-9 total">
  92. <?= $form->field($model, 'start_price')->textInput()->label(Yii::t('app', 'Загальна віртість')) ?>
  93. </div>
  94. <div class="col-sm-12 total">
  95. <?= Html::tag('label', Yii::t('app', 'Download'), ['class' => 'control-label']);
  96. echo FileInput::widget([
  97. 'model' => new \app\models\Lots,
  98. 'attribute' => 'files[]',
  99. 'options' => [
  100. 'multiple' => true,
  101. ],
  102. 'pluginOptions' => [
  103. 'showPreview' => true,
  104. 'showRemove' => true,
  105. 'showUpload' => false,
  106. 'showCaption' => true,
  107. ],
  108. ]);?>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <?= $form->field($model, 'nds')->checkbox(['checked ' => true]) ?>
  114. <?= $form->field($model, 'step')->textInput(['maxlength' => true]) ?>
  115. <?= $form->field($files, 'file[]')->widget(FileInput::classname(), [
  116. 'model' => $files,
  117. 'pluginOptions' => [
  118. //'allowedFileExtensions'=>['doc','docx','pdf'],
  119. 'initialCaption'=>'*.doc, *.docx, *.pdf *.png *.jpg *.tiff *.zip *.rar',
  120. 'showPreview' => true,
  121. 'showCaption' => true,
  122. 'showRemove' => true,
  123. 'showUpload' => false,
  124. 'maxFileCount' => 10,
  125. ],
  126. 'options' => [
  127. 'multiple' => true,
  128. ],
  129. ])->label(Yii::t('app','DopDocumentation ID')); ?>
  130. <?= $form->field($model, 'payment_term')->textInput(['maxlength' => true]) ?>
  131. <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>
  132. <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
  133. <!--
  134. <?= $form->field($model, 'delivery_time')->textInput(['maxlength' => true]) ?>
  135. <?= $form->field($model, 'delivery_term')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
  136. <?= $form->field($model, 'requires')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
  137. <?= $form->field($model, 'member_docs')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?> --!>
  138. <?= $form->field($model, 'notes')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
  139. <?= $form->field($model, 'date')->hiddenInput(['value' => date('Y-m-d H:i:s')])->label(false); ?>
  140. <!-- <?= $form->field($model, 'status')->textInput() ?> --!>
  141. <div class="form-group">
  142. <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create ID') : Yii::t('app', 'Update ID'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  143. </div>
  144. <?php ActiveForm::end(); ?>
  145. </div>