view.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. <strong><?= Html::encode("(#" . $model->id . ") - " . $this->title) ?></strong>
  78. <?php if(Yii::$app->user->id == $model->user_id || Yii::$app->user->can('admin')): ?>
  79. <?= Html::a(Yii::t('app', 'Update ID'), ['update', 'id' => $model->id], [
  80. 'class' => 'btn btn-warning']); ?>
  81. <?= Html::a(Yii::t('app', 'Delete ID'), ['delete', 'id' => $model->id], [
  82. 'class' => 'btn btn-danger',
  83. 'data' => [
  84. 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  85. 'method' => 'post',
  86. ]]); ?>
  87. <?php endif; ?>
  88. </div>
  89. <div class="panel-body">
  90. <div class="lots-view">
  91. <div class="container">
  92. <div class="row">
  93. <div class="col-sm-12">
  94. <?= $this->render('_alert.php') ?>
  95. <?php
  96. if((Yii::$app->user->id == $model->user_id) || Yii::$app->user->can('admin'))
  97. {
  98. ActiveForm::begin([
  99. 'action' => ['/lots/auction', 'id' => $model->id, 'type' => 1],
  100. 'id' => 'lot-form',
  101. ]); ?>
  102. <?= DetailView::widget([
  103. 'options' => [
  104. 'class' => 'table table-striped table-bordered detail-view'
  105. ],
  106. 'model' => $serialize_data,
  107. 'attributes' =>
  108. [
  109. [
  110. 'label' => 'Організатор аукціону',
  111. 'value' => isset($model->auction) ? $model->auction->user->at_org : $model->user->at_org,
  112. 'format' => 'raw',
  113. ],
  114. [
  115. 'label' => 'Тип аукціону',
  116. 'value' => function ($model){
  117. if($model->type == 1){
  118. return 'Підвищення';
  119. }
  120. if($model->type == 2){
  121. return 'Голландський';
  122. }
  123. if($model->type == 3){
  124. return 'Банкрутство';
  125. }
  126. },
  127. 'format' => 'raw',
  128. ],
  129. [
  130. 'label' => 'Дата закінчення',
  131. 'value' => $serialize_data->date_stop,
  132. 'format' => 'raw',
  133. ],
  134. [
  135. 'label' => 'Час продовження, хв',
  136. 'value' => explode(":",$serialize_data->time_cont)[1]." хв",
  137. 'format' => 'raw',
  138. ],
  139. ],
  140. ]); ?>
  141. <?php if($serialize_data->type == 2): ?>
  142. <?= DetailView::widget([
  143. 'options' => [
  144. 'class' => 'table table-striped table-bordered detail-view'
  145. ],
  146. 'model' => $serialize_data,
  147. 'attributes' =>
  148. [
  149. [
  150. 'label' => 'Крок',
  151. 'value' => $serialize_data->step_change,
  152. 'format' => 'raw',
  153. ],
  154. [
  155. 'label' => 'Час',
  156. 'value' => $timeStepFormat,
  157. 'format' => 'raw',
  158. ],
  159. ],
  160. ]); ?>
  161. <?php endif; ?>
  162. <div class="row">
  163. <?php if(Yii::$app->user->can('admin')): ?>
  164. <div class="col-sm-6">
  165. <?= $status; ?>
  166. </div>
  167. <div class="col-sm-6">
  168. <?= Html::submitButton(Yii::t('app', 'Підтвердити / Створити'), ['class' => 'btn btn-success']); ?>
  169. </div>
  170. <?php endif;?>
  171. </div>
  172. <?php ActiveForm::end(); ?>
  173. <br>
  174. </div>
  175. <hr>
  176. </div>
  177. <?php
  178. } else {
  179. $files = new Files();
  180. if(false != ($file = Files::findOne([
  181. 'user_id' => Yii::$app->user->id,
  182. 'type' => 'bid',
  183. 'lot_id' => $model->id,
  184. ]))) {
  185. $bidding = new \app\models\Bidding();
  186. $form = ActiveForm::begin([
  187. 'action' => Url::to(['/auctions/bid', 'id' => $model->auction->id]),
  188. ]); ?>
  189. <?= $form->field($bidding, 'special_price'); ?>
  190. <div class="form-group">
  191. <?= Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-success']); ?>
  192. <?= Html::a(Yii::t('app', 'Download file'), ["/files/download", 'id' => $file->id], ['class' => 'btn btn-warning']); ?>
  193. </div>
  194. <?php
  195. ActiveForm::end();
  196. } else {
  197. $form = ActiveForm::begin([
  198. 'options' => ['enctype' => 'multipart/form-data'] // important
  199. ]);
  200. echo $form->field($files, 'file')->widget(FileInput::classname(), [
  201. 'options' => ['multiple' => true],
  202. 'pluginOptions' => [
  203. 'initialCaption' => 'файл типу: doc, docx, pdf, jpg, png, zip, rar (розмiр не бiльше 40Мб)',
  204. 'showPreview' => true,
  205. 'overwriteInitial' => false,
  206. 'pluginLoading' => true,
  207. 'initialPreviewAsData' => true,
  208. 'uploadClass' => 'btn btn-danger',
  209. 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i>',
  210. ],
  211. ])->label(Yii::t('app', 'DownloadMemeberDoc ID'));
  212. ActiveForm::end();
  213. }
  214. }
  215. ?>
  216. <?= DetailView::widget([
  217. 'model' => $model,
  218. 'attributes' =>
  219. [
  220. // [
  221. // 'label' => Yii::t('app', 'Circle ID'),
  222. // 'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
  223. // 'format' => 'raw',
  224. // ],
  225. 'aukname',
  226. 'name',
  227. 'categoryName',
  228. 'description',
  229. 'auction_date',
  230. 'bidding_date',
  231. [
  232. 'attribute' => 'start_price',
  233. 'value' => $price_nds,
  234. ],
  235. [
  236. 'attribute' => 'count',
  237. 'value' => $model->count,
  238. 'visible' => $model->count,
  239. ],
  240. [
  241. 'attribute' => 'price_per_one',
  242. 'value' => $model->unitId ? ($model->start_price / $model->count) : '',
  243. 'visible' => $model->unitId ? true : false,
  244. ],
  245. [
  246. 'attribute' => 'unitName',
  247. 'value' => $model->unit ? $model->unit->name : '',
  248. 'visible' => $model->unitId ? true : false,
  249. ],
  250. 'step',
  251. [
  252. 'attribute' => 'docs_id',
  253. 'value' => $docs,
  254. 'format' => 'raw',
  255. ],
  256. 'address',
  257. 'member_require',
  258. 'payment_term',
  259. 'notes',
  260. [
  261. 'attribute' => 'dogovor_id',
  262. 'value' => $dogovor,
  263. 'format' => 'raw',
  264. ],
  265. [
  266. 'attribute' => Yii::t('app', 'Registration fee'),
  267. 'value' =>
  268. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ',
  269. [
  270. '/bills/download-requisites',
  271. 'id' => $model->getBillPayDocument(),
  272. ],
  273. [
  274. 'target' => '_blank',
  275. 'title' => Yii::t('app', 'Download bill')
  276. ]
  277. ) . $registration_fee,
  278. 'format' => 'raw',
  279. ],
  280. [
  281. 'attribute' => Yii::t('app', 'Guaranteed payment'),
  282. 'value' => function($model) use ($guarantee_fee){
  283. $id = $model->getBillPayDocument("guarantee");
  284. if(!$id){
  285. return Html::a(
  286. '<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ', '#', [
  287. 'title' => 'Завантажити рахунок',
  288. 'onclick' => "alert('Для завантаження рахунку, треба подати заявку на лот/аукціон'); return false;",
  289. ]) . $guarantee_fee . 'грн ' . Yii::t('app', 'zNDS ID');
  290. } else {
  291. return Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i> Завантажити рахунок ',
  292. [
  293. '/bills/download-requisites',
  294. 'id' => $id,
  295. ],
  296. [
  297. 'target' => '_blank',
  298. 'title' => 'Завантажити рахунок'
  299. ]
  300. ) . $guarantee_fee . 'грн ' . Yii::t('app', 'zNDS ID');
  301. }
  302. },
  303. 'format' => 'raw',
  304. ],
  305. // [
  306. // 'attribute' => Yii::t('app', 'Guaranteed payment'),
  307. // 'value' => $guarantee_fee .
  308. // Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  309. // [
  310. // '/bills/download-requisites',
  311. // 'id' => $model->getBillPayDocument("guarantee"),
  312. // ],
  313. // [
  314. // 'target' => '_blank',
  315. // 'title' => Yii::t('app', 'Download bill')
  316. // ]
  317. // ),
  318. // 'format' => 'raw',
  319. // ],
  320. ],
  321. ]) ?>
  322. </div>
  323. </div>
  324. </div>