_form.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. use yii\helpers\Url;
  9. use kartik\datetime\DateTimePicker;
  10. use app\widgets\ButtonGroupInput;
  11. use yii\widgets\DetailView;
  12. use yii\helpers\Json;
  13. /* @var $this yii\web\View */
  14. /* @var $model app\models\Lots */
  15. /* @var $model app\models\Category */
  16. /* @var $form yii\widgets\ActiveForm */
  17. $t = isset($model->auction->type_id) ? $model->auction->type_id : 0;
  18. $unserializeJson = Json::encode(json_decode($model->serialize_data, true));
  19. $this->registerJs(<<<JS
  20. function recalculateSum(){
  21. $('#count-input').val($('#count-input').val());
  22. $('#lots-price_per_one').val($('#lots-price_per_one').val());
  23. var value = $('#lots-price_per_one').val() * $('#count-input').val();
  24. $('#lots-start_price').val(value || '');
  25. }
  26. $('input[name="price_type"]').on('change', function(e){
  27. var type = $('input[name="price_type"]:checked').val();
  28. $('.per_one input, .per_one select').prop('readonly', type === 'total' ? 'readonly': false);
  29. $('#lots-start_price').prop('readonly', type === 'total' ? false : 'readonly');
  30. $('.per_one input, .per_one select').val('');
  31. });
  32. $('#count-input, #lots-price_per_one').on('keyup', function(e){
  33. recalculateSum();
  34. });
  35. $('input[name="type"]').on('change', function(e){
  36. $(".circle_down").hide();
  37. if($(this).val() == '2'){
  38. $(".circle_down").show();
  39. }
  40. });
  41. var concat_val = '';
  42. var value1 = value2 = value3 = 0;
  43. $("#button-save2").on("click",function(e){
  44. step = $("#input-save0").val();
  45. val1 = $("#input-save1").val();
  46. val2 = $("#input-save2").val();
  47. val3 = $("#input-save3").val();
  48. value1 = 0;
  49. if(val1 > 0){
  50. value1 = val1;
  51. }
  52. value2 = 0;
  53. if(val2 > 0){
  54. value2 = val2;
  55. }
  56. value3 = 0;
  57. if(val3 > 0){
  58. value3 = val3;
  59. }
  60. concat_val = value1 + ":"+ value2 + ":" + value3;
  61. // if(concat_val.length > 0){
  62. // alert(concat_val);
  63. // }
  64. $("#lead").html('кроки:'+step+', час:'+concat_val);
  65. });
  66. $(document).ready(function () {
  67. $("#button-save2").click();
  68. var t = {$t};
  69. if(t == '2'){
  70. $(".circle_down").show();
  71. }
  72. //===
  73. $("#lead").html('кроки:'+step+', час:'+concat_val);
  74. var settings = {$unserializeJson};
  75. if (settings) {
  76. $('input[name=\"time_cont\"][value=\"'+settings.time_cont+'\"]').prop('checked', true);
  77. $('input[name=\"type\"][value=\"'+settings.type+'\"]').prop('checked', true);
  78. //$("#lead").html('кроки:'+step+', час:'+concat_val);
  79. }
  80. });
  81. //====
  82. function serializeData() {
  83. return {
  84. time_cont: $('input[name="time_cont"]:checked').val(),
  85. type: $('input[name="type"]:checked').val(),
  86. step_change: step,
  87. time_step_change: concat_val,
  88. date_stop: $("#date_stop").val(),
  89. };
  90. }
  91. $('form').on('submit', function () {
  92. var data = serializeData();
  93. $('#serialize_data').val(JSON.stringify(data));
  94. });
  95. JS
  96. );
  97. //=========================
  98. $time_change = Html::button(
  99. Yii::t('app', 'Enter value'),
  100. [
  101. 'style' => 'font-weight: bold; text-transform: uppercase; color: black',
  102. 'class' => 'btn btn-info btn-sm',
  103. 'data-toggle' => 'modal',
  104. 'data-target' => '#myModal2'
  105. ]
  106. );
  107. ?>
  108. <!-- Modal -->
  109. <div class="modal fade" id="myModal2" role="dialog">
  110. <div class="modal-dialog modal-sm">
  111. <!-- Modal content-->
  112. <div class="modal-content">
  113. <div class="modal-header">
  114. <button type="button" class="close" data-dismiss="modal">&times;</button>
  115. <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
  116. </div>
  117. <div class="modal-body">
  118. <div class="container-fluid">
  119. <div class="row">
  120. <div class="col-xs-12">
  121. <div class="form-group">
  122. <label for=""><?= Yii::t('app', 'Кроки'); ?></label>
  123. <input type="number" class="form-control" placeholder="Кроки" min="0" max="100" value="3" id="input-save0">
  124. </div>
  125. </div>
  126. </div>
  127. <div class="row">
  128. <div class="col-xs-4">
  129. <div class="form-group">
  130. <label for=""><?= Yii::t('app', 'Години'); ?></label>
  131. <input type="number" class="form-control" placeholder="Години" min="0" max="23" value="0" id="input-save1">
  132. </div>
  133. </div>
  134. <div class="col-xs-4">
  135. <div class="form-group">
  136. <label for=""><?= Yii::t('app', 'Хвилини'); ?></label>
  137. <input type="number" class="form-control" placeholder="Хвилини" min="0" max="59" value="10" id="input-save2">
  138. </div>
  139. </div>
  140. <div class="col-xs-4">
  141. <div class="form-group">
  142. <label for=""><?= Yii::t('app', 'Секунди'); ?></label>
  143. <input type="number" class="form-control" placeholder="Секунди" min="0" max="59" value="0" id="input-save3">
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="modal-footer">
  150. <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save2', 'data-dismiss' => 'modal']) ?>
  151. <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="lots-form">
  157. <?php
  158. $files = new \app\models\Files();
  159. $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]); ?>
  160. <?= $form->field($model, 'serialize_data')->hiddenInput(['id' => 'serialize_data'])->label(false) ?>
  161. <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id])->label(false) ?>
  162. <div class="auclots-form">
  163. <div class="row">
  164. <div class="col-sm-3">
  165. <label for=""><?= Yii::t('app', 'Час продовження, хв'); ?></label>
  166. <br>
  167. <?= ButtonGroupInput::widget([
  168. 'name' => 'time_cont',
  169. 'items' => [
  170. '00:05' => Yii::t('app', '5 хвилин'),
  171. '00:10' => Yii::t('app', '10 хвилин')
  172. ],
  173. 'value' => '00:05',
  174. ]); ?>
  175. </div>
  176. <div class="col-sm-5">
  177. <label for="type"><?= Yii::t('app', 'Тип аукціону'); ?></label>
  178. <br>
  179. <?= ButtonGroupInput::widget([
  180. 'name' => 'type',
  181. 'items' => [
  182. '1' => Yii::t('app', 'Підвищення'),
  183. '2' => Yii::t('app', 'Голландський'),
  184. '3' => Yii::t('app', 'Банкрутство'),
  185. ],
  186. 'value' => 1,
  187. ]); ?>
  188. </div>
  189. <div class="col-sm-4">
  190. <label for="date_stop"><?= Yii::t('app', 'Дата закінчення'); ?></label>
  191. <br>
  192. <?= DateTimePicker::widget([
  193. 'layout' => '{picker}{input}',
  194. 'value' => isset($model->auction->date_stop) ? $model->auction->date_stop : date('Y-m-d H:i', time() + 360),
  195. 'name' => 'date_stop',
  196. 'id' => 'date_stop',
  197. 'options' => ['placeholder' => Yii::t('app', 'DateStop ID')],
  198. 'pluginOptions' => [
  199. 'autoclose' => true,
  200. 'format' => 'yyyy-mm-dd hh:ii',
  201. ],
  202. ]); ?>
  203. </div>
  204. </div>
  205. <style>.circle_down{display:none;margin:0px}</style>
  206. <?= DetailView::widget([
  207. 'options' => [
  208. 'class' => 'table table-striped table-bordered detail-view circle_down'
  209. ],
  210. 'model' => $model,
  211. 'attributes' =>
  212. [
  213. [
  214. 'label' => Yii::t('app', 'Circle ID'),
  215. 'value' => Html::tag('span', 'кроки 0, час 00:00:00', ['class' => 'lead','id'=>'lead']) . " " . $time_change,
  216. 'format' => 'raw',
  217. ],
  218. ],
  219. ]); ?>
  220. <?= $form->field($model, 'aukname')->textInput(['maxlength' => true]) ?>
  221. <?php $requisites = $model->allRequisites; ?>
  222. <?php if (!$requisites) { ?>
  223. <div class="alert alert-danger alert-dismissible fade in">
  224. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  225. <?= Yii::t('app', 'noRequisites ID')?>
  226. </div>
  227. <?php } ?>
  228. <div class="row">
  229. <div class='col-md-8'>
  230. <?= $form->field($model, 'requisites_id')->dropdownList($requisites) ?>
  231. </div>
  232. <div class='col-md-3' id="addReq">
  233. <label>|</label>
  234. <?= Html::button(Yii::t('app', 'Create Requisites'), ['value' => Url::to('/requisites/create-ajax'), 'class' => 'btn btn-success btn-block', 'id' => 'modalButton']) ;?>
  235. </div>
  236. </div>
  237. <?= $form->field($files, 'project_dogovor')->widget(FileInput::classname(), [
  238. 'model' => $files,
  239. 'pluginOptions' => [
  240. //'allowedFileExtensions'=>['doc','docx','pdf', 'png', ],
  241. 'initialCaption'=>'*.doc *.docx *.pdf *.png *.jpg *.tiff, *.zip *rar',
  242. 'showPreview' => false,
  243. 'showCaption' => true,
  244. 'showRemove' => true,
  245. 'showUpload' => false
  246. ],
  247. 'options' => ['multiple' => false,],
  248. ])->label(Yii::t('app','ProjectDogovor ID')); ?>
  249. <?= $form->field($model, 'bidding_date')->widget(DateTimePicker::className(),[
  250. 'name' => 'bidding_date',
  251. 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
  252. 'value' => date("dd-M-yyyy hh:ii"),
  253. //'options' => ['placeholder' => Yii::t('app','')],
  254. 'pluginOptions' => [
  255. 'autoclose'=>true,
  256. 'format' => 'yyyy-mm-dd hh:ii'
  257. ]
  258. ]) ?>
  259. <?= $form->field($model, 'auction_date')->widget(DateTimePicker::className(),[
  260. 'name' => 'auction_date',
  261. 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
  262. 'value' => date("dd-M-yyyy hh:ii"),
  263. 'options' => ['placeholder' => Yii::t('app','CreateAukDate ID')],
  264. 'pluginOptions' => [
  265. 'autoclose'=>true,
  266. 'format' => 'yyyy-mm-dd hh:ii'
  267. ]
  268. ]) ?>
  269. </div>
  270. <hr>
  271. <?php /*echo $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()
  272. ->where(['user_id' => Yii::$app->user->identity->id])->orderBy('id DESC')->all(), 'name', 'name'))*/ ?>
  273. <!-- ivakhnov -->
  274. <?= $form->field($model, 'num')->textInput(['maxlength' => 255])->label(Yii::t('app','AucNumber ID')) ?>
  275. <?= $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name')) ?>
  276. <?= $form->field($model, 'name')->textInput(['maxlength' => 255])->label(Yii::t('app','LotName ID')) ?>
  277. <?= $form->field($model, 'description')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
  278. <div class="row">
  279. <div class="col-sm-12">
  280. <div class="row">
  281. <div class="col-sm-3">
  282. <label class="price_type-input">
  283. <?= Yii::t('app', 'За одиницю'); ?>
  284. <?= Html::radio('price_type', true, ['value' => 'per_one']); ?>
  285. </label>
  286. </div>
  287. <div class="col-sm-9 per_one">
  288. <div class="row">
  289. <div class="col-sm-4">
  290. <div class="form-group">
  291. <label for=""><?= Yii::t('app', 'Кількість'); ?></label>
  292. <?= Html::activeInput('number', $model, 'count', [
  293. 'class' => 'form-control',
  294. 'id' => 'count-input',
  295. 'min' => 1,
  296. 'max' => 99999999999999999999999,
  297. 'step' => 1,
  298. 'readonly' => 'readonly',
  299. ]); ?>
  300. </div>
  301. </div>
  302. <div class="col-sm-4">
  303. <?= $form->field($model, 'price_per_one', ['inputOptions' => ['readonly' => 'readonly', 'class' => 'form-control']])->label(Yii::t('app', 'Ціна за одиницю')); ?>
  304. </div>
  305. <div class="col-sm-4">
  306. <div class="form-group">
  307. <label><?= Yii::t('app', 'Одиниці виміру'); ?></label>
  308. <?= Html::activeDropDownList($model, 'unitId', ArrayHelper::merge(['' => Yii::t('app', 'Оберіть')], ArrayHelper::map(Units::find()->all(), 'id', 'name')), [
  309. 'class' => 'form-control',
  310. 'readonly' => 'readonly',
  311. ]); ?>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. <div class="col-sm-12">
  319. <div class="row">
  320. <div class="col-sm-3">
  321. <label class="price_type-input">
  322. <?= Yii::t('app', 'Загальна вартість'); ?>
  323. <?= Html::radio('price_type', true, ['value' => 'total']); ?>
  324. </label>
  325. </div>
  326. <div class="col-sm-9 total">
  327. <?= $form->field($model, 'start_price')->textInput()->label(Yii::t('app', 'Загальна віртість')) ?>
  328. </div>
  329. <div class="col-sm-12 total">
  330. <?= Html::tag('label', Yii::t('app', 'Download'), ['class' => 'control-label']);
  331. echo FileInput::widget([
  332. 'model' => new \app\models\Lots,
  333. 'attribute' => 'files[]',
  334. 'options' => [
  335. 'multiple' => true,
  336. ],
  337. 'pluginOptions' => [
  338. 'showPreview' => true,
  339. 'showRemove' => true,
  340. 'showUpload' => false,
  341. 'showCaption' => true,
  342. ],
  343. ]);?>
  344. </div>
  345. </div>
  346. </div>
  347. </div>
  348. <?= $form->field($model, 'nds')->checkbox(['checked ' => true]) ?>
  349. <?= $form->field($model, 'step')->textInput(['maxlength' => true]) ?>
  350. <?= $form->field($files, 'file[]')->widget(FileInput::classname(), [
  351. 'model' => $files,
  352. 'pluginOptions' => [
  353. //'allowedFileExtensions'=>['doc','docx','pdf'],
  354. 'initialCaption'=>'*.doc, *.docx, *.pdf *.png *.jpg *.tiff *.zip *.rar',
  355. 'showPreview' => true,
  356. 'showCaption' => true,
  357. 'showRemove' => true,
  358. 'showUpload' => false,
  359. 'maxFileCount' => 10,
  360. ],
  361. 'options' => [
  362. 'multiple' => true,
  363. ],
  364. ])->label(Yii::t('app','DopDocumentation ID')); ?>
  365. <?= $form->field($model, 'payment_term')->textInput(['maxlength' => true]) ?>
  366. <?= $form->field($model, 'member_require')->textarea(/*['maxlength' => 5000, 'rows' => 50, 'cols' => 100]*/) ?>
  367. <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>
  368. <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
  369. <!--
  370. <?= $form->field($model, 'delivery_time')->textInput(['maxlength' => true]) ?>
  371. <?= $form->field($model, 'delivery_term')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
  372. <?= $form->field($model, 'requires')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
  373. <?= $form->field($model, 'member_docs')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?> --!>
  374. <?= $form->field($model, 'notes')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
  375. <?= $form->field($model, 'date')->hiddenInput(['value' => date('Y-m-d H:i:s')])->label(false); ?>
  376. <!-- <?= $form->field($model, 'status')->textInput() ?> --!>
  377. <div class="form-group">
  378. <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create ID') : Yii::t('app', 'Update ID'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  379. </div>
  380. <?php ActiveForm::end(); ?>
  381. </div>