view.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: NeiroN
  5. * Date: 19.11.2015
  6. * Time: 9:27
  7. */
  8. use yii\helpers\Html;
  9. use yii\grid\GridView;
  10. use yii\helpers\ArrayHelper;
  11. use app\models\Auctions;
  12. /* @var $this yii\web\View */
  13. /* @var $dataProvider yii\data\ActiveDataProvider */
  14. $this->title = Yii::t('app', 'Bidding ID');
  15. $this->params['breadcrumbs'][] = $this->title;
  16. ?>
  17. <div class="panel panel-primary">
  18. <div class="panel-heading"><span class="glyphicon glyphicon-list"></span><strong> <?= Html::encode($this->title) ?></strong></div>
  19. <div class="panel-body">
  20. <div class="bidding-index">
  21. <style>
  22. .action-button{
  23. display:flex;
  24. }
  25. .action-button .glyphicon{
  26. font-size: 15px !important;
  27. padding: 4px !important;
  28. border: 1px solid;
  29. margin: 1px;
  30. border-radius: 3px;
  31. }
  32. </style>
  33. <!-- <?= GridView::widget([
  34. 'dataProvider' => $dataProvider,
  35. 'columns' => [
  36. ['class' => 'yii\grid\SerialColumn'],
  37. 'auctionName',
  38. [
  39. 'header' => Yii::t('app','LotName ID'),
  40. 'value' => function($model)
  41. {
  42. if(ArrayHelper::getValue($model->auction,'lot_id')) {
  43. $lot = app\models\Lots::find()->where(['id' => $model->auction->lot_id])->one();
  44. return $lot->name;
  45. }
  46. return false;
  47. }
  48. ],
  49. 'fileName',
  50. [
  51. 'header' => Yii::t('app', 'BiddingDate ID'),
  52. 'value' => function($model){
  53. if(ArrayHelper::getValue($model->auction,'bidding_date')) {
  54. return $model->auction->bidding_date;
  55. }
  56. return false;
  57. }
  58. ],
  59. [
  60. 'header' => Yii::t('app', 'Рахунки'),
  61. 'value' => function($model){
  62. $status = true;
  63. foreach($model->bills as $bill){
  64. if( $bill->payed == 0 || $bill->payed == 2 ){
  65. $status = false;
  66. break;
  67. }
  68. }
  69. if ($status)
  70. {
  71. return Html::a('Сплачено', ['view'], ['class' => 'label label-success']);
  72. ///return Html::a(Yii::t('app', 'WaitConfirm ID'), ['view'], ['class' => 'label label-warning']);
  73. } else {
  74. return Html::a('Не сплачено', ['/bills'], ['class' => 'label label-danger']);
  75. }
  76. },
  77. 'format' => 'raw',
  78. ],
  79. [
  80. 'header' => Yii::t('app', 'Заявка'),//'header' => Yii::t('app', 'Status ID'),
  81. 'value' => function($model){
  82. if ($model['status']==0)
  83. {
  84. return Html::a(Yii::t('app', 'WaitConfirm ID'), ['view'], ['class' => 'label label-warning']);
  85. }
  86. if ($model['status']==1)
  87. {
  88. return Html::a(Yii::t('app', 'Success ID'), ['view'], ['class' => 'label label-success']);
  89. }
  90. if ($model['status']==2)
  91. {
  92. return Html::a(Yii::t('app', 'Rejected ID'), ['view'], ['class' => 'label label-danger']);
  93. }
  94. },
  95. 'format' => 'raw',
  96. ],
  97. [
  98. 'class' => 'yii\grid\ActionColumn',
  99. 'template' => '{enter} {download} {delete}',
  100. 'buttons' => [
  101. 'enter' => function ($url,$model,$key) {
  102. return Html::a('', '/auctions/view?id='.$model->auction_id,['title'=>Yii::t('app','GoAuction ID'),'class' => 'glyphicon glyphicon-log-in']);
  103. },
  104. 'download' => function ($url,$model,$key) {
  105. return Html::a('', '/files/download?id='.$model->file_id,['title'=>Yii::t('app','Download ID'),'class' => 'glyphicon glyphicon-circle-arrow-down']);
  106. }
  107. ],
  108. ],
  109. ],
  110. ]); ?> -->
  111. <?= GridView::widget([
  112. 'dataProvider' => $dataProvider,
  113. // 'filterModel' => $searchModel,
  114. 'columns' => [
  115. [
  116. 'header'=>'#id',
  117. 'attribute'=>'id',
  118. 'value'=>'id'
  119. ],
  120. [
  121. 'attribute' => 'user.at_org',
  122. 'header' => Yii::t('app', 'BidFrom ID'),
  123. ],
  124. [
  125. 'attribute'=>'status',
  126. //'header' => Yii::t('app', 'Status ID'),
  127. 'value' => function($model){
  128. $auction = $model->auction ? $model->auction->status : false;
  129. if($auction){
  130. $status_name = Auctions::statusNames()[$model->auction->status];
  131. if($model->auction->status == 1){
  132. return Html::a($status_name, ['#'], ['class' => 'label label-warning']);
  133. }
  134. if($model->auction->status == 2){
  135. return Html::a($status_name, ['#'], ['class' => 'label label-danger']);
  136. }
  137. if($model->auction->status == 3){
  138. return Html::a($status_name, ['#'], ['class' => 'label label-default']);
  139. }
  140. if($model->auction->status == 4){
  141. return Html::a($status_name, ['#'], ['class' => 'label label-primary']);
  142. }
  143. }
  144. if ($model->status==1)
  145. {
  146. //return Yii::t('app', 'Waiting ID');
  147. return Html::a(Yii::t('app', 'Waiting ID'), ['#'], ['class' => 'label label-warning']);
  148. }
  149. if ($model->status==2)
  150. {
  151. //return Yii::t('app', 'Success ID');
  152. return Html::a(Yii::t('app', 'Success ID'). ($model->auction ? ' | ' . (string)Auctions::statusNames()[$model->auction->status] : ''), ['#'], ['class' => 'label label-success']);
  153. }
  154. if ($model->status==3)
  155. {
  156. //return Yii::t('app', 'Rejected ID');
  157. return Html::a(Yii::t('app', 'Rejected ID'), ['#'], ['class' => 'label label-danger']);
  158. }
  159. if ($model->status==4)
  160. {
  161. //return Yii::t('app', 'Rejected ID');
  162. return Html::a(Yii::t('app', 'Agree by organizer'), ['#'], ['class' => 'label label-info']);
  163. }
  164. },
  165. 'format' => 'raw',
  166. ],
  167. [
  168. 'header'=>'Номер лоту',
  169. 'attribute'=>'lot.id',
  170. 'value'=>'lot.id'
  171. ],
  172. [
  173. 'header'=>'Номер аукціону',
  174. 'attribute'=>'auction.id',
  175. 'value'=>'auction.id'
  176. ],
  177. [
  178. 'attribute' => 'created_at',
  179. 'header' => Yii::t('app', 'Date ID'),
  180. //'attribute' => 'date_start',
  181. //'header' => Yii::t('app', 'AuctionDate ID'),
  182. ],
  183. [
  184. 'attribute' => 'auction.date_start',
  185. 'header' => Yii::t('app', 'AuctionDate ID'),
  186. ],
  187. 'special_price',
  188. [
  189. 'header' => Yii::t('app', 'Рахунки'),
  190. 'value' => function($model){
  191. $status = true;
  192. foreach($model->bills as $bill){
  193. if( $bill->payed == 0 || $bill->payed == 2 ){
  194. $status = false;
  195. break;
  196. }
  197. }
  198. if ($status)
  199. {
  200. return Html::a('Сплачено', ['view'], ['class' => 'label label-success']);
  201. ///return Html::a(Yii::t('app', 'WaitConfirm ID'), ['view'], ['class' => 'label label-warning']);
  202. } else {
  203. return Html::a('Не сплачено', ['/bills'], ['class' => 'label label-danger']);
  204. }
  205. },
  206. 'format' => 'raw',
  207. ],
  208. [
  209. 'header' => Yii::t('app', 'Status ID'),
  210. 'value' => function($model){
  211. if ($model['status']==0)
  212. {
  213. return Html::a(Yii::t('app', 'WaitConfirm ID'), ['#'], ['class' => 'label label-warning']);
  214. }
  215. if ($model['status']==1)
  216. {
  217. return Html::a(Yii::t('app', 'Success ID'), ['#'], ['class' => 'label label-success']);
  218. }
  219. if ($model['status']==2)
  220. {
  221. return Html::a(Yii::t('app', 'Rejected ID'), ['#'], ['class' => 'label label-danger']);
  222. }
  223. },
  224. 'format' => 'raw',
  225. ],
  226. [
  227. 'header' => Yii::t('app', 'Назва аукціону'),
  228. 'attribute' => 'lot.name',
  229. ],
  230. ['class' => 'yii\grid\ActionColumn',
  231. 'template' => '<div class="action-button">{auctions} {download} {enter}</div>',
  232. 'buttons' => [
  233. 'auctions' => function ($url, $model, $key) {
  234. if (!$model->auction) {
  235. return null;
  236. }
  237. if ($model->auction->status != 2) {
  238. // return null;
  239. }
  240. return Html::a(
  241. '<span class="glyphicon glyphicon-log-in"></span>',
  242. ['/auctions/view', 'id' => $model->auction->id],
  243. [
  244. 'title' => 'Перейти до торгів'
  245. ]
  246. );
  247. },
  248. 'enter' => function ($url,$model,$key) {
  249. return Html::a('', '/lots/view?id='.$model->lot->id,['title'=>Yii::t('app','Продивитись лот'),'class' => 'glyphicon glyphicon-th-list']);
  250. },
  251. 'download' => function ($url,$model,$key) {
  252. return Html::a('', '/files/download?id='.$model->file_id,['title'=>Yii::t('app','Download ID'),'class' => 'glyphicon glyphicon-circle-arrow-down']);
  253. }
  254. ],
  255. ],
  256. ],
  257. ]); ?>
  258. </div>
  259. </div>
  260. </div>