Sergey Kazanskiy 5 dias atrás
pai
commit
5bd9408fb3

+ 2 - 2
controllers/BiddingController.php

@@ -229,9 +229,9 @@ class BiddingController extends Controller
 
         if(Yii::$app->user->can('member'))
         {
-            $bid_date = new DateTime($model->auction->bidding_date);
+            $bid_date = new DateTime(isset($model->auction->bidding_date) ? $model->auction->bidding_date : 0 );
             $now_date = new DateTime(date("Y-m-d H:i:s"));
-            var_dump($bid_date->diff($now_date));
+            // var_dump($bid_date->diff($now_date));
             if ($bid_date < $now_date) {
                 return $this->redirect(['view']);
             }

+ 8 - 9
controllers/BillsController.php

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

+ 0 - 1
controllers/CabinetController.php

@@ -26,7 +26,6 @@ class CabinetController extends \yii\web\Controller
     }
     public function init()
     {
-        parent::init();
         //Yii::$app->session->get('user.flags'); exit;
         if(Yii::$app->user->isGuest)
         {

+ 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' => ['?'],
+                    ],
+                ],
+            ],
         ];
     }
 

+ 0 - 1
controllers/CategoryController.php

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

+ 0 - 1
controllers/EventlogController.php

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

+ 3 - 8
controllers/FilesController.php

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

+ 87 - 28
controllers/LotsController.php

@@ -119,9 +119,11 @@ class LotsController extends Controller
         $files = new Files();
         $files->uploads = '../uploads/lots/';
         $fileName = $files->uploadFile();
+        // print_r(Yii::$app->request->post());
+
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             if ($fileName) {
-                $model->docs_id = $files->saveFile([
+                $docs_id = $files->saveFile([
                     'name' => $fileName,
                     'path' => $files->uploads,
                     'user_id' => Yii::$app->user->identity->id,
@@ -129,9 +131,31 @@ class LotsController extends Controller
                     'auction_id' => null,
                     'type' => 'lot',
                 ]);
+                $model->updateAttributes(['docs_id' => $docs_id]);
                 $model->save();
-                $model->upload();
+                $model->upload();                
+            }
+
+            $dogovor = UploadedFile::getInstance($files, 'project_dogovor');
+            if(isset($dogovor))
+            {
+                $dogovor->name = $files->transliteration($dogovor->name);
+                $path = Yii::$app->params['uploadPath'].$dogovor->name;
+                $dogovor->saveAs($path);
+                $dogovor_id = $files->saveFile([
+                    'name'=>$dogovor->name,
+                    'path'=>Yii::$app->params['uploadPath'],
+                    'user_id'=>Yii::$app->user->identity->id,
+                    'auction_id'=>'null',
+                    'lot_id'=>$model->id,
+                    'type'  =>  'NULL'
+                ]);
+                $model->updateAttributes(['dogovor_id' => $dogovor_id]);
             }
+            
+            $data = json_decode($model->serialize_data, true);
+            $model->updateAttributes(['serialize_data' => json_encode($data)]);
+            
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
@@ -152,7 +176,7 @@ class LotsController extends Controller
 
     public function actionCircle_down($id)
     {
-        if (Yii::$app->user->can('admin')) {
+        if (Yii::$app->user->can('admin') || Yii::$app->user->can('org')) {
             $model = $this->findModel($id);
             Yii::$app->db->createCommand("UPDATE lots SET step_down=step_down-1 WHERE id=:id")
                 ->bindValue(':id', $id)
@@ -163,7 +187,7 @@ class LotsController extends Controller
 
     public function actionCircle_up($id)
     {
-        if (Yii::$app->user->can('admin')) {
+        if (Yii::$app->user->can('admin') || Yii::$app->user->can('org')) {
 
             $model = $this->findModel($id);
             Yii::$app->db->createCommand("UPDATE lots SET step_down=step_down+1 WHERE id=:id")
@@ -179,8 +203,6 @@ class LotsController extends Controller
 
         $files = new Files();
         $files->uploads = '../uploads/lots/';
-
-        // UploadedFile::getInstances($files, 'file'); 
         $fileName = $files->uploadFile();
 
         if ($model->status == 2) {
@@ -192,10 +214,8 @@ class LotsController extends Controller
         }
 
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
-
-            if ($fileName)
-            {
-                $model->docs_id = $files->saveFile([
+            if ($fileName) {
+                $docs_id = $files->saveFile([
                     'name' => $fileName,
                     'path' => $files->uploads,
                     'user_id' => Yii::$app->user->identity->id,
@@ -203,9 +223,30 @@ class LotsController extends Controller
                     'auction_id' => null,
                     'type' => 'lot',
                 ]);
+                $model->updateAttributes(['docs_id' => $docs_id]);
                 $model->save();
-                $model->upload();
+                $model->upload();                
+            }
+
+            $dogovor = UploadedFile::getInstance($files, 'project_dogovor');
+            if(isset($dogovor))
+            {
+                $dogovor->name = $files->transliteration($dogovor->name);
+                $path = Yii::$app->params['uploadPath'].$dogovor->name;
+                $dogovor->saveAs($path);
+                $dogovor_id = $files->saveFile([
+                    'name'=>$dogovor->name,
+                    'path'=>Yii::$app->params['uploadPath'],
+                    'user_id'=>Yii::$app->user->identity->id,
+                    'auction_id'=>'null',
+                    'lot_id'=>$model->id,
+                    'type'  =>  'NULL'
+                ]);
+                $model->updateAttributes(['dogovor_id' => $dogovor_id]);
             }
+            
+            $data = json_decode($model->serialize_data, true);
+            $model->updateAttributes(['serialize_data' => json_encode($data)]);
 
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
@@ -259,17 +300,29 @@ class LotsController extends Controller
 
             if($model->status==2 && $model->lot_lock==0 || $model->status==4 && $model->lot_lock==0)
             {
-                if(Yii::$app->request->post('date_stop'))
-                {
-                    $date_stop = Yii::$app->request->post('date_stop');
-                    $time_cont = Yii::$app->request->post('time_cont');
-                }
-                else
-                {
-                    $date = strtotime($model->auction_date) + 7200;
-                    $date_stop = date("Y-m-d H:i:s", $date);
-                }
+                // if(Yii::$app->request->post('date_stop'))
+                // {
+                //     $date_stop = Yii::$app->request->post('date_stop');
+                //     $time_cont = Yii::$app->request->post('time_cont');
+                // }
+                // else
+                // {
+                //     $date = strtotime($model->auction_date) + 7200;
+                //     $date_stop = date("Y-m-d H:i:s", $date);
+                // }
+                
                 //$date = new \DateTime($model->auction_date);
+                
+                $setData = json_decode($model->serialize_data);
+
+                $parts = array_pad(explode(':', $setData->time_step_change), 3, 0);
+                $timeStepFormat = sprintf(
+                    "%02d:%02d:%02d.00000",
+                    (int)$parts[0],
+                    (int)$parts[1],
+                    (int)$parts[2]
+                );                
+                
                 // create auction
                 $insert = [
                     'user_id' => $model->user_id,
@@ -278,15 +331,19 @@ class LotsController extends Controller
                     'lot_num'   =>  $model->num,
                     'date_start'    =>  $model->auction_date,
                     'bidding_date'  =>  $model->bidding_date,
-                    'date_stop' =>  $date_stop,
-                    'type_id'   =>  $type,
-                    'time_step_down' => $model->time_step_down,
-                    'time_cont'=> $time_cont,
-                    'step_down'=> $model->step_down,
-                    'temp_step_down'=>$model->step_down,
+                    'date_stop' =>  $setData->date_stop,
+                    'type_id'   =>  $setData->type,
+                    'time_step_down' => $timeStepFormat,
+                    'time_cont'=> $setData->time_cont,
+                    'step_down'=> $setData->step_change,
+                    'temp_step_down'=>$setData->step_change,
                     //'date_stop' =>  $date->modify('+1 day')->format('Y-m-d H:i:s'),
                 ];
-                // print_r($insert);die();
+                // echo '<pre>';
+                // print_r(json_decode($model->serialize_data));
+                // print_r($insert);
+                // echo '</pre>';
+                // die();
 
                 $auction = Yii::createObject(Auctions::className())->CreateAuction($insert);
                 Subscriptions::createNewsletter($auction);
@@ -344,6 +401,8 @@ class LotsController extends Controller
     public function actionClone($id)
     {
         $model = $this->findModel($id);
+        // print_r($model->attributes);
+        // exit;
         $attributes = $model->attributes;
         $attributes['id'] = null;
         $attributes['status'] = 1;

+ 38 - 1
controllers/RegistrationController.php

@@ -7,6 +7,8 @@ use app\models\RegistrationForm;
 use yii\filters\AccessControl;
 use app\models\Messages;
 use dektrium\user\controllers\RegistrationController as BaseRegistrationController;
+use app\models\Files;
+use yii\web\UploadedFile;
 
 class RegistrationController extends BaseRegistrationController
 {
@@ -29,7 +31,9 @@ class RegistrationController extends BaseRegistrationController
 
         $this->performAjaxValidation($model);
 
-        if ($model->load(Yii::$app->request->post())) {
+        $files = new Files();        
+
+        if ( $model->load( Yii::$app->request->post() ) && false != ( $file = UploadedFile::getInstances( $files, 'file' ) ) ) {
             Yii::debug('Form data: ' . print_r(Yii::$app->request->post(), true), __METHOD__);
             if ($user = $model->register()) {
                 // Создаем директорию для пользователя
@@ -45,6 +49,39 @@ class RegistrationController extends BaseRegistrationController
                     Yii::error("Role '$role' not found", __METHOD__);
                 }
 
+                $files->uploads = '../uploads/' . $user->id . '/';
+                $files->user_id = $user->id;
+
+                $fileName = $files->uploadFile();
+                if ($fileName) {
+                    $files->saveFile([
+                        'name' => $fileName,
+                        'path' => $files->uploads,
+                        'user_id' => $user->id,
+                        'auction_id'=>'null',
+                        'lot_id'=>false,                        
+                        'type' => 'register',
+                    ]);
+                }
+
+                // $files = new Files();
+
+                // $file = UploadedFile::getInstance($files, 'file');
+                // if(isset($file)){
+                //     $file->name = $files->transliteration($file->name);
+                //     $path = Yii::$app->params['uploadPath'] . $file->name;
+                //     $file->saveAs($path);
+
+                //     $files->saveFile([
+                //         'name'=>$file->name,
+                //         'path'=>Yii::$app->params['uploadPath'],
+                //         'user_id'=>$user->id,
+                //         'auction_id'=>'null',
+                //         'lot_id'=>'NULL',
+                //         'type'  =>  'register'
+                //     ]);
+                // }                
+
                 // Создаем сообщение
                 Yii::createObject(Messages::class)->CreateMessage([
                     'user_id' => 23,

+ 0 - 1
controllers/UsersController.php

@@ -33,7 +33,6 @@ class UsersController extends Controller
     public function init()
     {
 
-    parent::init();
         if(Yii::$app->user->isGuest)
         {
             return $this->redirect('/user/login');

+ 6 - 1
models/Bidding.php

@@ -63,7 +63,8 @@ class Bidding extends ActiveRecord
             'org_id'    => $insert['org_id'],
             'file_id'    => $insert['file_id'],
             'created_at' =>  date("Y-m-d H:i:s"),
-            'special_price' => $insert['special_price']
+            'special_price' => $insert['special_price'],
+            'type' => 'guarantee'
         ]);
         return $model->save(false) && Bills::create($model);
     }
@@ -80,6 +81,10 @@ class Bidding extends ActiveRecord
         return $this->hasOne(User::className(), ['id' => 'user_id']);
     }
 
+    public function getBills(){
+        return $this->hasMany(Bills::className(), ['user_id' => 'user_id']);
+    }    
+
     public function getProfile(){
         return $this->hasOne(Profile::className(), ['user_id' => 'id'])->via('user');
     }

+ 3 - 3
models/Bills.php

@@ -35,8 +35,8 @@ class Bills extends \yii\db\ActiveRecord {
             'auction_id' => $bid->auction_id,
         ];
         (new Bills($data))->save(false);
-        $data['type'] = 'registration';
-        (new Bills($data))->save(false);
+        // $data['type'] = 'registration';
+        // (new Bills($data))->save(false);
         return true;
     }
 
@@ -59,7 +59,7 @@ class Bills extends \yii\db\ActiveRecord {
 
     public function rules() {
         return [
-            [['user_id', 'type', 'bid_id'], 'required'],
+            [['user_id', 'type'], 'required'],
             [['user_id','auction_id' ,'bid_id'], 'integer'],
             [['type'], 'in', 'range' => array_keys(static::types())],
             [['payed'], 'in', 'range' => array_keys(static::payStatuses())],

+ 6 - 2
models/BillsSearch.php

@@ -32,7 +32,7 @@ class BillsSearch extends Bills
             'query' => $query,
             'sort' => [
                 'defaultOrder' => [
-                    'payed' => SORT_ASC,
+                    'payed' => SORT_DESC,
                 ],
             ],
         ]);
@@ -40,7 +40,10 @@ class BillsSearch extends Bills
         if (!$this->validate()) {
             return $dataProvider;
         }
-        $query->joinWith(['user', 'auction']);
+        //$query->joinWith(['user', 'auction']);
+        if (!Yii::$app->user->identity->isAdmin) {
+            $query->andWhere(['bills.user_id' => Yii::$app->user->id]);
+        }        
         $query->andFilterWhere([
             'user_id' => $this->user_id,
             'bid_id' => $this->bid_id,
@@ -52,6 +55,7 @@ class BillsSearch extends Bills
             'bidding.auction_id' => $this->auction_id,
         ]);
         $query->andFilterWhere(['like', 'user.at_org', $this->user_at_org]);
+        
         return $dataProvider;
     }
 }

+ 29 - 11
models/Files.php

@@ -24,9 +24,20 @@ class Files extends \yii\db\ActiveRecord
      * @inheritdoc
      */
     public $file;
+    public $project_dogovor;
     public $uploads = '../uploads/';
+    public $isUpdate;
 
-
+    const SCENARIO_CREATE = 'create';
+    const SCENARIO_UPDATE = 'update';
+    
+    public function scenarios()
+    {
+        return [
+            self::SCENARIO_CREATE => ['file', 'project_dogovor', 'path', 'name', 'user_id', 'lot_id'],
+            self::SCENARIO_UPDATE => ['file', 'project_dogovor', 'path', 'name', 'user_id', 'lot_id'],
+        ];
+    }
 
     public static function tableName()
     {
@@ -39,15 +50,20 @@ class Files extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['path','name','user_id'], 'required'],
-            ['file', 'required', 'message' => 'Необхiдно прикрiпити додаткову документацiю'],
-            [['path','name'], 'string', 'max' => 255],
-            [['date'],'date'],
-            [['user_id','auction_id','lot_id'], 'integer', 'max' => 255],
-            [['file'], 'file', 'maxFiles' => 0,
-                               'maxSize'=> 50*(1024*1024),
-                               'extensions' => ['doc','docx','pdf','png','jpg','tiff','zip','rar']],
-
+            [['path','name','user_id','lot_id'], 'safe'],
+    
+            // 🔥 CREATE → обязательно
+            [['file', 'project_dogovor'], 'required',
+                'on' => self::SCENARIO_CREATE,
+                'message' => 'Необхідно прикріпити файл'
+            ],
+    
+            // 🔥 валидация файлов ВСЕГДА
+            [['file', 'project_dogovor'], 'file',
+                'skipOnEmpty' => true,
+                'maxSize'=> 50*(1024*1024),
+                'extensions' => ['doc','docx','pdf','png','jpg','tiff','zip','rar']
+            ],
         ];
     }
 
@@ -149,7 +165,9 @@ class Files extends \yii\db\ActiveRecord
 
     public function fileName()
     {
-        return Yii::$app->user->identity->username.date('ymdhis'); //dir name
+        return isset(Yii::$app->user->identity->username) ? 
+            Yii::$app->user->identity->username.date('ymdhis') :
+            $this->user_id.date('ymdhis'); //dir name
     }
 
 

+ 42 - 23
models/Lots.php

@@ -31,6 +31,7 @@ use app\models\Auctions;
  * @property string $member_require
  * @property string $member_docs
  * @property integer $requisites_id
+ * @property integer $type_id
  * @property string $notes
  * @property integer $dogovor_id
  * @property string $date
@@ -64,15 +65,15 @@ class Lots extends ActiveRecord
     public function rules()
     {
         return [
-            [['aukname', 'user_id', 'name', 'description', 'start_price', 'step', 'category_id', 'member_docs', 'date'], 'required'],
-            [['user_id', 'category_id', 'status', 'lot_lock', 'docs_id', 'nds', 'num', 'unitId', 'count'], 'integer'],
+            [['aukname','user_id', 'name', 'description', 'start_price', 'step', 'category_id', 'member_docs', 'date'], 'required'],
+            [['type_id','dogovor_id','user_id', 'category_id', 'status', 'lot_lock', 'docs_id', 'nds', 'num', 'unitId', 'count'], 'integer'],
             [['start_price', 'step'], 'number'],
-            [['date', 'auction_date', 'bidding_date', 'address', 'step_down', 'time_step_down', 'notes', 'description'], 'safe'],
-            [['aukname', 'name', 'delivery_term', 'delivery_time', 'requires', 'member_docs', 'delivery_time', 'delivery_term', 'requires'], 'string', 'max' => 800],
+            [['serialize_data','type_id','dogovor_id','date', 'auction_date', 'bidding_date', 'address', 'step_down', 'time_step_down', 'notes', 'description'], 'safe'],
+            [['name', 'delivery_term', 'delivery_time', 'requires', 'member_docs', 'delivery_time', 'delivery_term', 'requires'], 'string', 'max' => 800],
             [['price_per_one'], 'number', 'integerOnly' => false],
             [['files'], 'image'],
             [['file'],'file'],
-            [['file'],'safe'],
+            [['file', 'files'],'safe'],
             //[['notes', 'description', 'safe'], 'string', 'max' => 15000]
         ];
     }
@@ -111,7 +112,7 @@ class Lots extends ActiveRecord
             'auction_date' => Yii::t('app', 'AuctionDate ID'),
             'status' => Yii::t('app', 'Status ID'),
             'lot_lock' => Yii::t('app', 'Status ID'),
-            'aukname' => Yii::t('app', 'AukName ID'),
+            'aukname' => Yii::t('app', 'Назва аукціону'),
             'categoryName' => Yii::t('app', 'Category ID'),
             'bidding_date' => Yii::t('app', 'BiddingDate ID'),
             'step_down' => Yii::t('app', 'Circle ID'),
@@ -123,24 +124,32 @@ class Lots extends ActiveRecord
 
     public function save($validate = true, $attr = NULL)
     {
-        if (empty($this->bidding_date)) {
-            $lot = Auclots::findOne(['name' => $this->aukname]);
-            //var_dump($lot); exit;
-            //$this->address = $lot->address;
-            $this->bidding_date = $lot->bidding_date;
-            $this->auction_date = $lot->auction_date;
-            $this->payment_term = $lot->payment_term;
-            $this->payment_order = $lot->payment_order;
-            $this->member_require = $lot->member_require;
-            $this->term_procedure = $lot->term_procedure;
-            $this->requisites_id = $lot->requisites_id;
-            $this->dogovor_id = $lot->dogovor_id;
-            $this->member_docs = "NULL";
-            //$this->docs_id =
-
-            //$this->time_step_down = $lot->time_step_down;
+        // echo $this->aukname;
+        // echo '<pre>';print_r($this);echo '</pre>';
+        
+        
+        // if (empty($this->bidding_date)) {
+        //     $lot = Auclots::findOne(['name' => $this->aukname]);
+        //     //var_dump($lot); exit;
+        //     //$this->address = $lot->address;
+        //     $this->bidding_date = $lot->bidding_date;
+        //     $this->auction_date = $lot->auction_date;
+        //     $this->payment_term = $lot->payment_term;
+        //     $this->payment_order = $lot->payment_order;
+        //     $this->member_require = $lot->member_require;
+        //     $this->term_procedure = $lot->term_procedure;
+        //     $this->requisites_id = $lot->requisites_id;
+        //     $this->dogovor_id = $lot->dogovor_id;            
+        //     $this->member_docs = "NULL";
+
+        //     //$this->docs_id =
+
+        //     //$this->time_step_down = $lot->time_step_down;
+        // }
+
+        //$this->serialize_data
+        $this->member_docs = "NULL";
 
-        }
         return parent::save($validate, $attr);
     }
 
@@ -149,6 +158,16 @@ class Lots extends ActiveRecord
         return $this->hasOne(Requisites::className(), ['id' => 'requisites_id']);
     }
 
+    public function getAllRequisites()
+    {
+        $requisites = Requisites::find() -> where(['user_id' => [Yii::$app->user->identity->id]])->all();
+
+        foreach($requisites as $requisite){
+            $requisite->title = $requisite->title . ' - ' . $requisite->account . ' / ' .  $requisite->bank;
+        }
+        return \yii\helpers\ArrayHelper::map($requisites, 'id', 'title');
+    }    
+
     public function getBillPayRegistration() {
         $sql = Yii::$app->db->createCommand("
         SELECT bills.id FROM bills 

+ 22 - 2
views/bidding/view.php

@@ -36,7 +36,7 @@ $this->params['breadcrumbs'][] = $this->title;
                             return false;
                         }
                     ],
-                    //'fileName',
+                    'fileName',
                     [
                         'header' => Yii::t('app', 'BiddingDate ID'),
                         'value' => function($model){
@@ -47,7 +47,27 @@ $this->params['breadcrumbs'][] = $this->title;
                         }
                     ],
                     [
-                        'header' => Yii::t('app', 'Status ID'),
+                        'header' => Yii::t('app', 'Рахунки'),
+                        'value' => function($model){
+                            $status = true;
+                            foreach($model->bills as $bill){                                
+                                if( $bill->payed == 0 || $bill->payed == 2 ){
+                                    $status = false;
+                                    break;
+                                }
+                            }
+                            if ($status)
+                            {
+                                return Html::a('Сплачено', ['view'], ['class' => 'label label-success']);
+                                ///return Html::a(Yii::t('app', 'WaitConfirm ID'), ['view'], ['class' => 'label label-warning']);
+                            } else {
+                                return Html::a('Не сплачено', ['/bills'], ['class' => 'label label-danger']);
+                            }
+                        },
+                        'format' => 'raw',
+                    ],                    
+                    [
+                        'header' => Yii::t('app', 'Заявка'),//'header' => Yii::t('app', 'Status ID'),
                         'value' => function($model){
                             if ($model['status']==0)
                             {

+ 30 - 7
views/bills/_form.php

@@ -3,6 +3,11 @@
 use yii\helpers\Html;
 use yii\widgets\ActiveForm;
 
+use yii\helpers\ArrayHelper;
+use app\models\User;
+use app\models\Auctions;
+use app\models\Bidding;
+
 /* @var $this yii\web\View */
 /* @var $model app\models\Bills */
 /* @var $form yii\widgets\ActiveForm */
@@ -12,13 +17,31 @@ use yii\widgets\ActiveForm;
 
     <?php $form = ActiveForm::begin(); ?>
 
-    <?= $form->field($model, 'id')->textInput() ?>
-
-    <?= $form->field($model, 'user_id')->textInput() ?>
-
-    <?= $form->field($model, 'type')->textInput(['maxlength' => true]) ?>
-
-    <?= $form->field($model, 'lot_id')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'user_id')->dropDownList(
+        ArrayHelper::map(User::find()->all(), 'id', 'username'),
+        ['prompt' => 'Выберите пользователя']
+    ) ?>
+
+    <?= $form->field($model, 'type')->dropDownList([
+        'guarantee' => 'Guarantee',
+        'registration' => 'Registration',
+    ], ['prompt' => 'Тип рахунку']) ?>
+
+    <?= $form->field($model, 'payed')->dropDownList([
+        '0' => 'Нові',
+        '1' => 'Сплачено',
+        '2' => 'Не сплачено',
+    ], ['prompt' => '']) ?>    
+
+    <?= $form->field($model, 'auction_id')->dropDownList(
+        ArrayHelper::map(Auctions::find()->all(), 'id', 'name'),
+        ['prompt' => 'Выберите аукцион']
+    ) ?>
+
+    <?= $form->field($model, 'bid_id')->dropDownList(
+        ArrayHelper::map(Bidding::find()->all(), 'id', 'id'),
+        ['prompt' => 'Выберите ставку']
+    ) ?>
 
     <div class="form-group">
         <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>

+ 0 - 2
views/bills/create.php

@@ -12,8 +12,6 @@ $this->params['breadcrumbs'][] = $this->title;
 ?>
 <div class="bills-create">
 
-    <h1><?= Html::encode($this->title) ?></h1>
-
     <?= $this->render('_form', [
         'model' => $model,
     ]) ?>

+ 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 ?? 0,
+                        return Html::a(isset($model->auction->id) ? $model->auction->id : 0,
                             [
                                 '/publishing/view',
-                                'id' => $model->auction->id ?? 0,
+                                'id' => isset($model->auction->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 . '-' . $model->payed,
+                            return Html::radioList('payed' . $model->id,
                                 [$model->payed],
                                 Bills::payStatuses(),
                                 [

+ 1 - 1
views/bills/view.php

@@ -26,7 +26,7 @@ $this->params['breadcrumbs'][] = $this->title;
         'model' => $model,
         'attributes' => [
             'auction_id',
-            'lot_id',
+            'bid_id',
             'type',
             'payed',
         ],

+ 1 - 1
views/files/index.php

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

+ 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 ?? "";
+                    return $e->user->username .' | '. $e->user->email;
                 }
             ],
             //'user_id',

+ 8 - 8
views/layouts/backend/left.php

@@ -42,10 +42,10 @@ if (Yii::$app->user->can('admin')) {
                             "label" => Yii::t('app', 'AukName ID'),
                             "url" => ["/auctions"],
                         ],
-                        [
-                            "label" => Yii::t('app', 'Template ID'),
-                            "url" => ["/auclots"],
-                        ],
+                        // [
+                        //     "label" => Yii::t('app', 'Template ID'),
+                        //     "url" => ["/auclots"],
+                        // ],
                         [
                             "label" => Yii::t('app', 'Lots ID'),
                             "url" => ["/lots"],
@@ -254,10 +254,10 @@ if (Yii::$app->user->can('org')) {
                             "label" => Yii::t('app', 'AukName ID'),
                             "url" => ["/auctions"],
                         ],
-                        [
-                            "label" => Yii::t('app', 'Template ID'),
-                            "url" => ["/auclots"],
-                        ],
+                        // [
+                        //     "label" => Yii::t('app', 'Template ID'),
+                        //     "url" => ["/auclots"],
+                        // ],
                         [
                             "label" => Yii::t('app', 'Lots ID'),
                             "url" => ["/lots"],

+ 390 - 93
views/lots/_admin.php

@@ -4,138 +4,433 @@ use yii\helpers\Html;
 use yii\widgets\ActiveForm;
 use yii\helpers\ArrayHelper;
 use kartik\file\FileInput;
+use app\models\Units;
+use app\models\Category;
+use yii\helpers\Url;
 use kartik\datetime\DateTimePicker;
+use app\widgets\ButtonGroupInput;
 use yii\widgets\DetailView;
-use yii\grid\GridView;
-
-use yii\helpers\Url;
-
-use yii\data\ActiveDataProvider;
-use app\models\Files;
+use yii\helpers\Json;
 
 /* @var $this yii\web\View */
 /* @var $model app\models\Lots */
 /* @var $model app\models\Category */
 /* @var $form yii\widgets\ActiveForm */
+
+$unserializeJson = Json::encode(json_decode($model->serialize_data, true)); 
+
+$this->registerJs(<<<JS
+    function recalculateSum(){
+        $('#count-input').val($('#count-input').val());
+        $('#lots-price_per_one').val($('#lots-price_per_one').val());
+        var value = $('#lots-price_per_one').val() * $('#count-input').val();
+        $('#lots-start_price').val(value || '');
+    }
+
+    $('input[name="price_type"]').on('change', function(e){
+        var type = $('input[name="price_type"]:checked').val();
+        $('.per_one input, .per_one select').prop('readonly', type === 'total' ? 'readonly': false);
+        $('#lots-start_price').prop('readonly', type === 'total' ? false : 'readonly');
+        $('.per_one input, .per_one select').val('');
+    });
+    $('#count-input, #lots-price_per_one').on('keyup', function(e){
+        recalculateSum();
+    });
+
+    $('input[name="type"]').on('change', function(e){        
+        $(".circle_down").hide();
+        if($(this).val() == '2'){
+            $(".circle_down").show();
+        }
+    });
+
+    var concat_val = '';
+    var value1 = value2 = value3 = 0;
+
+    $("#button-save2").on("click",function(e){
+        step = $("#input-save0").val();
+        val1 = $("#input-save1").val();
+        val2 = $("#input-save2").val();
+        val3 = $("#input-save3").val();
+        value1 = 0;
+        if(val1 > 0){
+            value1 = val1;
+        }
+        value2 = 0;
+        if(val2 > 0){
+            value2 = val2;
+        }
+        value3 = 0;
+        if(val3 > 0){
+            value3 = val3;
+        }     
+        concat_val = value1 + ":"+ value2 + ":" + value3;
+        // if(concat_val.length > 0){
+        //     alert(concat_val);
+        // }
+        $("#lead").html('кроки:'+step+', час:'+concat_val);
+    });    
+    
+    $(document).ready(function () {
+        var settings = {$unserializeJson};    
+        if (settings) {
+            $('input[name=\"time_cont\"][value=\"'+settings.time_cont+'\"]').prop('checked', true);
+            $('input[name=\"type\"][value=\"'+settings.type+'\"]').prop('checked', true).change();
+
+            $("#input-save0").val(settings.step_change);
+            $("#input-save1").val(settings.time_step_change.split(':')[0]);
+            $("#input-save2").val(settings.time_step_change.split(':')[1]);
+            $("#input-save3").val(settings.time_step_change.split(':')[2]);
+
+            $("#button-save2").click();
+        }        
+    });
+
+    //====
+
+    function serializeData() {
+        return {
+            time_cont: $('input[name="time_cont"]:checked').val(),
+            type: $('input[name="type"]:checked').val(),
+            step_change: step,
+            time_step_change: concat_val,
+            date_stop: $("#date_stop").val(),
+        };
+    }
+
+    $('form').on('submit', function () {
+        var data = serializeData();        
+        $('#serialize_data').val(JSON.stringify(data));
+    });
+JS
+);
+
+//=========================
+
+$time_change = Html::button(
+    Yii::t('app', 'Enter value'), 
+    [
+        'style' => 'font-weight: bold; text-transform: uppercase; color: black', 
+        'class' => 'btn btn-info btn-sm',
+        'data-toggle' => 'modal', 
+        'data-target' => '#myModal2'
+    ]
+);
 ?>
-<div class="lots-form">
 
-    <?php
+<!-- Modal -->
+<div class="modal fade" id="myModal2" role="dialog">
+    <div class="modal-dialog modal-sm">
+        <!-- Modal content-->
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+                <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
+            </div>
+            <div class="modal-body">
+                <div class="container-fluid">
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Кроки'); ?></label>
+                                <input type="number" class="form-control" placeholder="Кроки" min="0" max="100" value="3" id="input-save0">
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row">
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Години'); ?></label>
+                                <input type="number" class="form-control" placeholder="Години" min="0" max="23" value="0" id="input-save1">
+                            </div>
+                        </div>
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Хвилини'); ?></label>
+                                <input type="number" class="form-control" placeholder="Хвилини" min="0" max="59" value="10" id="input-save2">
+                            </div>
+                        </div>
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Секунди'); ?></label>
+                                <input type="number" class="form-control" placeholder="Секунди" min="0" max="59" value="0" id="input-save3">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save2', 'data-dismiss' => 'modal']) ?>
+                <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
+            </div>
+        </div>
+    </div>
+</div>
 
+<div class="lots-form">
+    <?php
+    $serialize_data = json_decode($model->serialize_data);
     $files = new \app\models\Files();
 
     $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]); ?>
 
-    <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id]) ?>
+    <?= $form->field($model, 'serialize_data')->hiddenInput(['id' => 'serialize_data'])->label(false) ?>
+    
+    <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id])->label(false) ?>
+    
+    <div class="auclots-form">
+        <div class="row">
+            <div class="col-sm-3">
+                <label for=""><?= Yii::t('app', 'Час продовження, хв'); ?></label>
+                <br>
+                <?= ButtonGroupInput::widget([
+                    'name' => 'time_cont',
+                    'items' => [
+                        '00:05' => Yii::t('app', '5 хвилин'), 
+                        '00:10' => Yii::t('app', '10 хвилин')
+                    ],
+                    'value' => isset($serialize_data->time_cont) ? $serialize_data->time_cont : '00:05',
+                ]); ?>
+            </div>
+            <div class="col-sm-5">
+                <label for="type"><?= Yii::t('app', 'Тип аукціону'); ?></label>
+                <br>
+                <?= ButtonGroupInput::widget([
+                    'name' => 'type',
+                    'items' => [
+                        '1' => Yii::t('app', 'Підвищення'),
+                        '2' => Yii::t('app', 'Голландський'),
+                        '3' => Yii::t('app', 'Банкрутство'),
+                    ],
+                    'value' => isset($serialize_data->type) ? $serialize_data->type : 1,
+                ]); ?>
+            </div>
+            <div class="col-sm-4">
+                <label for="date_stop"><?= Yii::t('app', 'Дата закінчення'); ?></label>                                
+                <br>
+                <?= DateTimePicker::widget([
+                    'layout' => '{picker}{input}',
+                    'value' => isset($serialize_data->date_stop) ? $serialize_data->date_stop : date('Y-m-d H:i', time() + 360),                    
+                    'name' => 'date_stop',
+                    'id' => 'date_stop',
+                    'options' => ['placeholder' => Yii::t('app', 'DateStop ID')],
+                    'pluginOptions' => [
+                        'autoclose' => true,
+                        'format' => 'yyyy-mm-dd hh:ii',
+                    ],
+                ]); ?>
+            </div>
+        </div>
+
+        <style>.circle_down{display:none;margin:0px}</style>
+        <?= DetailView::widget([
+            'options' => [
+                'class' => 'table table-striped table-bordered detail-view circle_down'
+            ],
+            'model' => $model,
+            'attributes' =>
+                [
+                    [
+                        'label' => Yii::t('app', 'Circle ID'),
+                        'value' => Html::tag('span', 'кроки 0, час 00:00:00', ['class' => 'lead','id'=>'lead']) . " " . $time_change,
+                        'format' => 'raw',
+                    ],
+                ],
+        ]); ?>        
+
+        <?= $form->field($model, 'aukname')->textInput(['maxlength' => true]) ?>
+
+        <?php $requisites = $model->allRequisites; ?>
+        <?php if (!$requisites) { ?>
+        <div class="alert alert-danger alert-dismissible fade in">
+            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+            <?= Yii::t('app', 'noRequisites ID')?>
+        </div>
+        <?php } ?>
+        
+        <div class="row">
+            <div class='col-md-8'>
+                <?= $form->field($model, 'requisites_id')->dropdownList($requisites) ?>
+            </div>
+            <div class='col-md-3' id="addReq">
+                <label>|</label>
+                <?= Html::button(Yii::t('app', 'Create Requisites'), ['value' => Url::to('/requisites/create-ajax'), 'class' => 'btn btn-success btn-block', 'id' => 'modalButton']) ;?>
+            </div>
+        </div>
+
+        <?= $form->field($files, 'project_dogovor')->widget(FileInput::classname(), [
+            'model' => $files,
+            'pluginOptions' => [
+                //'allowedFileExtensions'=>['doc','docx','pdf', 'png', ],
+                'initialCaption'=>'*.doc *.docx *.pdf *.png *.jpg *.tiff, *.zip *rar',
+                'showPreview' => false,
+                'showCaption' => true,
+                'showRemove' => true,
+                'showUpload' => false
+            ],
+            'options' => ['multiple' => false,],
+        ])->label(Yii::t('app','ProjectDogovor ID')); ?>
+
+        <?= $form->field($model, 'bidding_date')->widget(DateTimePicker::className(),[
+            'name' => 'bidding_date',
+            'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
+            'value' => date("dd-M-yyyy hh:ii"),
+            //'options' => ['placeholder' => Yii::t('app','')],
+            'pluginOptions' => [
+                'autoclose'=>true,
+                'format' => 'yyyy-mm-dd hh:ii'
+            ]
+        ]) ?>
+
+        <?= $form->field($model, 'auction_date')->widget(DateTimePicker::className(),[
+            'name' => 'auction_date',
+            'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
+            'value' => date("dd-M-yyyy hh:ii"),
+            'options' => ['placeholder' => Yii::t('app','CreateAukDate ID')],
+            'pluginOptions' => [
+                'autoclose'=>true,
+                'format' => 'yyyy-mm-dd hh:ii'
+            ]
+        ]) ?>
 
-    <?= $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()->all(), 'name', 'name')) ?>
+    </div>
 
-    <?= $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\app\models\Category::find()->all(), 'id', 'name')) ?>
+    <hr>
+
+    
+
+    <?php /*echo $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()
+        ->where(['user_id' => Yii::$app->user->identity->id])->orderBy('id DESC')->all(), 'name', 'name'))*/ ?>
+
+    <!--  ivakhnov  -->
+    <?= $form->field($model, 'num')->textInput(['maxlength' => 255])->label(Yii::t('app','AucNumber ID')) ?>
+
+    <?= $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name')) ?>
+
+    <?= $form->field($model, 'name')->textInput(['maxlength' => 255])->label(Yii::t('app','LotName ID')) ?>
+
+    <?= $form->field($model, 'description')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
+
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="row">
+                <div class="col-sm-3">
+                    <label class="price_type-input">
+                        <?= Yii::t('app', 'За одиницю'); ?>
+                        <?= Html::radio('price_type', true, ['value' => 'per_one']); ?>
+                    </label>
+                </div>
+                <div class="col-sm-9 per_one">
+                    <div class="row">
+                        <div class="col-sm-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Кількість'); ?></label>
+                                <?= Html::activeInput('number', $model, 'count', [
+                                    'class' => 'form-control',
+                                    'id' => 'count-input',
+                                    'min' => 1,
+                                    'max' => 99999999999999999999999,
+                                    'step' => 1,
+                                    'readonly' => 'readonly',
+                                ]); ?>
+                            </div>
+                        </div>
+                        <div class="col-sm-4">
+                            <?= $form->field($model, 'price_per_one', ['inputOptions' => ['readonly' => 'readonly', 'class' => 'form-control']])->label(Yii::t('app', 'Ціна за одиницю')); ?>
+                        </div>
+                        <div class="col-sm-4">
+                            <div class="form-group">
+                                <label><?= Yii::t('app', 'Одиниці виміру'); ?></label>
+                                <?= Html::activeDropDownList($model, 'unitId', ArrayHelper::merge(['' => Yii::t('app', 'Оберіть')], ArrayHelper::map(Units::find()->all(), 'id', 'name')), [
+                                    'class' => 'form-control',
+                                    'readonly' => 'readonly',
+                                ]); ?>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-sm-12">
+            <div class="row">
+                <div class="col-sm-3">
+                    <label class="price_type-input">
+                        <?= Yii::t('app', 'Загальна вартість'); ?>
+                        <?= Html::radio('price_type', true, ['value' => 'total']); ?>
+                    </label>
+                </div>
+                <div class="col-sm-9 total">
+                    <?= $form->field($model, 'start_price')->textInput()->label(Yii::t('app', 'Загальна віртість')) ?>
+                </div>
+
+                <div class="col-sm-12 total">
+                    <?= Html::tag('label', Yii::t('app', 'Download'), ['class' => 'control-label']);
+
+                    echo FileInput::widget([
+                        'model' => new \app\models\Lots,
+                        'attribute' => 'files[]',
+                        'options' => [
+                            'multiple' => true,
+                        ],
+                        'pluginOptions' => [
+                            'showPreview' => true,
+                            'showRemove' => true,
+                            'showUpload' => false,
+                            'showCaption' => true,
+                        ],
+                    ]);?>
+                </div>
+
+            </div>
+        </div>
+    </div>
 
-    <?= $form->field($model, 'name')->textInput(['maxlength' => true])->label(Yii::t('app','LotName ID')) ?>
 
-    <?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
-    <?= $form->field($model, 'bidding_date')->textInput()->widget(DateTimePicker::className(),[
-        'name' => 'auction_date',
-        'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
-        'value' => date("dd-M-yyyy hh:ii"),
-        'pluginOptions' => [
-            'autoclose'=>true,
-            'format' => 'yyyy-mm-dd hh:ii'
-        ]
-    ]) ?>
-
-    <?= $form->field($model, 'auction_date')->widget(DateTimePicker::className(),[
-        'name' => 'auction_date',
-        'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
-        'value' => date("dd-M-yyyy hh:ii"),
-        'options' => ['placeholder' => Yii::t('app','CreateAukDate ID')],
-        'pluginOptions' => [
-            'autoclose'=>true,
-            'format' => 'yyyy-mm-dd hh:ii'
-        ]
-    ]) ?>
-
-    <?= $form->field($model, 'start_price')->textInput() ?>
+    <?= $form->field($model, 'nds')->checkbox(['checked ' => true])  ?>
 
     <?= $form->field($model, 'step')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($files, 'file')->widget(FileInput::classname(), [
+
+
+    <?= $form->field($files, 'file[]')->widget(FileInput::classname(), [
         'model' => $files,
-        //'attribute' => 'file',
+
         'pluginOptions' => [
-            'allowedFileExtensions'=>['doc','docx','pdf', 'jpg', 'png', 'zip', 'rar'],
-            'initialCaption'=>'*.doc, *.docx, *.pdf, *.jpg, *.png, *zip, *rar',
-            'showPreview' => false,
+            //'allowedFileExtensions'=>['doc','docx','pdf'],
+            'initialCaption'=>'*.doc, *.docx, *.pdf *.png *.jpg *.tiff *.zip *.rar',
+            'showPreview' => true,
             'showCaption' => true,
             'showRemove' => true,
-            'showUpload' => false
+            'showUpload' => false,
+            'maxFileCount' => 10,
+        ],
+        'options' => [
+            'multiple' => true,
         ],
-        'options' => ['multiple' => true,],
-
     ])->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, 'member_require')->textarea(/*['maxlength' => 5000, 'rows' => 50, 'cols' => 100]*/) ?>    
 
-        ],
-    ]); ?>
+    <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'payment_term')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
 
-<!--    <?= $form->field($model, 'delivery_time')->textInput(['maxlength' => true]) ?>  --!>
+    <!--
 
-    <?= $form->field($model, 'delivery_term')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'delivery_time')->textInput(['maxlength' => true]) ?>
 
-    <?= $form->field($model, 'requires')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'delivery_term')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
 
-    <?= $form->field($model, 'member_docs')->textInput(['maxlength' => true]) ?>
+    <?= $form->field($model, 'requires')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?>
 
-    <?= $form->field($model, 'notes')->textarea(['maxlength' => true]) ?>
+    <?= $form->field($model, 'member_docs')->textarea(['maxlength' => 800, 'rows' => 6, 'cols' => 50]) ?> --!>
 
-    <?= $form->field($model, 'date')->hiddenInput(['value' => date('Y-m-d H:i:s')]) ?>
+    <?= $form->field($model, 'notes')->textarea(['maxlength' => 15000, 'rows' => 6, 'cols' => 50]) ?>
 
-<!--    <?= $form->field($model, 'status')->textInput() ?> --!>
+    <?= $form->field($model, 'date')->hiddenInput(['value' => date('Y-m-d H:i:s')])->label(false); ?>
 
     <div class="form-group">
         <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create ID') : Yii::t('app', 'Update ID'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
@@ -143,4 +438,6 @@ use app\models\Files;
 
     <?php ActiveForm::end(); ?>
 
+
+
 </div>

+ 267 - 4
views/lots/_form.php

@@ -6,12 +6,20 @@ use yii\helpers\ArrayHelper;
 use kartik\file\FileInput;
 use app\models\Units;
 use app\models\Category;
+use yii\helpers\Url;
+use kartik\datetime\DateTimePicker;
+use app\widgets\ButtonGroupInput;
+use yii\widgets\DetailView;
+use yii\helpers\Json;
 
 /* @var $this yii\web\View */
 /* @var $model app\models\Lots */
 /* @var $model app\models\Category */
 /* @var $form yii\widgets\ActiveForm */
 
+$t = isset($model->auction->type_id) ? $model->auction->type_id : 0;
+$unserializeJson = Json::encode(json_decode($model->serialize_data, true)); 
+
 $this->registerJs(<<<JS
     function recalculateSum(){
         $('#count-input').val($('#count-input').val());
@@ -29,20 +37,273 @@ $this->registerJs(<<<JS
     $('#count-input, #lots-price_per_one').on('keyup', function(e){
         recalculateSum();
     });
+
+    $('input[name="type"]').on('change', function(e){        
+        $(".circle_down").hide();
+        if($(this).val() == '2'){
+            $(".circle_down").show();
+        }
+    });
+
+    var concat_val = '';
+    var value1 = value2 = value3 = 0;
+
+    $("#button-save2").on("click",function(e){
+        step = $("#input-save0").val();
+        val1 = $("#input-save1").val();
+        val2 = $("#input-save2").val();
+        val3 = $("#input-save3").val();
+        value1 = 0;
+        if(val1 > 0){
+            value1 = val1;
+        }
+        value2 = 0;
+        if(val2 > 0){
+            value2 = val2;
+        }
+        value3 = 0;
+        if(val3 > 0){
+            value3 = val3;
+        }     
+        concat_val = value1 + ":"+ value2 + ":" + value3;
+        // if(concat_val.length > 0){
+        //     alert(concat_val);
+        // }
+        $("#lead").html('кроки:'+step+', час:'+concat_val);
+    });    
+    
+    $(document).ready(function () {
+        $("#button-save2").click();
+
+        var t = {$t};
+        if(t == '2'){
+            $(".circle_down").show();
+        }
+        //===
+        $("#lead").html('кроки:'+step+', час:'+concat_val);
+
+        var settings = {$unserializeJson};    
+        if (settings) {
+            $('input[name=\"time_cont\"][value=\"'+settings.time_cont+'\"]').prop('checked', true);
+            $('input[name=\"type\"][value=\"'+settings.type+'\"]').prop('checked', true);
+            //$("#lead").html('кроки:'+step+', час:'+concat_val);
+        }        
+    });
+
+    //====
+
+    function serializeData() {
+        return {
+            time_cont: $('input[name="time_cont"]:checked').val(),
+            type: $('input[name="type"]:checked').val(),
+            step_change: step,
+            time_step_change: concat_val,
+            date_stop: $("#date_stop").val(),
+        };
+    }
+
+    $('form').on('submit', function () {
+        var data = serializeData();        
+        $('#serialize_data').val(JSON.stringify(data));
+    });
 JS
 );
+
+//=========================
+
+$time_change = Html::button(
+    Yii::t('app', 'Enter value'), 
+    [
+        'style' => 'font-weight: bold; text-transform: uppercase; color: black', 
+        'class' => 'btn btn-info btn-sm',
+        'data-toggle' => 'modal', 
+        'data-target' => '#myModal2'
+    ]
+);
 ?>
-<div class="lots-form">
 
+<!-- Modal -->
+<div class="modal fade" id="myModal2" role="dialog">
+    <div class="modal-dialog modal-sm">
+        <!-- Modal content-->
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+                <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
+            </div>
+            <div class="modal-body">
+                <div class="container-fluid">
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Кроки'); ?></label>
+                                <input type="number" class="form-control" placeholder="Кроки" min="0" max="100" value="3" id="input-save0">
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row">
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Години'); ?></label>
+                                <input type="number" class="form-control" placeholder="Години" min="0" max="23" value="0" id="input-save1">
+                            </div>
+                        </div>
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Хвилини'); ?></label>
+                                <input type="number" class="form-control" placeholder="Хвилини" min="0" max="59" value="10" id="input-save2">
+                            </div>
+                        </div>
+                        <div class="col-xs-4">
+                            <div class="form-group">
+                                <label for=""><?= Yii::t('app', 'Секунди'); ?></label>
+                                <input type="number" class="form-control" placeholder="Секунди" min="0" max="59" value="0" id="input-save3">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save2', 'data-dismiss' => 'modal']) ?>
+                <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<div class="lots-form">
     <?php
     $files = new \app\models\Files();
 
     $form = ActiveForm::begin(['options'=>['enctype'=>'multipart/form-data']]); ?>
 
-    <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id]) ?>
+    <?= $form->field($model, 'serialize_data')->hiddenInput(['id' => 'serialize_data'])->label(false) ?>
+    
+    <?= $form->field($model, 'user_id')->hiddenInput(['value' => Yii::$app->user->identity->id])->label(false) ?>
+    
+    <div class="auclots-form">
+        <div class="row">
+            <div class="col-sm-3">
+                <label for=""><?= Yii::t('app', 'Час продовження, хв'); ?></label>
+                <br>
+                <?= ButtonGroupInput::widget([
+                    'name' => 'time_cont',
+                    'items' => [
+                        '00:05' => Yii::t('app', '5 хвилин'), 
+                        '00:10' => Yii::t('app', '10 хвилин')
+                    ],
+                    'value' => '00:05',
+                ]); ?>
+            </div>
+            <div class="col-sm-5">
+                <label for="type"><?= Yii::t('app', 'Тип аукціону'); ?></label>
+                <br>
+                <?= ButtonGroupInput::widget([
+                    'name' => 'type',
+                    'items' => [
+                        '1' => Yii::t('app', 'Підвищення'),
+                        '2' => Yii::t('app', 'Голландський'),
+                        '3' => Yii::t('app', 'Банкрутство'),
+                    ],
+                    'value' => 1,
+                ]); ?>
+            </div>
+            <div class="col-sm-4">
+                <label for="date_stop"><?= Yii::t('app', 'Дата закінчення'); ?></label>                                
+                <br>
+                <?= DateTimePicker::widget([
+                    'layout' => '{picker}{input}',
+                    'value' => isset($model->auction->date_stop) ? $model->auction->date_stop : date('Y-m-d H:i', time() + 360),
+                    'name' => 'date_stop',
+                    'id' => 'date_stop',
+                    'options' => ['placeholder' => Yii::t('app', 'DateStop ID')],
+                    'pluginOptions' => [
+                        'autoclose' => true,
+                        'format' => 'yyyy-mm-dd hh:ii',
+                    ],
+                ]); ?>
+            </div>
+        </div>
+
+        <style>.circle_down{display:none;margin:0px}</style>
+        <?= DetailView::widget([
+            'options' => [
+                'class' => 'table table-striped table-bordered detail-view circle_down'
+            ],
+            'model' => $model,
+            'attributes' =>
+                [
+                    [
+                        'label' => Yii::t('app', 'Circle ID'),
+                        'value' => Html::tag('span', 'кроки 0, час 00:00:00', ['class' => 'lead','id'=>'lead']) . " " . $time_change,
+                        'format' => 'raw',
+                    ],
+                ],
+        ]); ?>        
+
+        <?= $form->field($model, 'aukname')->textInput(['maxlength' => true]) ?>
+
+        <?php $requisites = $model->allRequisites; ?>
+        <?php if (!$requisites) { ?>
+        <div class="alert alert-danger alert-dismissible fade in">
+            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+            <?= Yii::t('app', 'noRequisites ID')?>
+        </div>
+        <?php } ?>
+        
+        <div class="row">
+            <div class='col-md-8'>
+                <?= $form->field($model, 'requisites_id')->dropdownList($requisites) ?>
+            </div>
+            <div class='col-md-3' id="addReq">
+                <label>|</label>
+                <?= Html::button(Yii::t('app', 'Create Requisites'), ['value' => Url::to('/requisites/create-ajax'), 'class' => 'btn btn-success btn-block', 'id' => 'modalButton']) ;?>
+            </div>
+        </div>
 
-    <?= $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()
-        ->where(['user_id' => Yii::$app->user->identity->id])->orderBy('id DESC')->all(), 'name', 'name')) ?>
+        <?= $form->field($files, 'project_dogovor')->widget(FileInput::classname(), [
+            'model' => $files,
+            'pluginOptions' => [
+                //'allowedFileExtensions'=>['doc','docx','pdf', 'png', ],
+                'initialCaption'=>'*.doc *.docx *.pdf *.png *.jpg *.tiff, *.zip *rar',
+                'showPreview' => false,
+                'showCaption' => true,
+                'showRemove' => true,
+                'showUpload' => false
+            ],
+            'options' => ['multiple' => false,],
+        ])->label(Yii::t('app','ProjectDogovor ID')); ?>
+
+        <?= $form->field($model, 'bidding_date')->widget(DateTimePicker::className(),[
+            'name' => 'bidding_date',
+            'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
+            'value' => date("dd-M-yyyy hh:ii"),
+            //'options' => ['placeholder' => Yii::t('app','')],
+            'pluginOptions' => [
+                'autoclose'=>true,
+                'format' => 'yyyy-mm-dd hh:ii'
+            ]
+        ]) ?>
+
+        <?= $form->field($model, 'auction_date')->widget(DateTimePicker::className(),[
+            'name' => 'auction_date',
+            'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
+            'value' => date("dd-M-yyyy hh:ii"),
+            'options' => ['placeholder' => Yii::t('app','CreateAukDate ID')],
+            'pluginOptions' => [
+                'autoclose'=>true,
+                'format' => 'yyyy-mm-dd hh:ii'
+            ]
+        ]) ?>
+
+    </div>
+
+    <hr>
+
+    
+
+    <?php /*echo $form->field($model, 'aukname')->dropDownList(ArrayHelper::map(\app\models\Auclots::find()
+        ->where(['user_id' => Yii::$app->user->identity->id])->orderBy('id DESC')->all(), 'name', 'name'))*/ ?>
 
     <!--  ivakhnov  -->
     <?= $form->field($model, 'num')->textInput(['maxlength' => 255])->label(Yii::t('app','AucNumber ID')) ?>
@@ -153,6 +414,8 @@ JS
 
     <?= $form->field($model, 'payment_term')->textInput(['maxlength' => true]) ?>
 
+    <?= $form->field($model, 'member_require')->textarea(/*['maxlength' => 5000, 'rows' => 50, 'cols' => 100]*/) ?>    
+
     <?= $form->field($model, 'term_procedure')->textInput(['maxlength' => true]) ?>
 
 

+ 3 - 2
views/lots/index.php

@@ -20,9 +20,10 @@ $this->params['breadcrumbs'][] = $this->title;
     <div class="panel-body">
 
             <ul class="nav nav-tabs">
-                <li role="presentation">
+                <!-- <li role="presentation">
                     <?= Html::a(\Yii::t('app', 'Template ID'), ['auclots/index'], ['class' => 'presentation active']) ?>
-                </li><li role="presentation"  class="active">
+                </li> -->
+                <li role="presentation"  class="active">
                     <?= Html::a(\Yii::t('app', 'Lots ID'), ['/lots/index'], ['class' => 'presentation active']) ?>
                 </li>
             </ul>

+ 110 - 246
views/lots/view.php

@@ -12,8 +12,11 @@ use app\widgets\ButtonGroupInput;
 /* @var $this yii\web\View */
 /* @var $model app\models\Lots */
 
+///$mid = isset($model->id) ? $model->id : 0;
+
 $url = Url::to(['confirm', 'id' => $model->id]);
 $this->registerJs(<<<JS
+
     $('input[name="status"]').on('change', function(e){
         var self = $(this);
         $.get('$url' + '&status=' + self.val(), function(data){
@@ -23,14 +26,13 @@ $this->registerJs(<<<JS
         });
     });
 
-   $('input[name="statusOrg"]').on('change', function(e){
-        var self = $(this);
-        $.get('$url' + '&status=' + self.val(), function(data){
-            if(data !== 1){
-                window.location.reload();
-            }
-        });
-    });
+// $("#lot-form").on("beforeSubmit", function(e){
+//     if($("input[name=\"status\"]:checked").val() != 2){
+//         alert("' . Yii::t('app', 'Необхідно узгодити лот') . '");
+//         return false;
+//     }
+// }); 
+  
 JS
 );
 
@@ -42,17 +44,7 @@ if(Yii::$app->user->can('member')) {
 }
 
 $this->params['breadcrumbs'][] = $this->title;
-if(Yii::$app->user->can('admin')) {
-    $time_change = Html::button(Yii::t('app', 'Time Value'), ['style' => 'font-weight: bold; text-transform: uppercase; color: black', 'class' => 'btn btn-info btn-sm',
-        'data-toggle' => 'modal', 'data-target' => '#myModal2']);
-    $circle_change = Html::button(Yii::t('app', 'Enter value'), ['style' => 'font-weight: bold; text-transform: uppercase; color: black', 'class' => 'btn btn-info btn-sm',
-        'data-toggle' => 'modal', 'data-target' => '#myModal']);
-} else {
-    $time_change = '';
-    $circle_change = '';
-}
-$circle_down = Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-minus']), ['circle_down', 'id' => $model->id], ['class' => 'btn btn-xs btn-primary']);
-$circle_up = Html::a(Html::tag('i', '', ['class' => 'glyphicon glyphicon-plus']), ['circle_up', 'id' => $model->id], ['class' => 'btn btn-xs btn-primary']);
+
 
 $status = ButtonGroupInput::widget([
     'name' => 'status',
@@ -65,15 +57,6 @@ $status = ButtonGroupInput::widget([
     'value' => $model->status
 ]);
 
-$statusOrg = ButtonGroupInput::widget([
-    'name' => 'status',
-    'items' => [
-        '3' => Yii::t('app', 'Відхилено'),
-        '4' => Yii::t('app','Узгоджено організатором'),
-
-    ],
-    'value' => $model->status
-]);
 
 if($model->docs_id) {
     $docs = Html::a(Yii::t('app', 'Download ID'), ['/files/download', 'id' => $model->docs_id], ['class' => 'glyphicon glyphicon-circle-arrow-down']);
@@ -91,174 +74,41 @@ if($model->nds == 1) {
 } else {
     $price_nds = $model->start_price . " " . Yii::t('app', 'bNDS ID');
 }
-$registration_fee = $model->start_price * 0.0015;
+$registration_fee = 120.00 . 'грн ' . Yii::t('app', 'zNDS ID');//$model->start_price * 0.0015;
 $guarantee_fee = $model->start_price * 0.015;
 
-//ivakhnov
-
-$js = '$("#button-save").on("click",function(e){
-    var value = $("#input-save").val();
-    var id = ' . $model->id . ';
-    if(value.length > 0){
-        $.post("' . Url::to(['/lots/step-change']) . '", 
-        {
-            value: value,
-            id: id
-        },);
-    }
-});
-
-
-$("#lot-form").on("beforeSubmit", function(e){
-    if($("input[name=\"status\"]:checked").val() != 2){
-        alert("' . Yii::t('app', 'Необхідно узгодити лот') . '");
-        return false;
-    }
-});
-
-
-$("input[name=\"type\"]").on("change", function(e){
-    var self = $(this),
-    form = $("#lot-form");
-    form.attr("action", "/lots/auction?" + self.val() +  "?id=' . $model->id . '");
-    form.attr("action", "/lots/auction?id=' . $model->id . '&type=" + self.val());
-});
+$serialize_data = json_decode($model->serialize_data);
 
-$("#button-save2").on("click",function(e){
-    var val1 = $("#input-save1").val();
-    var val2 = $("#input-save2").val();
-    var val3 = $("#input-save3").val();
-    
-    
-   var value1 = value2 = value3 = 0;
-   if(val1 > 0){
-    value1 = val1;
-   }
-   if(val2 > 0){
-    value2 = val2;
-   }
-   if(val3 > 0){
-    value3 = val3;
-   }
-     
-   var concat_val = value1 + ":"+ value2 + ":" + value3;
-    
-    
-    var id = ' . $model->id . ';
-       
-    if(concat_val.length > 0){
-        $.post("' . Url::to(['/lots/time-step-change']) . '", 
-        {
-            concat_val: concat_val,
-            id: id
-        },
-        function(data){
-            
-        }
-        );
-    }
-});
-
-$(document).ready(function () {
-    $(\'input[type=checkbox]\').change(function(){
-        $(this).parent().siblings().children().filter(\':checked\').not(this).removeAttr(\'checked\');
-    });
-});
-
-';
-
-
-
-
-$this->registerJs($js);
-
-
-
-//--------
+$parts = array_pad(explode(':', $serialize_data->time_step_change), 3, 0);
+$timeStepFormat = sprintf(
+    "%02d:%02d:%02d.00000",
+    (int)$parts[0],
+    (int)$parts[1],
+    (int)$parts[2]
+);
 
 ?>
 
 <!-- Modal by Ivakhnov -->
-<!-- Modal -->
-<div class="modal fade" id="myModal" role="dialog">
-    <div class="modal-dialog modal-sm">
-
-        <!-- Modal content-->
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal">&times;</button>
-                <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
-            </div>
-            <div class="modal-body">
-                <p><input type="number" class="form-control" value="<?= $model->step_down ?>" id="input-save"></p>
-            </div>
-            <div class="modal-footer">
-                <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save']) ?>
-                <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
-            </div>
-        </div>
-
-    </div>
-</div>
-
-<div class="modal fade" id="myModal2" role="dialog">
-    <div class="modal-dialog modal-sm">
-
-        <!-- Modal content-->
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal">&times;</button>
-                <h4 class="modal-title"><?= Yii::t('app', 'Circle ID') ?></h4>
-            </div>
-            <div class="modal-body">
-                <div class="container-fluid">
-                    <div class="row">
-                        <div class="col-xs-4">
-                            <div class="form-group">
-                                <label for=""><?= Yii::t('app', 'Години'); ?></label>
-                                <input type="number" class="form-control" placeholder="Години" value="0" id="input-save1">
-                            </div>
-                        </div>
-                        <div class="col-xs-4">
-                            <div class="form-group">
-                                <label for=""><?= Yii::t('app', 'Хвилини'); ?></label>
-                                <input type="number" class="form-control" placeholder="Хвилини" max="59" value="10" id="input-save2">
-                            </div>
-                        </div>
-                        <div class="col-xs-4">
-                            <div class="form-group">
-                                <label for=""><?= Yii::t('app', 'Секунди'); ?></label>
-                                <input type="number" class="form-control" placeholder="Секунди" max="59" value="0" id="input-save3">
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <?= Html::button(Yii::t('app', 'Save'), ['class' => 'btn btn-default', 'id' => 'button-save2']) ?>
-                <button type="button" class="btn btn-default" data-dismiss="modal"><?= Yii::t('app', 'Close') ?></button>
-            </div>
-        </div>
-
-    </div>
-</div>
 <div class="panel panel-primary">
-    <div class="panel-heading"><span class="glyphicon glyphicon-stats"></span><strong>
-            <?= Html::encode($this->title) ?></strong>
-        <?php if (Yii::$app->user->id == $model->user_id || Yii::$app->user->can('admin')): ?>
-        <?php if(Yii::$app->user->can('org') || Yii::$app->user->can('admin')): ?>
+    <div class="panel-heading">
+        <span class="glyphicon glyphicon-stats"></span>
+        <strong><?= Html::encode($this->title) ?></strong>
+        
+        <?php if(Yii::$app->user->id == $model->user_id || Yii::$app->user->can('admin')): ?>
+            <?= Html::a(Yii::t('app', 'Update ID'), ['update', 'id' => $model->id], [
+            'class' => 'btn btn-warning']); ?>
 
-            <?= Html::a(Yii::t('app', 'Update ID'), ['update', 'id' => $model->id], ['class' => 'btn btn-warning']); ?>
             <?= Html::a(Yii::t('app', 'Delete ID'), ['delete', 'id' => $model->id], [
-                'class' => 'btn btn-danger',
-                'data' => [
-                    'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
-                    'method' => 'post',
-                ]]); ?>
-
-        <?php endif; ?>
+            'class' => 'btn btn-danger',
+            'data' => [
+                'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
+                'method' => 'post',
+            ]]); ?>
         <?php endif; ?>
+
     </div>
+    
     <div class="panel-body">
         <div class="lots-view">
             <div class="container">
@@ -266,77 +116,89 @@ $this->registerJs($js);
                     <div class="col-sm-12">
                         <?= $this->render('_alert.php') ?>
                         <?php
-                        if(Yii::$app->user->can('admin'))
+                        if((Yii::$app->user->id == $model->user_id) || Yii::$app->user->can('admin'))
                         {
                         ActiveForm::begin([
                             'action' => ['/lots/auction', 'id' => $model->id, 'type' => 1],
                             'id' => 'lot-form',
                         ]); ?>
-                        <div class="row">
-                            <div class="col-sm-3">
-                                <label for=""><?= Yii::t('app', 'Час продовження, хв'); ?></label>
-                                <br>
-                                <?= ButtonGroupInput::widget([
-                                    'name' => 'time_cont',
-                                    'items' => ['00:05' => Yii::t('app', '5 хвилин'), '00:10' => Yii::t('app', '10 хвилин')],
-                                    'value' => '00:05',
-                                ]); ?>
-                            </div>
-                            <div class="col-sm-5">
-                                <label for="type"><?= Yii::t('app', 'Тип аукціону'); ?></label>
-                                <br>
-                                <?= ButtonGroupInput::widget([
-                                    'name' => 'type',
-                                    'items' => [
-                                        '1' => Yii::t('app', 'Підвищення'),
-                                        '2' => Yii::t('app', 'Голландський'),
-                                        '3' => Yii::t('app', 'Банкрутство'),
+
+                        <?= DetailView::widget([
+                            'options' => [
+                                'class' => 'table table-striped table-bordered detail-view'
+                            ],
+                            'model' => $serialize_data,
+                            
+                            'attributes' =>
+                                [
+                                    [
+                                        'label' => 'Тип аукціону',
+                                        'value' => function ($model){
+                                            if($model->type == 1){
+                                                return 'Підвищення';
+                                            }
+                                            if($model->type == 2){
+                                                return 'Голландський';
+                                            }
+                                            if($model->type == 3){
+                                                return 'Банкрутство';
+                                            }                                                                                        
+                                        },
+                                        'format' => 'raw',
                                     ],
-                                    'value' => '1',
-                                ]); ?>
-                            </div>
-                            <div class="col-sm-2">
-                                <label for="date_stop"><?= Yii::t('app', 'Дата закінчення'); ?></label>
-                                <br>
-                                <?= DateTimePicker::widget([
-                                    'layout' => '{picker}{input}',
-                                    'value' => date('Y-m-d H:i', time() + 360),
-                                    'name' => 'date_stop',
-                                    'options' => ['placeholder' => Yii::t('app', 'DateStop ID')],
-                                    'pluginOptions' => [
-                                        'autoclose' => true,
-                                        'format' => 'yyyy-mm-dd hh:ii',
+                                    [
+                                        'label' => 'Дата закінчення',
+                                        'value' => $serialize_data->date_stop,
+                                        'format' => 'raw',
+                                    ],
+                                    [
+                                        'label' => 'Час продовження, хв',
+                                        'value' => explode(":",$serialize_data->time_cont)[1]." хв",
+                                        'format' => 'raw',
+                                    ],
+                                ],
+                        ]); ?>
+
+                        <?php if($serialize_data->type == 2): ?>
+                        <?= DetailView::widget([
+                            'options' => [
+                                'class' => 'table table-striped table-bordered detail-view'
+                            ],
+                            'model' => $serialize_data,
+                            
+                            'attributes' =>
+                                [
+                                    [
+                                        'label' => 'Крок',
+                                        'value' => $serialize_data->step_change,
+                                        'format' => 'raw',
                                     ],
-                                ]); ?>
+                                    [
+                                        'label' => 'Час',
+                                        'value' => $timeStepFormat,
+                                        'format' => 'raw',
+                                    ],
+                                ],
+                        ]); ?>
+                        <?php endif; ?>
+                        
+                        <div class="row">
+                            <?php if(Yii::$app->user->can('admin')): ?>
+                            <div class="col-sm-6">
+                                <?= $status; ?>
                             </div>
-                            <div class="col-sm-2">
-                                <label for="">&nbsp;</label>
-                                <br>
-                                <?php if(Yii::$app->user->can('admin')): ?>
-                                <?= Html::submitButton(Yii::t('app', 'Створити'), ['class' => 'btn btn-success']); ?>
-                                <?php elseif(Yii::$app->user->can('org')): ?>
-                                    <?= Html::a('&larr;До Аукціонів', ['lots/index'], ['class' => 'btn btn-info']) ?>
-                                <?php endif;?>
+                            
+                            <div class="col-sm-6">
+                                <?= Html::submitButton(Yii::t('app', 'Підтвердити / Створити'), ['class' => 'btn btn-success']); ?>
                             </div>
+                            <?php endif;?>
                         </div>
                         <?php ActiveForm::end(); ?>
-                    </div>
-
-                    <div class="row">
-                        <div class="col-xs-12">
-                            <hr>
-                        </div>
-
-                        <div class="col-sm-2">
-                            <p class="lead"><?= Yii::t('app', 'Статус'); ?>:</p>
-                        </div>
-                        <div class="col-sm-4">
-                            <?= $status; ?>
-                        </div>
-
+                        <br>
                     </div>
 
                     <hr>
+
                 </div>
                 <?php
                 } else {
@@ -379,15 +241,17 @@ $this->registerJs($js);
                     }
                 }
                 ?>
+
+
                 <?= DetailView::widget([
                     'model' => $model,
                     'attributes' =>
                         [
-                            [
-                                'label' => Yii::t('app', 'Circle ID'),
-                                'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
-                                'format' => 'raw',
-                            ],
+                            // [
+                            //     'label' => Yii::t('app', 'Circle ID'),
+                            //     'value' => $circle_down . Html::tag('span', $model->step_down, ['class' => 'lead']) . $circle_up . $circle_change . $time_change . $model->time_step_down,
+                            //     'format' => 'raw',
+                            // ],
                             'aukname',
                             'name',
                             'categoryName',

+ 12 - 5
views/publishing/_forms/_auctions.php

@@ -8,7 +8,8 @@ use dosamigos\gallery\Gallery;
  * @var \app\models\Publishing $model
  * */
 
-$profile = \app\models\Profile::findOne(['user_id' => 23]);
+///$profile = \app\models\Profile::findOne(['user_id' => 23]);
+$profile = \app\models\Profile::findOne(['user_id' => $model->user->id]);
 
 ?>
 
@@ -67,12 +68,10 @@ $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) . ' хв.';
                                 }
 
@@ -84,8 +83,16 @@ $profile = \app\models\Profile::findOne(['user_id' => 23]);
                             <p class="subtitle-secondary mb-2">Початкова ціна</p>
                             <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 $disabled"])?>
+                        <?php
+                                $diff = strtotime ($model->date_start) - time();
+                                if($diff < 0){
+                                    echo Html::a(Yii::t('app', 'Взяти участь'), ['#'], ['class' => 'btn btn-primary mt-3 btn-block disabled']);
+                                }else{
+                                    echo Html::a(Yii::t('app', 'Взяти участь'), ['/lots/view','id' => $model->lot->id],
+                                    ['class' => 'btn btn-primary mt-3 btn-block']);
+                                }
+
+                        ?>                        
                         <?= Html::a(Yii::t('app', 'Детальніше'), ['/publishing/view','id' => $model->id],
                             ['class' => 'btn link-secondary btn-block'])?>
                     </div>

+ 17 - 0
views/registration/register.php

@@ -3,6 +3,7 @@
 use yii\helpers\Html;
 use yii\widgets\ActiveForm;
 use yii\captcha\Captcha;
+use kartik\file\FileInput;
 
 /**
  * @var yii\web\View $this
@@ -11,6 +12,8 @@ use yii\captcha\Captcha;
 
 $this->title = Yii::t('user', 'Sign up');
 $this->params['breadcrumbs'][] = $this->title;
+
+$files = new \app\models\Files();
 ?>
 
 <div class="col-md-6 col-md-offset-3">
@@ -56,6 +59,20 @@ $this->params['breadcrumbs'][] = $this->title;
 
                     <?= $form->field($model, 'member')->textInput()->label(Yii::t('app', 'MemberFrom ID')) ?>
 
+                    <?php echo $form->field($files, 'file')->widget(FileInput::classname(), [
+                        'model' => $files,
+                        'pluginOptions' => [
+                            //'allowedFileExtensions'=>['doc','docx','pdf', 'png', ],
+                            'initialCaption'=>'*.doc *.docx *.pdf *.png *.jpg *.tiff, *.zip *rar',
+                            'showPreview' => false,
+                            'showCaption' => true,
+                            'showRemove' => false,
+                            'showUpload' => false
+                        ],
+                        'options' => ['multiple' => true,],
+
+                    ])->label(Yii::t('app','Документи')); ?>                    
+
                     <!-- Поля пользователя -->
                     <?= $form->field($model, 'email') ?>
                     <?= $form->field($model, 'username') ?>

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

@@ -53,12 +53,10 @@ 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) . ' хв.';
                                 }
 
@@ -71,7 +69,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 $disabled"])?>
+                            ['class' => 'btn btn-primary mt-3 btn-block'])?>
                         <?= Html::a(Yii::t('app', 'Детальніше'), ['/publishing/view','id' => $model->id],
                             ['class' => 'btn link-secondary btn-block'])?>
                     </div>

+ 64 - 0
views/user/admin/_user.php

@@ -1,4 +1,13 @@
 <?php
+use yii\helpers\Html;
+use yii\grid\GridView;
+use app\models\Files;
+use app\models\FilesSearch;
+use kartik\daterange\DateRangePicker;
+use yii\helpers\ArrayHelper;
+use app\models\User;
+use app\models\FilesSearch as FS;
+use yii\data\ActiveDataProvider;
 
 /*
  * This file is part of the Dektrium project.
@@ -13,8 +22,63 @@
  * @var yii\widgets\ActiveForm 		$form
  * @var dektrium\user\models\User 	$user
  */
+
+ $searchModel = new FS();
+ //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+ $dataProvider = new ActiveDataProvider([
+    'query' => FS::find()->where(['user_id' => $user->id]),
+]);
 ?>
 
 <?= $form->field($user, 'email')->textInput(['maxlength' => 255]) ?>
 <?= $form->field($user, 'username')->textInput(['maxlength' => 255]) ?>
 <?= $form->field($user, 'password')->passwordInput() ?>
+
+<div class="files-index">
+
+    <?= GridView::widget([
+        'dataProvider' => $dataProvider,
+        'filterModel' => $searchModel,
+        'columns' => [
+            [
+                'attribute' =>'name',
+                'header' => Yii::t('app', 'FileName ID'),
+                'filter' => false,
+            ],
+            [
+                'attribute' => 'type',
+                'header' => Yii::t('app','Тип документу'),
+            ],
+            [
+                    'attribute' => 'date',
+                    'header' => Yii::t('app', 'Date'),
+                    // 'filter' => DateRangePicker::widget([
+                    //     'name'=>'date_range_2',
+                    //     'presetDropdown'=>true,
+                    //     'hideInput'=>true
+                    // ])
+            ],
+            [
+                'class' => 'yii\grid\ActionColumn',
+                'template' => '{maintenance} {delete}',
+                'buttons' => [
+                    'maintenance' => function ($url, $model, $key)
+                    {
+                        return Html::a('<span class="glyphicon glyphicon-download"></span>', ['/files/download', 'id' => $model->id], [
+                            'title' => 'download files',
+                            'data-pjax' => '0',
+
+                        ]);
+                    }
+
+                ]
+            ],
+
+            //'user_id',
+           // 'auction_id',
+            // 'lot_id',
+
+           // ['class' => 'yii\grid\ActionColumn'],
+        ],
+    ]); ?>
+</div>