_admin.php 18 KB

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