view.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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($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' => function ($model){
  112. if($model->type == 1){
  113. return 'Підвищення';
  114. }
  115. if($model->type == 2){
  116. return 'Голландський';
  117. }
  118. if($model->type == 3){
  119. return 'Банкрутство';
  120. }
  121. },
  122. 'format' => 'raw',
  123. ],
  124. [
  125. 'label' => 'Дата закінчення',
  126. 'value' => $serialize_data->date_stop,
  127. 'format' => 'raw',
  128. ],
  129. [
  130. 'label' => 'Час продовження, хв',
  131. 'value' => explode(":",$serialize_data->time_cont)[1]." хв",
  132. 'format' => 'raw',
  133. ],
  134. ],
  135. ]); ?>
  136. <?php if($serialize_data->type == 2): ?>
  137. <?= DetailView::widget([
  138. 'options' => [
  139. 'class' => 'table table-striped table-bordered detail-view'
  140. ],
  141. 'model' => $serialize_data,
  142. 'attributes' =>
  143. [
  144. [
  145. 'label' => 'Крок',
  146. 'value' => $serialize_data->step_change,
  147. 'format' => 'raw',
  148. ],
  149. [
  150. 'label' => 'Час',
  151. 'value' => $timeStepFormat,
  152. 'format' => 'raw',
  153. ],
  154. ],
  155. ]); ?>
  156. <?php endif; ?>
  157. <div class="row">
  158. <?php if(Yii::$app->user->can('admin')): ?>
  159. <div class="col-sm-6">
  160. <?= $status; ?>
  161. </div>
  162. <div class="col-sm-6">
  163. <?= Html::submitButton(Yii::t('app', 'Підтвердити / Створити'), ['class' => 'btn btn-success']); ?>
  164. </div>
  165. <?php endif;?>
  166. </div>
  167. <?php ActiveForm::end(); ?>
  168. <br>
  169. </div>
  170. <hr>
  171. </div>
  172. <?php
  173. } else {
  174. $files = new Files();
  175. if(false != ($file = Files::findOne([
  176. 'user_id' => Yii::$app->user->id,
  177. 'type' => 'bid',
  178. 'lot_id' => $model->id,
  179. ]))) {
  180. $bidding = new \app\models\Bidding();
  181. $form = ActiveForm::begin([
  182. 'action' => Url::to(['/auctions/bid', 'id' => $model->auction->id]),
  183. ]); ?>
  184. <?= $form->field($bidding, 'special_price'); ?>
  185. <div class="form-group">
  186. <?= Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-success']); ?>
  187. <?= Html::a(Yii::t('app', 'Download file'), ["/files/download", 'id' => $file->id], ['class' => 'btn btn-warning']); ?>
  188. </div>
  189. <?php
  190. ActiveForm::end();
  191. } else {
  192. $form = ActiveForm::begin([
  193. 'options' => ['enctype' => 'multipart/form-data'] // important
  194. ]);
  195. echo $form->field($files, 'file')->widget(FileInput::classname(), [
  196. 'options' => ['multiple' => true],
  197. 'pluginOptions' => [
  198. 'initialCaption' => 'файл типу: doc, docx, pdf, jpg, png, zip, rar (розмiр не бiльше 40Мб)',
  199. 'showPreview' => true,
  200. 'overwriteInitial' => false,
  201. 'pluginLoading' => true,
  202. 'initialPreviewAsData' => true,
  203. 'uploadClass' => 'btn btn-danger',
  204. 'removeIcon' => '<i class="glyphicon glyphicon-trash"></i>',
  205. ],
  206. ])->label(Yii::t('app', 'DownloadMemeberDoc ID'));
  207. ActiveForm::end();
  208. }
  209. }
  210. ?>
  211. <?= DetailView::widget([
  212. 'model' => $model,
  213. 'attributes' =>
  214. [
  215. // [
  216. // 'label' => Yii::t('app', 'Circle ID'),
  217. // 'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
  218. // 'format' => 'raw',
  219. // ],
  220. 'aukname',
  221. 'name',
  222. 'categoryName',
  223. 'description',
  224. 'auction_date',
  225. 'bidding_date',
  226. [
  227. 'attribute' => 'start_price',
  228. 'value' => $price_nds,
  229. ],
  230. [
  231. 'attribute' => 'count',
  232. 'value' => $model->count,
  233. 'visible' => $model->count,
  234. ],
  235. [
  236. 'attribute' => 'price_per_one',
  237. 'value' => $model->unitId ? ($model->start_price / $model->count) : '',
  238. 'visible' => $model->unitId ? true : false,
  239. ],
  240. [
  241. 'attribute' => 'unitName',
  242. 'value' => $model->unit ? $model->unit->name : '',
  243. 'visible' => $model->unitId ? true : false,
  244. ],
  245. 'step',
  246. [
  247. 'attribute' => 'docs_id',
  248. 'value' => $docs,
  249. 'format' => 'raw',
  250. ],
  251. 'address',
  252. 'member_require',
  253. 'payment_term',
  254. 'notes',
  255. [
  256. 'attribute' => 'dogovor_id',
  257. 'value' => $dogovor,
  258. 'format' => 'raw',
  259. ],
  260. [
  261. 'attribute' => Yii::t('app', 'Registration fee'),
  262. 'value' => $registration_fee .
  263. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  264. [
  265. '/bills/download-requisites',
  266. 'id' => $model->billPayRegistration,
  267. ],
  268. [
  269. 'target' => '_blank',
  270. 'title' => Yii::t('app', 'Download bill')
  271. ]
  272. ),
  273. 'format' => 'raw',
  274. ],
  275. [
  276. 'attribute' => Yii::t('app', 'Guaranteed payment'),
  277. 'value' => $guarantee_fee .
  278. Html::a('<i class="glyphicon glyphicon-circle-arrow-down"></i>',
  279. [
  280. '/bills/download-requisites',
  281. 'id' => $model->billPayGuarantee,
  282. ],
  283. [
  284. 'target' => '_blank',
  285. 'title' => Yii::t('app', 'Download bill')
  286. ]
  287. ),
  288. 'format' => 'raw',
  289. ],
  290. ],
  291. ]) ?>
  292. </div>
  293. </div>
  294. </div>