ks před 2 týdny
rodič
revize
de7570389a

+ 0 - 1
.gitignore

@@ -5,7 +5,6 @@ archive
 web/node_modules
 web/uploadfolder
 stats/
-config/db.php
 .env
 composer.lock
 config/db.php

+ 4 - 2
config/web.php

@@ -120,13 +120,15 @@ $config = [
                     'except' => ['delete']
                 ],// for rest api
                 'public/view/<id>' => 'public/view',
-//                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
+               '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                 '<alias:register>' => 'user/registration/<alias>',
                 '<alias:logout|login>' => 'user/security/<alias>',
                 '/news/<name:[\w]+>' => '/site/view',
                 '/product/<slug:[\w-]+>' => '/products/view',
                 '/dopomoga/category/<slug:[\w-]+>' => '/dopomoga/category',
-                '/category/<slug:[\w-]+>' => '/categoriesblog/category',
+                //'/category/<slug:[\w-]+>' => '/categoriesblog/category',
+                //'/blog/<slug:[\w-]+>' => '/categoriesblog/category',
+                // '/page/<slug:[\w-]+>' => '/categoriesblog/page',
             ]
         ],
         'assetManager'  =>  [

+ 8 - 7
controllers/BillsController.php

@@ -26,6 +26,7 @@ class BillsController extends Controller
                 'class' => VerbFilter::className(),
                 'actions' => [
                     'delete' => ['POST'],
+                    'payed' => ['GET'],
                 ],
             ],
             'access' => [
@@ -170,9 +171,9 @@ class BillsController extends Controller
         $percent_g = 0.015;
         $percent_r = 0.0015;
         $amount_vat = $amount = $type == 'guarantee'
-            ? $percent_g*$model->auction->lot->start_price
-            : $percent_r*$model->auction->lot->start_price;
-        if ($model->auction->lot->nds) {
+            ? $percent_g*($model->auction->lot->start_price ?? 0)
+            : $percent_r*($model->auction->lot->start_price ?? 0);
+        if ($model->auction->lot->nds ?? 0) {
             $amount = $amount/1.2*1;
         } else {
             $amount_vat *= 1.2;
@@ -181,13 +182,13 @@ class BillsController extends Controller
         $filename = templater()->process(
             [
                 'billID' => $model->id,
-                'auctionID' => $model->auction->id,
+                'auctionID' => $model->auction->id ?? 0,
                 'date' => date('d-m-Y'),
                 'inn' => $model->profile->inn,
                 'zkpo' => $model->profile->zkpo,
                 'uAddress' => $model->profile->u_address,
-                'bank' => $model->requisite->bank,
-                'payAccount' => $model->requisite->account,
+                'bank' => $model->requisite->bank ?? 0,
+                'payAccount' => $model->requisite->account ?? 0,
                 'phone' => $model->profile->phone,
                 'fax' => $model->profile->fax,
                 'firmaFull' => $model->profile->firma_full,
@@ -195,7 +196,7 @@ class BillsController extends Controller
                 'amountString' => num2str($amount_vat),
                 'amountVat' => $amount_vat,
                 'amount' => $amount,
-                'vat' => $model->auction->lot->nds ? 'з ПДВ' : 'без ПДВ',
+                'vat' => ($model->auction->lot->nds ?? 0) ? 'з ПДВ' : 'без ПДВ',
             ],
             $type
         );

+ 15 - 15
controllers/CategoriesblogController.php

@@ -29,21 +29,21 @@ class CategoriesblogController extends Controller
                     'delete' => ['POST'],
                 ],
             ],
-            'access' =>[
-                'class' => AccessControl::className(),
-                'rules' => [
-                    [
-                        'allow' => true,
-                        'actions' => ['create', 'update', 'delete', 'index', 'category', 'view', 'blog'],
-                        'roles' => ['@'],
-                    ],
-                    [
-                        'allow' => true,
-                        'actions' => ['index', 'category', 'view', 'blog'],
-                        'roles' => ['?'],
-                    ],
-                ],
-            ],
+            // 'access' =>[
+            //     'class' => AccessControl::className(),
+            //     'rules' => [
+            //         [
+            //             'allow' => true,
+            //             'actions' => ['create', 'update', 'delete', 'index', 'category', 'view', 'blog'],
+            //             'roles' => ['@'],
+            //         ],
+            //         // [
+            //         //     'allow' => true,
+            //         //     'actions' => ['index', 'category', 'view', 'blog'],
+            //         //     'roles' => ['?'],
+            //         // ],
+            //     ],
+            // ],
         ];
     }
 

+ 1 - 0
controllers/CategoryController.php

@@ -33,6 +33,7 @@ class CategoryController extends Controller
 
     public function init()
     {
+        parent::init();
 
         if(Yii::$app->user->isGuest)
         {

+ 1 - 0
controllers/EventlogController.php

@@ -33,6 +33,7 @@ class EventlogController extends Controller
      */
     public function init()
     {
+        parent::init();
 
         if(Yii::$app->user->isGuest)
         {

+ 8 - 3
controllers/FilesController.php

@@ -20,7 +20,7 @@ class FilesController extends \yii\web\Controller
             'verbs' => [
                 'class' => VerbFilter::className(),
                 'actions' => [
-                    'delete' => ['POST'],
+                    'delete' => ['POST', 'GET'],
                 ],
             ],
         ];
@@ -29,6 +29,7 @@ class FilesController extends \yii\web\Controller
 
     public function init()
     {
+        parent::init();
         //if(Yii::$app->user->isGuest)
         //{
         //    return $this->redirect('/user/login');
@@ -164,9 +165,13 @@ class FilesController extends \yii\web\Controller
      */
     public function actionDelete($id)
     {
-        $this->findModel($id)->delete();
+        $model = Files::findOne($id);
 
-        return $this->redirect(['index']);
+        if ($model) {
+            $model->delete();
+        }
+
+        return $this->redirect(Yii::$app->request->referrer);
     }
 
     /**

+ 2 - 2
controllers/LotsController.php

@@ -180,7 +180,7 @@ class LotsController extends Controller
         $files = new Files();
         $files->uploads = '../uploads/lots/';
 
-        // UploadedFile::getInstances($files, 'file');
+        // UploadedFile::getInstances($files, 'file'); 
         $fileName = $files->uploadFile();
 
         if ($model->status == 2) {
@@ -193,7 +193,7 @@ class LotsController extends Controller
 
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
 
-            if ($fileName) ;
+            if ($fileName)
             {
                 $model->docs_id = $files->saveFile([
                     'name' => $fileName,

+ 4 - 4
views/bills/index.php

@@ -17,7 +17,7 @@ $this->registerJs(<<<JS
 $('.payed-radio  input[type="radio"]').on('change', function(e){
     var radio = $(this);
     $.get(
-        radio.parents('.payed-radio').data('url') + '&payed=' + radio.val());
+        radio.parents('.payed-radio').data('url') + '?payed=' + radio.val());
 });
 JS
 );
@@ -53,10 +53,10 @@ JS
                 [
                     'attribute' => 'auction_id',
                     'value' => function ($model) {
-                        return Html::a($model->auction->id,
+                        return Html::a($model->auction->id ?? 0,
                             [
                                 '/publishing/view',
-                                'id' => $model->auction->id,
+                                'id' => $model->auction->id ?? 0,
                             ],
                             ['target' => '_blank']
                         );
@@ -78,7 +78,7 @@ JS
                         if (!Yii::$app->user->can('admin')) {
                             return getValue(Bills::payStatuses(), $model->payed);
                         } else {
-                            return Html::radioList('payed' . $model->id,
+                            return Html::radioList('payed' . $model->id . '-' . $model->payed,
                                 [$model->payed],
                                 Bills::payStatuses(),
                                 [

+ 1 - 1
views/files/index.php

@@ -45,7 +45,7 @@ $this->params['breadcrumbs'][] = $this->title;
                 'value'=> function(Files $e)
                 {
 
-                    return $e->user->username;
+                    return $e->user->username ?? "";
                 }
 
             ],

+ 1 - 1
views/files/view.php

@@ -42,7 +42,7 @@ use yii\widgets\Breadcrumbs;
                 'attribute' => 'user_id',
                 'value'=> function(Files $e)
                 {
-                    return $e->user->username .' | '. $e->user->email;
+                    return $e->user->username ?? "";
                 }
             ],
             //'user_id',

+ 51 - 0
views/lots/_admin.php

@@ -5,6 +5,13 @@ use yii\widgets\ActiveForm;
 use yii\helpers\ArrayHelper;
 use kartik\file\FileInput;
 use kartik\datetime\DateTimePicker;
+use yii\widgets\DetailView;
+use yii\grid\GridView;
+
+use yii\helpers\Url;
+
+use yii\data\ActiveDataProvider;
+use app\models\Files;
 
 /* @var $this yii\web\View */
 /* @var $model app\models\Lots */
@@ -68,6 +75,50 @@ use kartik\datetime\DateTimePicker;
 
     ])->label(Yii::t('app','DopDocumentation ID')); ?>
 
+    <?php 
+        print_r($model->file);
+    ?>
+
+    <?= GridView::widget([
+        'dataProvider' => new ActiveDataProvider([
+            'query' => Files::find()->where(['lot_id' => $model->id]),
+        ]),
+        'columns' => [
+
+            'name',
+            
+
+            [
+                'class' => 'yii\grid\ActionColumn',
+                'template' => '{download} {delete}',
+                'buttons' => [
+
+                    'download' => function ($url, $model) {
+                        return Html::a(
+                            'Скачать',
+                            Url::to(['files/download', 'id' => $model->id]),
+                            ['class' => 'btn btn-success btn-sm']
+                        );
+                    },
+
+                    'delete' => function ($url, $model) {
+                        return Html::a(
+                            'Удалить',
+                            ['files/delete', 'id' => $model->id],
+                            [
+                                'class' => 'btn btn-danger btn-sm',
+                                'data-confirm' => 'Удалить файл?',
+                                'data-method' => 'get',
+                            ]
+                        );
+                    },
+
+                ],
+            ],
+
+        ],
+    ]); ?>
+
     <?= $form->field($model, 'payment_term')->textInput(['maxlength' => true]) ?>
 
     <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>

+ 3 - 1
views/publishing/_forms/_auctions.php

@@ -67,10 +67,12 @@ $profile = \app\models\Profile::findOne(['user_id' => 23]);
                         <div class="publications-left">
                             <p class="subtitle-secondary mb-2">Період прийому заявок</p>
                             <p class="publications-left-time"><?php
+                                $disabled = 'disabled';
                                 $diff = strtotime ($model->date_start) - time();
                                 if($diff < 0){
                                     echo Yii::t('app', 'Закінчився');
                                 }else{
+                                    $disabled = '';
                                     echo intval($diff/86400) . ' дн. ' . intval(($diff%86400)/3600) . ' год. ' . intval((($diff%86400)%3600)/60) . ' хв.';
                                 }
 
@@ -83,7 +85,7 @@ $profile = \app\models\Profile::findOne(['user_id' => 23]);
                             <p class="publications-starting-price-value"><?= $model->lot->start_price . ' грн.'?></p>
                         </div>
                         <?= Html::a(Yii::t('app', 'Взяти участь'), ['/lots/view','id' => $model->lot->id],
-                            ['class' => 'btn btn-primary mt-3 btn-block'])?>
+                            ['class' => "btn btn-primary mt-3 btn-block $disabled"])?>
                         <?= Html::a(Yii::t('app', 'Детальніше'), ['/publishing/view','id' => $model->id],
                             ['class' => 'btn link-secondary btn-block'])?>
                     </div>

+ 3 - 1
views/site/_forms/_auctions.php

@@ -53,10 +53,12 @@ use yii\widgets\DetailView;
                         <div class="publications-left">
                             <p class="subtitle-secondary mb-2">Період прийому заявок</p>
                             <p class="publications-left-time"><?php
+                                $disabled = 'disabled';
                                 $diff = strtotime ($model->date_start) - time();
                                 if($diff < 0){
                                     echo Yii::t('app', 'Закінчився');
                                 }else{
+                                    $disabled = '';
                                     echo intval($diff/86400) . ' дн. ' . intval(($diff%86400)/3600) . ' год. ' . intval((($diff%86400)%3600)/60) . ' хв.';
                                 }
 
@@ -69,7 +71,7 @@ use yii\widgets\DetailView;
                             <p class="publications-starting-price-value"><?= $model->lot->start_price . ' грн.'?></p>
                         </div>
                         <?= Html::a(Yii::t('app', 'Взяти участь'), ['/lots/view','id' => $model->lot->id],
-                            ['class' => 'btn btn-primary mt-3 btn-block'])?>
+                            ['class' => "btn btn-primary mt-3 btn-block $disabled"])?>
                         <?= Html::a(Yii::t('app', 'Детальніше'), ['/publishing/view','id' => $model->id],
                             ['class' => 'btn link-secondary btn-block'])?>
                     </div>