view.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\DetailView;
  4. use kartik\file\FileInput;
  5. use yii\widgets\ActiveForm;
  6. use kartik\datetime\DateTimePicker;
  7. use yii\helpers\Url;
  8. use app\models\Files;
  9. use app\widgets\ButtonGroupInput;
  10. /* @var $this yii\web\View */
  11. /* @var $model app\models\Lots */
  12. $url = Url::to(['confirm', 'id' => $model->id]);
  13. $this->registerJs(<<<JS
  14. $('input[name="status"]').on('change', function(e){
  15. var self = $(this);
  16. $.get('$url' + '&status=' + self.val(), function(data){
  17. if(data !== 1){
  18. window.location.reload();
  19. }
  20. });
  21. });
  22. $('input[name="statusOrg"]').on('change', function(e){
  23. var self = $(this);
  24. $.get('$url' + '&status=' + self.val(), function(data){
  25. if(data !== 1){
  26. window.location.reload();
  27. }
  28. });
  29. });
  30. JS
  31. );
  32. $this->title = $model->name;
  33. if(Yii::$app->user->can('member')) {
  34. $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Auction ID'), 'url' => ['/auctions/index']];
  35. } else {
  36. $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Lots ID'), 'url' => ['index']];
  37. }
  38. $this->params['breadcrumbs'][] = $this->title;
  39. if(Yii::$app->user->can('admin')) {
  40. $time_change = Html::button(Yii::t('app', 'Time Value'), ['style' => 'font-weight: bold; text-transform: uppercase; color: black', 'class' => 'btn btn-info btn-sm',
  41. 'data-toggle' => 'modal', 'data-target' => '#myModal2']);
  42. $circle_change = Html::button(Yii::t('app', 'Enter value'), ['style' => 'font-weight: bold; text-transform: uppercase; color: black', 'class' => 'btn btn-info btn-sm',
  43. 'data-toggle' => 'modal', 'data-target' => '#myModal']);
  44. } else {
  45. $time_change = '';
  46. $circle_change = '';
  47. }
  48. $circle_down = Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-minus']), ['circle_down', 'id' => $model->id], ['class' => 'btn btn-xs btn-primary']);
  49. $circle_up = Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-plus']), ['circle_up', 'id' => $model->id], ['class' => 'btn btn-xs btn-primary']);
  50. $status = ButtonGroupInput::widget([
  51. 'name' => 'status',
  52. 'items' => [
  53. '1' => Yii::t('app', 'Обробляється'),
  54. '2' => Yii::t('app', 'Узгоджено'),
  55. '3' => Yii::t('app', 'Відхилено'),
  56. ],
  57. 'value' => $model->status
  58. ]);
  59. $statusOrg = ButtonGroupInput::widget([
  60. 'name' => 'status',
  61. 'items' => [
  62. '3' => Yii::t('app', 'Відхилено'),
  63. '4' => Yii::t('app','Узгоджено організатором'),
  64. ],
  65. 'value' => $model->status
  66. ]);
  67. if($model->docs_id) {
  68. $docs = Html::a(Yii::t('app', 'Download ID'), ['/files/download', 'id' => $model->docs_id], ['class' => 'glyphicon glyphicon-circle-arrow-down']);
  69. } else {
  70. $docs = NULL;
  71. }
  72. if($model->dogovor_id) {
  73. $dogovor = Html::a(Yii::t('app', 'Download ID'), ['/files/download', 'id' => $model->dogovor_id], ['class' => 'glyphicon glyphicon-circle-arrow-down']);
  74. } else {
  75. $docs = NULL;
  76. }
  77. if($model->nds == 1) {
  78. $price_nds = $model->start_price . " " . Yii::t('app', 'zNDS ID');
  79. } else {
  80. $price_nds = $model->start_price . " " . Yii::t('app', 'bNDS ID');
  81. }
  82. $registration_fee = $model->start_price * 0.0015;
  83. $guarantee_fee = $model->start_price * 0.015;
  84. //ivakhnov
  85. $js = '$("#button-save").on("click",function(e){
  86. var value = $("#input-save").val();
  87. var id = ' . $model->id . ';
  88. if(value.length > 0){
  89. $.post("' . Url::to(['/lots/step-change']) . '",
  90. {
  91. value: value,
  92. id: id
  93. },);
  94. }
  95. });
  96. $("#lot-form").on("beforeSubmit", function(e){
  97. if($("input[name=\"status\"]:checked").val() != 2){
  98. alert("' . Yii::t('app', 'Необхідно узгодити лот') . '");
  99. return false;
  100. }
  101. });
  102. $("input[name=\"type\"]").on("change", function(e){
  103. var self = $(this),
  104. form = $("#lot-form");
  105. form.attr("action", "/lots/auction?" + self.val() + "?id=' . $model->id . '");
  106. form.attr("action", "/lots/auction?id=' . $model->id . '&type=" + self.val());
  107. });
  108. $("#button-save2").on("click",function(e){
  109. var val1 = $("#input-save1").val();
  110. var val2 = $("#input-save2").val();
  111. var val3 = $("#input-save3").val();
  112. var value1 = value2 = value3 = 0;
  113. if(val1 > 0){
  114. value1 = val1;
  115. }
  116. if(val2 > 0){
  117. value2 = val2;
  118. }
  119. if(val3 > 0){
  120. value3 = val3;
  121. }
  122. var concat_val = value1 + ":"+ value2 + ":" + value3;
  123. var id = ' . $model->id . ';
  124. if(concat_val.length > 0){
  125. $.post("' . Url::to(['/lots/time-step-change']) . '",
  126. {
  127. concat_val: concat_val,
  128. id: id
  129. },
  130. function(data){
  131. }
  132. );
  133. }
  134. });
  135. $(document).ready(function () {
  136. $(\'input[type=checkbox]\').change(function(){
  137. $(this).parent().siblings().children().filter(\':checked\').not(this).removeAttr(\'checked\');
  138. });
  139. });
  140. ';
  141. $this->registerJs($js);
  142. //--------
  143. ?>
  144. <!-- Modal by Ivakhnov -->
  145. <!-- Modal -->
  146. <div class="modal fade" id="myModal" role="dialog">
  147. <div class="modal-dialog modal-sm">
  148. <!-- Modal content-->
  149. <div class="modal-content">
  150. <div class="modal-header">
  151. <button type="button" class="close" data-dismiss="modal">&times;</button>
  152. <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
  153. </div>
  154. <div class="modal-body">
  155. <p><input type="number" class="form-control" value="<?= $model->step_down ?>" id="input-save"></p>
  156. </div>
  157. <div class="modal-footer">
  158. <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save']) ?>
  159. <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="modal fade" id="myModal2" role="dialog">
  165. <div class="modal-dialog modal-sm">
  166. <!-- Modal content-->
  167. <div class="modal-content">
  168. <div class="modal-header">
  169. <button type="button" class="close" data-dismiss="modal">&times;</button>
  170. <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
  171. </div>
  172. <div class="modal-body">
  173. <div class="container-fluid">
  174. <div class="row">
  175. <div class="col-xs-4">
  176. <div class="form-group">
  177. <label for=""><?= Yii::t('app', 'Години'); ?></label>
  178. <input type="number" class="form-control" placeholder="Години" value="0" id="input-save1">
  179. </div>
  180. </div>
  181. <div class="col-xs-4">
  182. <div class="form-group">
  183. <label for=""><?= Yii::t('app', 'Хвилини'); ?></label>
  184. <input type="number" class="form-control" placeholder="Хвилини" max="59" value="10" id="input-save2">
  185. </div>
  186. </div>
  187. <div class="col-xs-4">
  188. <div class="form-group">
  189. <label for=""><?= Yii::t('app', 'Секунди'); ?></label>
  190. <input type="number" class="form-control" placeholder="Секунди" max="59" value="0" id="input-save3">
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. <div class="modal-footer">
  197. <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save2']) ?>
  198. <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <div class="panel panel-primary">
  204. <div class="panel-heading"><span class="glyphicon glyphicon-stats"></span><strong>
  205. <?= Html::encode($this->title) ?></strong>
  206. <?php if (Yii::$app->user->id == $model->user_id || Yii::$app->user->can('admin')): ?>
  207. <?php if(Yii::$app->user->can('org') || Yii::$app->user->can('admin')): ?>
  208. <?= Html::a(Yii::t('app', 'Update ID'), ['update', 'id' => $model->id], ['class' => 'btn btn-warning']); ?>
  209. <?= Html::a(Yii::t('app', 'Delete ID'), ['delete', 'id' => $model->id], [
  210. 'class' => 'btn btn-danger',
  211. 'data' => [
  212. 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  213. 'method' => 'post',
  214. ]]); ?>
  215. <?php endif; ?>
  216. <?php endif; ?>
  217. </div>
  218. <div class="panel-body">
  219. <div class="lots-view">
  220. <div class="container">
  221. <div class="row">
  222. <div class="col-sm-12">
  223. <?= $this->render('_alert.php') ?>
  224. <?php
  225. if(Yii::$app->user->can('admin'))
  226. {
  227. ActiveForm::begin([
  228. 'action' => ['/lots/auction', 'id' => $model->id, 'type' => 1],
  229. 'id' => 'lot-form',
  230. ]); ?>
  231. <div class="row">
  232. <div class="col-sm-3">
  233. <label for=""><?= Yii::t('app', 'Час продовження, хв'); ?></label>
  234. <br>
  235. <?= ButtonGroupInput::widget([
  236. 'name' => 'time_cont',
  237. 'items' => ['00:05' => Yii::t('app', '5 хвилин'), '00:10' => Yii::t('app', '10 хвилин')],
  238. 'value' => '00:05',
  239. ]); ?>
  240. </div>
  241. <div class="col-sm-5">
  242. <label for="type"><?= Yii::t('app', 'Тип аукціону'); ?></label>
  243. <br>
  244. <?= ButtonGroupInput::widget([
  245. 'name' => 'type',
  246. 'items' => [
  247. '1' => Yii::t('app', 'Підвищення'),
  248. '2' => Yii::t('app', 'Голландський'),
  249. '3' => Yii::t('app', 'Банкрутство'),
  250. ],
  251. 'value' => '1',
  252. ]); ?>
  253. </div>
  254. <div class="col-sm-2">
  255. <label for="date_stop"><?= Yii::t('app', 'Дата закінчення'); ?></label>
  256. <br>
  257. <?= DateTimePicker::widget([
  258. 'layout' => '{picker}{input}',
  259. 'value' => date('Y-m-d H:i', time() + 360),
  260. 'name' => 'date_stop',
  261. 'options' => ['placeholder' => Yii::t('app', 'DateStop ID')],
  262. 'pluginOptions' => [
  263. 'autoclose' => true,
  264. 'format' => 'yyyy-mm-dd hh:ii',
  265. ],
  266. ]); ?>
  267. </div>
  268. <div class="col-sm-2">
  269. <label for="">&nbsp;</label>
  270. <br>
  271. <?php if(Yii::$app->user->can('admin')): ?>
  272. <?= Html::submitButton(Yii::t('app', 'Створити'), ['class' => 'btn btn-success']); ?>
  273. <?php elseif(Yii::$app->user->can('org')): ?>
  274. <?= Html::a('&larr;До Аукціонів', ['lots/index'], ['class' => 'btn btn-info']) ?>
  275. <?php endif;?>
  276. </div>
  277. </div>
  278. <?php ActiveForm::end(); ?>
  279. </div>
  280. <div class="row">
  281. <div class="col-xs-12">
  282. <hr>
  283. </div>
  284. <div class="col-sm-2">
  285. <p class="lead"><?= Yii::t('app', 'Статус'); ?>:</p>
  286. </div>
  287. <div class="col-sm-4">
  288. <?= $status; ?>
  289. </div>
  290. </div>
  291. <hr>
  292. </div>
  293. <?php
  294. } else {
  295. $files = new Files();
  296. if(false != ($file = Files::findOne([
  297. 'user_id' => Yii::$app->user->id,
  298. 'type' => 'bid',
  299. 'lot_id' => $model->id,
  300. ]))) {
  301. $bidding = new \app\models\Bidding();
  302. $form = ActiveForm::begin([
  303. 'action' => Url::to(['/auctions/bid', 'id' => $model->auction->id]),
  304. ]); ?>
  305. <?= $form->field($bidding, 'special_price'); ?>
  306. <div class="form-group">
  307. <?= Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-success']); ?>
  308. <?= Html::a(Yii::t('app', 'Download file'), ["/files/download", 'id' => $file->id], ['class' => 'btn btn-warning']); ?>
  309. </div>
  310. <?php
  311. ActiveForm::end();
  312. } else {
  313. $form = ActiveForm::begin([
  314. 'options' => ['enctype' => 'multipart/form-data'] // important
  315. ]);
  316. echo $form->field($files, 'file')->widget(FileInput::classname(), [
  317. 'options' => ['multiple' => true],
  318. 'pluginOptions' => [
  319. 'initialCaption' => 'файл типу: doc, docx, pdf, jpg, png, zip, rar (розмiр не бiльше 40Мб)',
  320. 'showPreview' => true,
  321. 'overwriteInitial' => false,
  322. 'pluginLoading' => true,
  323. 'initialPreviewAsData' => true,
  324. 'uploadClass' => 'btn btn-danger',
  325. 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i>',
  326. ],
  327. ])->label(Yii::t('app', 'DownloadMemeberDoc ID'));
  328. ActiveForm::end();
  329. }
  330. }
  331. ?>
  332. <?= DetailView::widget([
  333. 'model' => $model,
  334. 'attributes' =>
  335. [
  336. [
  337. 'label' => Yii::t('app', 'Circle ID'),
  338. 'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
  339. 'format' => 'raw',
  340. ],
  341. 'aukname',
  342. 'name',
  343. 'categoryName',
  344. 'description',
  345. 'auction_date',
  346. 'bidding_date',
  347. [
  348. 'attribute' => 'start_price',
  349. 'value' => $price_nds,
  350. ],
  351. [
  352. 'attribute' => 'count',
  353. 'value' => $model->count,
  354. 'visible' => $model->count,
  355. ],
  356. [
  357. 'attribute' => 'price_per_one',
  358. 'value' => $model->unitId ? ($model->start_price / $model->count) : '',
  359. 'visible' => $model->unitId ? true : false,
  360. ],
  361. [
  362. 'attribute' => 'unitName',
  363. 'value' => $model->unit ? $model->unit->name : '',
  364. 'visible' => $model->unitId ? true : false,
  365. ],
  366. 'step',
  367. [
  368. 'attribute' => 'docs_id',
  369. 'value' => $docs,
  370. 'format' => 'raw',
  371. ],
  372. 'address',
  373. 'member_require',
  374. 'payment_term',
  375. 'notes',
  376. [
  377. 'attribute' => 'dogovor_id',
  378. 'value' => $dogovor,
  379. 'format' => 'raw',
  380. ],
  381. [
  382. 'attribute' => Yii::t('app', 'Registration fee'),
  383. 'value' => $registration_fee .
  384. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  385. [
  386. '/bills/download-requisites',
  387. 'id' => $model->billPayRegistration,
  388. ],
  389. [
  390. 'target' => '_blank',
  391. 'title' => Yii::t('app', 'Download bill')
  392. ]
  393. ),
  394. 'format' => 'raw',
  395. ],
  396. [
  397. 'attribute' => Yii::t('app', 'Guaranteed payment'),
  398. 'value' => $guarantee_fee .
  399. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  400. [
  401. '/bills/download-requisites',
  402. 'id' => $model->billPayGuarantee,
  403. ],
  404. [
  405. 'target' => '_blank',
  406. 'title' => Yii::t('app', 'Download bill')
  407. ]
  408. ),
  409. 'format' => 'raw',
  410. ],
  411. ],
  412. ]) ?>
  413. </div>
  414. </div>
  415. </div>