view.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. ///$mid = isset($model->id) ? $model->id : 0;
  13. $url = Url::to(['confirm', 'id' => $model->id]);
  14. $this->registerJs(<<<JS
  15. $('input[name="status"]').on('change', function(e){
  16. var self = $(this);
  17. $.get('$url' + '&status=' + self.val(), function(data){
  18. if(data !== 1){
  19. window.location.reload();
  20. }
  21. });
  22. });
  23. // $("#lot-form").on("beforeSubmit", function(e){
  24. // if($("input[name=\"status\"]:checked").val() != 2){
  25. // alert("' . Yii::t('app', 'Необхідно узгодити лот') . '");
  26. // return false;
  27. // }
  28. // });
  29. JS
  30. );
  31. $this->title = $model->name;
  32. if(Yii::$app->user->can('member')) {
  33. $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Auction ID'), 'url' => ['/auctions/index']];
  34. } else {
  35. $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Lots ID'), 'url' => ['index']];
  36. }
  37. $this->params['breadcrumbs'][] = $this->title;
  38. $status = ButtonGroupInput::widget([
  39. 'name' => 'status',
  40. 'items' => [
  41. '1' => Yii::t('app', 'Обробляється'),
  42. '2' => Yii::t('app', 'Узгоджено'),
  43. '3' => Yii::t('app', 'Відхилено'),
  44. ],
  45. 'value' => $model->status
  46. ]);
  47. if($model->docs_id) {
  48. $docs = Html::a(Yii::t('app', 'Download ID'), ['/files/download', 'id' => $model->docs_id], ['class' => 'glyphicon glyphicon-circle-arrow-down']);
  49. } else {
  50. $docs = NULL;
  51. }
  52. if($model->dogovor_id) {
  53. $dogovor = Html::a(Yii::t('app', 'Download ID'), ['/files/download', 'id' => $model->dogovor_id], ['class' => 'glyphicon glyphicon-circle-arrow-down']);
  54. } else {
  55. $docs = NULL;
  56. }
  57. if($model->nds == 1) {
  58. $price_nds = $model->start_price . " " . Yii::t('app', 'zNDS ID');
  59. } else {
  60. $price_nds = $model->start_price . " " . Yii::t('app', 'bNDS ID');
  61. }
  62. $registration_fee = 120.00 . 'грн ' . Yii::t('app', 'zNDS ID');//$model->start_price * 0.0015;
  63. $guarantee_fee = $model->start_price * 0.015;
  64. $serialize_data = json_decode($model->serialize_data);
  65. $parts = array_pad(explode(':', $serialize_data->time_step_change), 3, 0);
  66. $timeStepFormat = sprintf(
  67. "%02d:%02d:%02d.00000",
  68. (int)$parts[0],
  69. (int)$parts[1],
  70. (int)$parts[2]
  71. );
  72. ?>
  73. <!-- Modal by Ivakhnov -->
  74. <div class="panel panel-primary">
  75. <div class="panel-heading">
  76. <span class="glyphicon glyphicon-stats"></span>
  77. <<<<<<< HEAD
  78. <strong><?= Html::encode("(#" . $model->id . ") - " . $this->title) ?></strong>
  79. =======
  80. <strong><?= Html::encode($this->title) ?></strong>
  81. >>>>>>> 5bd9408fb32cecb076e639952fbeaaed915e69ce
  82. <?php if(Yii::$app->user->id == $model->user_id || Yii::$app->user->can('admin')): ?>
  83. <?= Html::a(Yii::t('app', 'Update ID'), ['update', 'id' => $model->id], [
  84. 'class' => 'btn btn-warning']); ?>
  85. <?= Html::a(Yii::t('app', 'Delete ID'), ['delete', 'id' => $model->id], [
  86. 'class' => 'btn btn-danger',
  87. 'data' => [
  88. 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  89. 'method' => 'post',
  90. ]]); ?>
  91. <?php endif; ?>
  92. </div>
  93. <div class="panel-body">
  94. <div class="lots-view">
  95. <div class="container">
  96. <div class="row">
  97. <div class="col-sm-12">
  98. <?= $this->render('_alert.php') ?>
  99. <?php
  100. if((Yii::$app->user->id == $model->user_id) || Yii::$app->user->can('admin'))
  101. {
  102. ActiveForm::begin([
  103. 'action' => ['/lots/auction', 'id' => $model->id, 'type' => 1],
  104. 'id' => 'lot-form',
  105. ]); ?>
  106. <?= DetailView::widget([
  107. 'options' => [
  108. 'class' => 'table table-striped table-bordered detail-view'
  109. ],
  110. 'model' => $serialize_data,
  111. 'attributes' =>
  112. [
  113. [
  114. <<<<<<< HEAD
  115. 'label' => 'Організатор аукціону',
  116. 'value' => isset($model->auction) ? $model->auction->user->at_org : $model->user->at_org,
  117. 'format' => 'raw',
  118. ],
  119. [
  120. =======
  121. >>>>>>> 5bd9408fb32cecb076e639952fbeaaed915e69ce
  122. 'label' => 'Тип аукціону',
  123. 'value' => function ($model){
  124. if($model->type == 1){
  125. return 'Підвищення';
  126. }
  127. if($model->type == 2){
  128. return 'Голландський';
  129. }
  130. if($model->type == 3){
  131. return 'Банкрутство';
  132. }
  133. },
  134. 'format' => 'raw',
  135. ],
  136. [
  137. 'label' => 'Дата закінчення',
  138. 'value' => $serialize_data->date_stop,
  139. 'format' => 'raw',
  140. ],
  141. [
  142. 'label' => 'Час продовження, хв',
  143. 'value' => explode(":",$serialize_data->time_cont)[1]." хв",
  144. 'format' => 'raw',
  145. ],
  146. ],
  147. ]); ?>
  148. <?php if($serialize_data->type == 2): ?>
  149. <?= DetailView::widget([
  150. 'options' => [
  151. 'class' => 'table table-striped table-bordered detail-view'
  152. ],
  153. 'model' => $serialize_data,
  154. 'attributes' =>
  155. [
  156. [
  157. 'label' => 'Крок',
  158. 'value' => $serialize_data->step_change,
  159. 'format' => 'raw',
  160. <<<<<<< HEAD
  161. ],
  162. [
  163. 'label' => 'Час',
  164. 'value' => $timeStepFormat,
  165. 'format' => 'raw',
  166. ],
  167. =======
  168. ],
  169. [
  170. 'label' => 'Час',
  171. 'value' => $timeStepFormat,
  172. 'format' => 'raw',
  173. ],
  174. >>>>>>> 5bd9408fb32cecb076e639952fbeaaed915e69ce
  175. ],
  176. ]); ?>
  177. <?php endif; ?>
  178. <div class="row">
  179. <?php if(Yii::$app->user->can('admin')): ?>
  180. <div class="col-sm-6">
  181. <?= $status; ?>
  182. </div>
  183. <div class="col-sm-6">
  184. <?= Html::submitButton(Yii::t('app', 'Підтвердити / Створити'), ['class' => 'btn btn-success']); ?>
  185. </div>
  186. <?php endif;?>
  187. </div>
  188. <?php ActiveForm::end(); ?>
  189. <br>
  190. </div>
  191. <hr>
  192. </div>
  193. <?php
  194. } else {
  195. $files = new Files();
  196. if(false != ($file = Files::findOne([
  197. 'user_id' => Yii::$app->user->id,
  198. 'type' => 'bid',
  199. 'lot_id' => $model->id,
  200. ]))) {
  201. $bidding = new \app\models\Bidding();
  202. $form = ActiveForm::begin([
  203. 'action' => Url::to(['/auctions/bid', 'id' => $model->auction->id]),
  204. ]); ?>
  205. <?= $form->field($bidding, 'special_price'); ?>
  206. <div class="form-group">
  207. <?= Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-success']); ?>
  208. <?= Html::a(Yii::t('app', 'Download file'), ["/files/download", 'id' => $file->id], ['class' => 'btn btn-warning']); ?>
  209. </div>
  210. <?php
  211. ActiveForm::end();
  212. } else {
  213. $form = ActiveForm::begin([
  214. 'options' => ['enctype' => 'multipart/form-data'] // important
  215. ]);
  216. echo $form->field($files, 'file')->widget(FileInput::classname(), [
  217. 'options' => ['multiple' => true],
  218. 'pluginOptions' => [
  219. 'initialCaption' => 'файл типу: doc, docx, pdf, jpg, png, zip, rar (розмiр не бiльше 40Мб)',
  220. 'showPreview' => true,
  221. 'overwriteInitial' => false,
  222. 'pluginLoading' => true,
  223. 'initialPreviewAsData' => true,
  224. 'uploadClass' => 'btn btn-danger',
  225. 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i>',
  226. ],
  227. ])->label(Yii::t('app', 'DownloadMemeberDoc ID'));
  228. ActiveForm::end();
  229. }
  230. }
  231. ?>
  232. <?= DetailView::widget([
  233. 'model' => $model,
  234. 'attributes' =>
  235. [
  236. // [
  237. // 'label' => Yii::t('app', 'Circle ID'),
  238. // 'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
  239. // 'format' => 'raw',
  240. // ],
  241. 'aukname',
  242. 'name',
  243. 'categoryName',
  244. 'description',
  245. 'auction_date',
  246. 'bidding_date',
  247. [
  248. 'attribute' => 'start_price',
  249. 'value' => $price_nds,
  250. ],
  251. [
  252. 'attribute' => 'count',
  253. 'value' => $model->count,
  254. 'visible' => $model->count,
  255. ],
  256. [
  257. 'attribute' => 'price_per_one',
  258. 'value' => $model->unitId ? ($model->start_price / $model->count) : '',
  259. 'visible' => $model->unitId ? true : false,
  260. ],
  261. [
  262. 'attribute' => 'unitName',
  263. 'value' => $model->unit ? $model->unit->name : '',
  264. 'visible' => $model->unitId ? true : false,
  265. ],
  266. 'step',
  267. [
  268. 'attribute' => 'docs_id',
  269. 'value' => $docs,
  270. 'format' => 'raw',
  271. ],
  272. 'address',
  273. 'member_require',
  274. 'payment_term',
  275. 'notes',
  276. [
  277. 'attribute' => 'dogovor_id',
  278. 'value' => $dogovor,
  279. 'format' => 'raw',
  280. ],
  281. [
  282. 'attribute' => Yii::t('app', 'Registration fee'),
  283. 'value' =>
  284. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ',
  285. [
  286. '/bills/download-requisites',
  287. 'id' => $model->getBillPayDocument(),
  288. ],
  289. [
  290. 'target' => '_blank',
  291. 'title' => Yii::t('app', 'Download bill')
  292. ]
  293. ) . $registration_fee,
  294. 'format' => 'raw',
  295. ],
  296. [
  297. 'attribute' => Yii::t('app', 'Guaranteed payment'),
  298. 'value' => function($model) use ($guarantee_fee){
  299. $id = $model->getBillPayDocument("guarantee");
  300. if(!$id){
  301. return Html::a(
  302. '<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ', '#', [
  303. 'title' => 'Завантажити рахунок',
  304. 'onclick' => "alert('Для завантаження рахунку, треба подати заявку на лот/аукціон'); return false;",
  305. ]) . $guarantee_fee . 'грн ' . Yii::t('app', 'zNDS ID');
  306. } else {
  307. return Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ',
  308. [
  309. '/bills/download-requisites',
  310. 'id' => $id,
  311. ],
  312. [
  313. 'target' => '_blank',
  314. 'title' => 'Завантажити рахунок'
  315. ]
  316. ) . $guarantee_fee . 'грн ' . Yii::t('app', 'zNDS ID');
  317. }
  318. },
  319. 'format' => 'raw',
  320. ],
  321. // [
  322. // 'attribute' => Yii::t('app', 'Guaranteed payment'),
  323. // 'value' => $guarantee_fee .
  324. // Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  325. // [
  326. // '/bills/download-requisites',
  327. // 'id' => $model->getBillPayDocument("guarantee"),
  328. // ],
  329. // [
  330. // 'target' => '_blank',
  331. // 'title' => Yii::t('app', 'Download bill')
  332. // ]
  333. // ),
  334. // 'format' => 'raw',
  335. // ],
  336. ],
  337. ]) ?>
  338. </div>
  339. </div>
  340. </div>