Ver código fonte

blitz-030326

mxuser 2 dias atrás
commit
41ac3bf1a0
100 arquivos alterados com 10760 adições e 0 exclusões
  1. 13 0
      .env-dist
  2. 11 0
      .gitignore
  3. 41 0
      assets/AppAsset.php
  4. 31 0
      assets/BackendAsset.php
  5. 43 0
      commands/MailerController.php
  6. 46 0
      components/DektriumMailer.php
  7. 161 0
      components/NumberToText.php
  8. 59 0
      components/Templater.php
  9. 76 0
      composer.json
  10. 69 0
      config/console.php
  11. 9 0
      config/params.php
  12. 215 0
      config/web.php
  13. 31 0
      controllers/AdminController.php
  14. 156 0
      controllers/AuclotsController.php
  15. 76 0
      controllers/AuctionController.php
  16. 366 0
      controllers/AuctionsController.php
  17. 277 0
      controllers/BiddingController.php
  18. 205 0
      controllers/BillsController.php
  19. 113 0
      controllers/BlogPostsController.php
  20. 41 0
      controllers/CabinetController.php
  21. 181 0
      controllers/CategoriesblogController.php
  22. 130 0
      controllers/CategoryController.php
  23. 126 0
      controllers/DocumentsToTheUserController.php
  24. 93 0
      controllers/DopomogaController.php
  25. 24 0
      controllers/DownloadsFilesController.php
  26. 150 0
      controllers/EventlogController.php
  27. 181 0
      controllers/FilesController.php
  28. 134 0
      controllers/HelpController.php
  29. 134 0
      controllers/HelpVideoController.php
  30. 124 0
      controllers/ImagesController.php
  31. 384 0
      controllers/LotsController.php
  32. 132 0
      controllers/MenuToTheUserController.php
  33. 98 0
      controllers/MessagesController.php
  34. 60 0
      controllers/NotificationController.php
  35. 134 0
      controllers/PagesController.php
  36. 125 0
      controllers/PostsController.php
  37. 65 0
      controllers/ProfileController.php
  38. 66 0
      controllers/PublishController.php
  39. 454 0
      controllers/PublishingController.php
  40. 80 0
      controllers/RegistrationController.php
  41. 150 0
      controllers/RequisitesController.php
  42. 165 0
      controllers/SettingsController.php
  43. 158 0
      controllers/SiteController.php
  44. 72 0
      controllers/StatisticsController.php
  45. 85 0
      controllers/SubscriptionsController.php
  46. 72 0
      controllers/TradeController.php
  47. 134 0
      controllers/UnitsController.php
  48. 80 0
      controllers/UpdateAction.php
  49. 135 0
      controllers/UsersController.php
  50. 61 0
      error/400.html
  51. 61 0
      error/401.html
  52. 61 0
      error/403.html
  53. 61 0
      error/404.html
  54. 61 0
      error/405.html
  55. 61 0
      error/500.html
  56. 61 0
      error/502.html
  57. 61 0
      error/503.html
  58. BIN
      favicon.ico
  59. 125 0
      functions.php
  60. 47 0
      lib/docxGenerator.php
  61. 196 0
      lib/zip/createzip.php
  62. 22 0
      lib/zip/createzipfromdir.php
  63. 22 0
      mailer/layouts/html.php
  64. 12 0
      mailer/main.php
  65. 496 0
      messages/uk/app.php
  66. 52 0
      messages/uk/rbac.php
  67. 215 0
      messages/uk/user.php
  68. 42 0
      migrations/m181121_153329_create_bills_table.php
  69. 107 0
      models/Admin.php
  70. 79 0
      models/Auclots.php
  71. 419 0
      models/Auctions.php
  72. 76 0
      models/AuctionsSearch.php
  73. 104 0
      models/Bidding.php
  74. 103 0
      models/Bills.php
  75. 57 0
      models/BillsSearch.php
  76. 96 0
      models/BlogPosts.php
  77. 87 0
      models/BlogPostsSearch.php
  78. 63 0
      models/Cabinet.php
  79. 53 0
      models/Categoriesblog.php
  80. 69 0
      models/CategoriesblogSearch.php
  81. 44 0
      models/Category.php
  82. 63 0
      models/ContactForm.php
  83. 131 0
      models/DocumentsToTheUser.php
  84. 70 0
      models/DocumentsToTheUserSearch.php
  85. 94 0
      models/Eventlog.php
  86. 35 0
      models/EventlogQuery.php
  87. 91 0
      models/EventlogSearch.php
  88. 237 0
      models/Files.php
  89. 94 0
      models/FilesSearch.php
  90. 85 0
      models/Help.php
  91. 71 0
      models/HelpCategory.php
  92. 77 0
      models/HelpSearch.php
  93. 60 0
      models/HelpVideo.php
  94. 71 0
      models/HelpVideoSearch.php
  95. 133 0
      models/Images.php
  96. 71 0
      models/ImagesSearch.php
  97. 8 0
      models/LoginForm.php
  98. 96 0
      models/LotSearch.php
  99. 234 0
      models/Lots.php
  100. 0 0
      models/Mails.php

+ 13 - 0
.env-dist

@@ -0,0 +1,13 @@
+YII_DEBUG=1
+YII_ENV='dev'
+
+DB_HOST='localhost'
+DB_NAME='c1nrc'
+DB_USER='c1neiron'
+DB_PASS='neiron22'
+
+SMTP_HOST='smtp.zoho.eu'
+SMTP_USER='etm@react-logic.com'
+SMTP_PASS='neiron22'
+SMTP_PORT='587'
+SMTP_ENC='tls'

+ 11 - 0
.gitignore

@@ -0,0 +1,11 @@
+.idea
+uploads
+vendor
+archive
+web/node_modules
+web/uploadfolder
+stats/
+config/db.php
+.env
+composer.lock
+config/db.php

+ 41 - 0
assets/AppAsset.php

@@ -0,0 +1,41 @@
+<?php
+/**
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright (c) 2008 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+namespace app\assets;
+
+use yii\web\AssetBundle;
+
+/**
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @since 2.0
+ */
+class AppAsset extends AssetBundle
+{
+    public $basePath = '@webroot';
+    public $baseUrl = '@web';
+    public $css = [
+//        'css/dist/css/style.min.css',
+//        'css/backend.css',
+        'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css',
+        'dist/custom.min.css',
+        'css/fixes.css'
+    ];
+    public $js = [
+//        'css/dist/js/scripts.js',
+        //ivakhnov
+//        'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
+        //--------
+//        'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js',
+        'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js',
+        'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js',
+        'dist/scripts.min.js'
+    ];
+    public $depends = [
+        'yii\web\YiiAsset',
+        'yii\bootstrap\BootstrapAsset',
+    ];
+}

+ 31 - 0
assets/BackendAsset.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright (c) 2008 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+namespace app\assets;
+
+use yii\web\AssetBundle;
+
+/**
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @since 2.0
+ */
+class BackendAsset extends AppAsset
+{
+    public $sourcePath = null;
+    public $basePath = '@webroot/backend';
+    public $baseUrl = '@web/backend';
+    public $css = [
+        'css/backend.css'
+    ];
+    public $js = [
+    ];
+    public $depends = [
+        'yii\web\YiiAsset',
+        'yii\bootstrap\BootstrapAsset',
+        'yiister\gentelella\assets\Asset',
+    ];
+}

+ 43 - 0
commands/MailerController.php

@@ -0,0 +1,43 @@
+<?php
+/**
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright (c) 2008 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+namespace app\commands;
+
+use yii\console\Controller;
+use app\models\Mails;
+use Yii;
+
+/**
+ * This command echoes the first argument that you have entered.
+ *
+ * This command is provided as an example for you to learn how to create console commands.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @since 2.0
+ */
+class MailerController extends Controller
+{
+
+    public function actionSend()
+    {
+        foreach(Mails::find()->where(['process' => 0])->limit(20)->all() as $mail){
+            $mail->updateAttributes(['process' => 1]);
+            // try{
+                Yii::$app->mailer->compose('main', ['content' => $mail->text])
+                    ->setTo($mail->email)
+                    ->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->name])
+                    ->setSubject($mail->title)
+                    ->send();
+                // $mail->delete();
+            // }
+            // catch(\Exception $e){
+                // $mail->updateAttributes(['process' => 0]);
+            // }
+        }
+    }
+
+}

+ 46 - 0
components/DektriumMailer.php

@@ -0,0 +1,46 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: andri
+ * Date: 26.10.17
+ * Time: 12:56
+ */
+
+namespace app\components;
+
+use dektrium\user\Mailer;
+use Yii;
+
+
+class DektriumMailer extends Mailer
+{
+
+    /**
+     * @param string $to
+     * @param string $subject
+     * @param string $view
+     * @param array  $params
+     *
+     * @return bool
+     */
+    public function sendMessage($to, $subject, $view, $params = [])
+    {
+        /** @var \yii\swiftmailer\Mailer $mailer **/
+        $mailer = $this->mailerComponent === null ? Yii::$app->mailer : Yii::$app->get($this->mailerComponent);
+        $mailer->viewPath = $this->viewPath;
+        $mailer->getView()->theme = Yii::$app->view->theme;
+
+        if ($this->sender === null) {
+            $this->sender = isset(Yii::$app->params['adminEmail']) ?
+                Yii::$app->params['adminEmail']
+                : 'no-reply@example.com';
+        }
+
+        return $mailer->compose(['html' => $view, 'text' => 'text/' . $view], $params)
+            ->setTo($to)
+            ->setFrom($this->sender)
+            ->setSubject($subject)
+            ->send();
+    }
+
+}

+ 161 - 0
components/NumberToText.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace app\components;
+
+use yii\base\Component;
+
+class NumberToText extends Component
+{
+    private array $units = [
+        ['нуль'],
+        ['один', 'одна'],
+        ['два', 'дві'],
+        ['три'],
+        ['чотири'],
+        ['п’ять'],
+        ['шість'],
+        ['сім'],
+        ['вісім'],
+        ['дев’ять'],
+    ];
+
+    private array $teens = [
+        'десять','одинадцять','дванадцять','тринадцять',
+        'чотирнадцять','п’ятнадцять','шістнадцять',
+        'сімнадцять','вісімнадцять','дев’ятнадцять'
+    ];
+
+    private array $tens = [
+        '', '', 'двадцять','тридцять','сорок',
+        'п’ятдесят','шістдесят','сімдесят',
+        'вісімдесят','дев’яносто'
+    ];
+
+    private array $hundreds = [
+        'сто','двісті','триста','чотириста',
+        'п’ятсот','шістсот','сімсот',
+        'вісімсот','дев’ятсот'
+    ];
+
+    private array $orders = [
+        [ ['тисяча','тисячі','тисяч'], 'f'],
+        [ ['мільйон','мільйони','мільйонів'], 'm'],
+        [ ['мільярд','мільярди','мільярдів'], 'm'],
+    ];
+
+    public function money(float $amount): string
+    {
+        $amount = round($amount, 2);
+
+        $hryvnias = floor($amount);
+        $kopecks = (int)round(($amount - $hryvnias) * 100);
+
+        $result  = $this->convert($hryvnias, ['гривня','гривні','гривень'], 'f');
+        $result .= ' ';
+        $result .= $this->convert($kopecks, ['копійка','копійки','копійок'], 'f');
+
+        return $result;
+    }
+
+    private function convert(int $number, array $forms, string $gender): string
+    {
+        if ($number === 0) {
+            return 'нуль ' . $forms[2];
+        }
+
+        $result = [];
+        $order = 0;
+
+        while ($number > 0) {
+            $chunk = $number % 1000;
+
+            if ($chunk > 0) {
+                $chunkGender = $order === 0 ? $gender : $this->orders[$order-1][1];
+                $words = $this->convertChunk($chunk, $chunkGender);
+                $plural = $this->pluralForm($chunk);
+
+                if ($order === 0) {
+                    $words[] = $forms[$plural];
+                } else {
+                    $words[] = $this->orders[$order-1][0][$plural];
+                }
+
+                $result = array_merge($words, $result);
+            }
+
+            $number = intdiv($number, 1000);
+            $order++;
+        }
+
+        return implode(' ', $result);
+    }
+
+    private function convertChunk(int $number, string $gender): array
+    {
+        $words = [];
+
+        if ($number >= 100) {
+            $words[] = $this->hundreds[intdiv($number,100)-1];
+            $number %= 100;
+        }
+
+        if ($number >= 10 && $number <= 19) {
+            $words[] = $this->teens[$number-10];
+            return $words;
+        }
+
+        if ($number >= 20) {
+            $words[] = $this->tens[intdiv($number,10)];
+            $number %= 10;
+        }
+
+        if ($number > 0) {
+            if ($number == 1 || $number == 2) {
+                $words[] = $this->units[$number][$gender === 'f' ? 1 : 0];
+            } else {
+                $words[] = $this->units[$number][0];
+            }
+        }
+
+        return $words;
+    }
+
+    private function pluralForm(int $number): int
+    {
+        $number %= 100;
+        if ($number >= 11 && $number <= 19) return 2;
+
+        $number %= 10;
+        if ($number == 1) return 0;
+        if ($number >= 2 && $number <= 4) return 1;
+
+        return 2;
+    }
+
+    public function moneyFormatted(float $amount): string
+    {
+        $amount = round($amount, 2);
+
+        $hryvnias = floor($amount);
+        $kopecks = (int)round(($amount - $hryvnias) * 100);
+
+        $numberFormatted = number_format($amount, 2, ',', ' ');
+
+        $textHryvnias = $this->convert(
+            $hryvnias,
+            ['','',''],
+            'f'
+        );
+
+        $plural = $this->pluralForm($hryvnias);
+        $forms = ['гривня','гривні','гривень'];
+
+        return sprintf(
+            "%s (%s) %s %02d копійок",
+            $numberFormatted,
+            $textHryvnias,
+            $forms[$plural],
+            $kopecks
+        );
+    }
+}

+ 59 - 0
components/Templater.php

@@ -0,0 +1,59 @@
+<?php
+namespace app\components;
+
+use Yii;
+use yii\base\Component;
+use yii\helpers\FileHelper;
+
+class Templater extends Component
+{
+    public $templatePath = '@app/templates/protocol.docx';
+    private $content;
+
+    public function process(array $data, $type = 'protocol', $filepath = false)
+    {
+        $filename = $this->createTempFile($filepath, $type);
+
+        $file = new \ZipArchive();
+        if ($file->open($filename) !== true) {
+            throw new \Exception('Cannot open docx file');
+        }
+
+        $this->content = $file->getFromName('word/document.xml');
+        $file->addFromString(
+            'word/document.xml',
+            $this->replace($this->content, $data)
+        );
+
+        $file->close();
+
+        return $filename;
+    }
+
+    private function replace($string, array $params = [])
+    {
+        foreach ($params as $index => $param) {
+            $string = str_ireplace($index, $param, $string);
+        }
+        return $string;
+    }
+
+    private function createTempFile($filepath = false, $type)
+    {
+        $path = $filepath ?: Yii::getAlias('@runtime/tmp');
+        FileHelper::createDirectory($path);
+
+        $filename = "{$type}.docx";
+        $newFilePath = $path . '/' . $filename;
+
+        $tplPath = Yii::getAlias($this->templatePath);
+
+        if (!file_exists($tplPath)) {
+            throw new \Exception("Template not found: " . $tplPath);
+        }
+
+        copy($tplPath, $newFilePath);
+
+        return $newFilePath;
+    }
+}

+ 76 - 0
composer.json

@@ -0,0 +1,76 @@
+{
+    "name": "yiisoft/yii2-app-basic",
+    "description": "Yii 2 Basic Project Template",
+    "keywords": ["yii2", "framework", "basic", "project template"],
+    "homepage": "http://www.yiiframework.com/",
+    "type": "project",
+    "license": "BSD-3-Clause",
+    "support": {
+        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
+        "forum": "http://www.yiiframework.com/forum/",
+        "wiki": "http://www.yiiframework.com/wiki/",
+        "irc": "irc://irc.freenode.net/yii",
+        "source": "https://github.com/yiisoft/yii2"
+    },
+    "minimum-stability": "stable",
+    "require": {
+        "php": ">=5.4.0",
+        "yiisoft/yii2": "~2.0.13",
+        "yiisoft/yii2-bootstrap": "*",
+        "yiisoft/yii2-swiftmailer": "*",
+        "yiisoft/yii2-gii": "*",
+        "dektrium/yii2-user": "0.9.*@dev",
+        "dektrium/yii2-rbac": "dev-master",
+        "mdmsoft/yii2-captcha": "*",
+        "kartik-v/yii2-widget-fileinput": "@dev",
+        "developeruz/yii2-db-rbac": "*",
+        "yiisoft/yii2-debug": "^2.0",
+        "kartik-v/yii2-widget-datetimepicker": "*",
+        "yiidoc/yii2-redactor": "*",
+        "phpoffice/phpword": "v0.13.*",
+        "vlucas/phpdotenv": "^2.4",
+        "rmrevin/yii2-fontawesome": "~2.17",
+        "yiister/yii2-gentelella": "^1.3",
+        "kartik-v/yii2-date-range": "*",
+        "mihaildev/yii2-ckeditor": "*",
+        "mihaildev/yii2-elfinder": "*",
+        "2amigos/yii2-gallery-widget": "~1.0",
+        "yurkinx/yii2-image": "dev-master",
+        "2amigos/yii2-chartjs-widget": "~2.0",
+        "kartik-v/yii2-widget-datepicker": "@dev",
+        "ext-zip" : "*"
+    },
+    "require-dev": {
+        "codeception/codeception" :"*",
+        "yiisoft/yii2-faker": "*"
+    },
+    "config": {
+        "process-timeout": 1800,
+        "fxp-asset": {
+            "installer-paths": {
+                "npm-asset-library": "vendor/npm",
+                "bower-asset-library": "vendor/bower"
+            }
+        }
+    },
+    "scripts": {
+        "post-create-project-cmd": [
+            "yii\\composer\\Installer::postCreateProject"
+        ]
+    },
+    "extra": {
+        "yii\\composer\\Installer::postCreateProject": {
+            "setPermission": [
+                {
+                    "runtime": "0777",
+                    "web/assets": "0777",
+                    "yii": "0755"
+                }
+            ],
+            "generateCookieValidationKey": [
+                "config/web.php"
+            ]
+        }
+
+    }
+}

+ 69 - 0
config/console.php

@@ -0,0 +1,69 @@
+<?php
+
+date_default_timezone_set('Europe/Kiev');
+
+
+Yii::setAlias('@tests', dirname(__DIR__) . '/tests');
+
+$params = require(__DIR__ . '/params.php');
+$db = require(__DIR__ . '/db.php');
+
+return [
+    'id' => 'basic-console',
+    'name'  =>  'UmsTrade',
+    'basePath' => dirname(__DIR__),
+    'bootstrap' => ['log', 'gii'],
+    'controllerNamespace' => 'app\commands',
+    'modules' => [
+        'gii' => 'yii\gii\Module',
+    ],
+    'components' => [
+        'formatter' => [
+            'dateFormat' => 'dd.MM.Y',
+            'datetimeFormat' => 'php:d.m.Y H:i:s',
+            'timeFormat' => 'H:i:s',
+            'locale' => 'uk',
+            'defaultTimeZone' => 'Europe/Kiev',
+        ],
+        'cache' => [
+            'class' => 'yii\caching\FileCache',
+        ],
+        /*
+        'authManager' => [
+            'class' => 'yii\rbac\PhpManager',
+        ],
+        */
+        'authManager' => [
+            'class' => 'yii\rbac\DbManager',
+        ],
+        'mailer' => [
+            'class' => 'yii\swiftmailer\Mailer',
+            'useFileTransport' => false,
+            'viewPath' => '@app/mailer',
+            'transport' => [
+                'class' => 'Swift_SmtpTransport',
+                'host' => getenv('SMTP_HOST'),
+                'username' => getenv('SMTP_USER'),
+                'password' => getenv('SMTP_PASS'),
+                'port' => getenv('SMTP_PORT'),
+                'encryption' => getenv('SMTP_ENC'),
+            ],
+        ],
+        'log' => [
+            'targets' => [
+                [
+                    'class' => 'yii\log\FileTarget',
+                    'levels' => ['error', 'warning'],
+                ],
+            ],
+        ],
+        'urlManager' => [
+            'scriptUrl' => 'http://umstrade.com.ua',
+            'baseUrl' => 'http://umstrade.com.ua',
+            'showScriptName' => false,
+            'enablePrettyUrl' => true,
+        ],
+        'db' => $db,
+    ],
+    'params' => $params,
+];

+ 9 - 0
config/params.php

@@ -0,0 +1,9 @@
+<?php
+
+return [
+    'adminEmail' => 'etm@react-logic.com',
+    'supportEmail' => 'etm@react-logic.com',
+    'language' => 'uk-UA',
+    'sourceLanguage' => 'en-US',
+    'uploadPath'    =>  "../uploads/",
+];

+ 215 - 0
config/web.php

@@ -0,0 +1,215 @@
+<?php
+
+$params = require(__DIR__ . '/params.php');
+
+require (__DIR__."/../lib/docxGenerator.php");
+
+
+$config = [
+    'id' => 'basic',
+    'name'  =>  'НРЦ',
+    'basePath' => dirname(__DIR__),
+    'bootstrap' => ['debug'], // debug
+    'charset'   =>  'utf-8',
+    'language'  =>  'uk',
+    'sourceLanguage' => 'en',
+    'timeZone' => 'Europe/Kiev',
+    // 'on beforeAction' => function($event){
+    //     if(Yii::$app->controller->action->id != 'maintenance'){
+    //         return Yii::$app->controller->redirect(['/site/maintenance']);
+    //     }
+    // },
+    'components' => [
+        'templater' => [
+            'class' => 'app\components\Templater',            
+        ],
+        'num2text' => [
+            'class' => 'app\components\NumberToText',            
+        ],
+        'image' => array(
+            'class' => 'yii\image\ImageDriver',
+            'driver' => 'GD',  //GD or Imagick
+        ),
+        'view' => [
+            'theme' => [
+                'pathMap' => [
+                    '@dektrium/user/views' => '@app/views/user'
+                ],
+            ],
+        ],
+        'request' => [
+            'cookieValidationKey' => '2Q3pzGXlQIxOPm1TyemO0YlVF1ylwRSm',
+            'baseUrl'   =>  '',
+            'parsers' => ['application/json' => 'yii\web\JsonParser',], // for rest api
+        ],
+        'formatter' => [
+            'dateFormat' => 'dd.MM.Y',
+            'datetimeFormat' => 'php:d.m.Y H:i:s',
+            'timeFormat' => 'H:i:s',
+            'locale' => 'uk',
+            'defaultTimeZone' => 'Europe/Kiev',
+        ],
+        'cache' => [
+            'class' => 'yii\caching\FileCache',
+        ],
+        'user' => [
+            'identityClass' => 'app\models\User',
+        ],
+        'errorHandler' => [
+            'errorAction' => 'site/error',
+        ],
+        'authManager' => [
+            'class' => 'dektrium\rbac\components\DbManager',
+        ],
+        'mailer' => [
+            'class' => 'yii\swiftmailer\Mailer',
+            'useFileTransport' => false,
+            'viewPath' => '@app/mailer',
+            'transport' => [
+                'class' => 'Swift_SmtpTransport',
+                'host' => getenv('SMTP_HOST'),
+                'username' => getenv('SMTP_USER'),
+                'password' => getenv('SMTP_PASS'),
+                'port' => getenv('SMTP_PORT'),
+                'encryption' => getenv('SMTP_ENC'),
+            ],
+        ],
+        'log' => [
+            'traceLevel' => YII_DEBUG ? 3 : 0,
+            'targets' => [
+                [
+                    'class' => 'yii\log\FileTarget',
+                    'levels' => ['error', 'warning'],
+                ],
+            ],
+        ],
+        'i18n' => [
+            'translations' => [
+                'app' => [
+                    'class' => 'yii\i18n\PhpMessageSource',
+                    'basePath' => '@app/messages',
+                    'fileMap' => [
+                        'app' => 'app.php',
+                        'app/error' => 'error.php',
+                    ]
+                ],
+                'user' => [
+                    'class' => 'yii\i18n\PhpMessageSource',
+                    'basePath' => '@app/messages',
+                    'fileMap' => [
+                        'user' => 'user.php',
+                    ]
+                ],
+            ],
+        ],
+        'db' => require(__DIR__ . '/db.php'),
+        'urlManager' => [
+            'showScriptName' => false,
+            //'enableStrictParsing' => true, // rest api dont work
+            'enablePrettyUrl' => true,
+            'rules' => [
+                ['class' => 'yii\rest\UrlRule',
+                    'controller' => ['auction','publish','trade','notification'],
+                    'pluralize' => false,
+                    'except' => ['delete']
+                ],// for rest api
+                'public/view/<id>' => 'public/view',
+//                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
+                '<alias:register>' => 'user/registration/<alias>',
+                '<alias:logout|login>' => 'user/security/<alias>',
+                '/news/<name:[\w]+>' => '/site/view',
+                '/product/<slug:[\w-]+>' => '/products/view',
+                '/dopomoga/category/<slug:[\w-]+>' => '/dopomoga/category',
+                '/category/<slug:[\w-]+>' => '/categoriesblog/category',
+            ]
+        ],
+        'assetManager'  =>  [
+            'basePath'  =>  '@webroot/assets',
+            'baseUrl'   =>  '@web/assets',
+            'bundles' => [
+                'kartik\file\FileInputAsset' => [
+                    'sourcePath' => '@webroot/replaces/fileinput',
+                ]
+            ]
+        ]
+    ],
+    'controllerMap' => [
+        'elfinder' => [
+            'class' => 'mihaildev\elfinder\Controller',
+            'access' => ['@'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?']
+            'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
+            'roots' => [
+                [
+                    'baseUrl'=>'@web',
+                    'basePath'=>'@webroot',
+                    'path' => 'uploads/global',
+                    'name' => 'Global'
+                ],
+                [
+                    'class' => 'mihaildev\elfinder\volume\UserPath',
+                    'path'  => 'uploads/user_{id}',
+                    'name'  => 'My Documents'
+                ],
+
+            ],
+        ]
+    ],
+    'modules' => [
+        'user' => [
+            'class' => 'dektrium\user\Module',
+            // 'enableUnconfirmedLogin' => true,
+            'mailer' => [
+                'class' => 'app\components\DektriumMailer',
+                'viewPath' => '@app/views/user/mail',
+            ],
+            'confirmWithin' => 21600,
+            'cost' => 12,
+            'admins' => ['neiron'],
+            'modelMap' => [
+                'RegistrationForm' => 'app\models\RegistrationForm',
+                'User' => 'app\models\User',
+                'UserSearch' => 'app\models\UsersSearch',
+                'LoginForm' => 'app\models\LoginForm',
+                'Profile' => 'app\models\Profile',
+            ],
+            'controllerMap' => [
+                'registration' => 'app\models\RegistrationController',
+                'settings' => 'app\controllers\SettingsController',
+                //'security' => 'app\controllers\SecurityController',
+                'admin' => 'app\controllers\AdminController',
+            ],
+        ],
+        'rbac' => [
+            'class' => 'dektrium\rbac\RbacWebModule',
+        ],
+        'redactor' => [
+            'class' => 'yii\redactor\RedactorModule',
+            'uploadDir' => '@webroot/uploadfolder',
+            'uploadUrl' => '@web/uploadfolder',
+            'imageAllowExtensions'=>['jpg','png','gif']
+        ],
+        // 'debug' => [
+        //    'class' => 'yii\debug\Module',
+        // ],
+    ],
+    'params' => $params,
+];
+
+if (YII_ENV_DEV) {
+    // configuration adjustments for 'dev' environment
+    $config['bootstrap'][] = 'debug';
+    $config['modules']['debug'] = [
+        'class' => 'yii\debug\Module',
+    ];
+    // $config['modules']['debug']['allowedIPs'] = ['93.78.238.18','192.168.2.5','127.0.0.1','10.0.0.1','192.168.2.207', '::1', '93.78.206.*'];
+
+    $config['bootstrap'][] = 'gii';
+    //$config['modules']['gii'] = 'yii\gii\Module';
+    //$config['modules']['gii'] = ['class' => 'yii\gii\Module'];
+    $config['modules']['gii'] = [
+        'class' => 'yii\gii\Module',
+        // 'allowedIPs' => ['93.78.238.18','127.0.0.1','10.0.0.1','192.168.2.207', '::1', '93.78.206.*'],
+    ];
+}
+
+return $config;

+ 31 - 0
controllers/AdminController.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: andri
+ * Date: 26.10.17
+ * Time: 12:39
+ */
+
+namespace app\controllers;
+
+
+use dektrium\user\controllers\AdminController as BaseAdminConteroler;
+use Yii;
+use dektrium\user\Mailer;
+use yii\helpers\Url;
+
+
+class AdminController extends BaseAdminConteroler
+{
+
+    public function actionSend($id)
+    {
+        $model = $this->findModel($id);
+        //$mailer = Yii::createObject(Mailer::className());
+        $mailer = Yii::$container->get(Mailer::className());
+        $mailer->sendMessage($model->email, Yii::t('app','ActivationSubject ID'), 'confirmation');
+
+        return $this->redirect(Url::previous('actions-redirect'));
+    }
+
+}

+ 156 - 0
controllers/AuclotsController.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Bills;
+use Yii;
+use app\models\Auclots;
+use app\models\Files;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\UploadedFile;
+
+/**
+ * AuclotsController implements the CRUD actions for Auclots model.
+ */
+class AuclotsController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Auclots models.
+     * @return mixed
+     */
+    public function init()
+    {
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)){
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function actionIndex()
+    {
+        $dataProvider = new ActiveDataProvider([
+            'query' => Auclots::find()->where(['user_id'=>Yii::$app->user->identity->id])->orderBy('id DESC'),
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Auclots model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Auclots model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Auclots();
+        if (Yii::$app->request->post()) {
+
+            $files = new Files();
+
+            $dogovor = UploadedFile::getInstance($files, 'file');
+            if(isset($dogovor))
+            {
+                $dogovor->name = $files->transliteration($dogovor->name);
+                $path = Yii::$app->params['uploadPath'].$dogovor->name;
+                $dogovor->saveAs($path);
+                $model->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'
+                ]);
+            }
+        }
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            Yii::$app->session->setFlash('success', Yii::t('app', 'AuctionCreated ID'));
+            return $this->redirect(['index']);
+        } else {
+            return $this->render('create', ['model' => $model]);
+        }
+    }
+
+    /**
+     * Updates an existing Auclots model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Auclots model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Auclots model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Auclots the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Auclots::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 76 - 0
controllers/AuctionController.php

@@ -0,0 +1,76 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: NeiroN
+ * Date: 11.10.2015
+ * Time: 12:08
+ */
+namespace app\controllers;
+use Yii;
+use app\models\Auctions;
+use yii\rest\ActiveController;
+use yii\data\ActiveDataProvider;
+use yii\filters\AccessControl;
+
+class AuctionController extends ActiveController
+{
+    public $modelClass = 'app\models\Auctions';
+
+    public function actions()
+    {
+        return [
+            'index' => [
+                'class' => 'yii\rest\IndexAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'prepareDataProvider' =>  function ($action)
+                {
+                    if(Yii::$app->request->get()) { $auc_id = $_GET['id']; }
+                    if(isset($auc_id)) {
+                        return new ActiveDataProvider(
+                            [
+                                'query' => Auctions::find()->where(['id' => $auc_id]),
+                            ]);
+                    } else {
+                        return new ActiveDataProvider(
+                            [
+                                'query' => Auctions::find(),
+                            ]);
+                    }
+                }
+            ],
+            'view' => [
+                'class' => 'yii\rest\ViewAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'create' => [
+                'class' => 'yii\rest\CreateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->createScenario,
+            ],
+            'update' => [
+                //'class' => 'yii\rest\UpdateAction',
+                'class' => 'app\controllers\UpdateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->updateScenario,
+            ],
+            'delete' => [
+                'class' => 'yii\rest\DeleteAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'options' => [
+                'class' => 'yii\rest\OptionsAction',
+            ],
+        ];
+    }
+    public function checkAccess($action, $model = null, $params = [])
+    {
+        // check if the user can access $action and $model
+        // throw ForbiddenHttpException if access should be denied
+    }
+
+}

+ 366 - 0
controllers/AuctionsController.php

@@ -0,0 +1,366 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Bidding;
+use app\models\Lots;
+use app\models\Messages;
+use app\models\Eventlog;
+use dektrium\user\Mailer;
+use Yii;
+use app\models\Auctions;
+use app\models\AuctionsSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use DateTime;
+use app\models\Subscriptions;
+use yii\helpers\ArrayHelper;
+/**
+ * AuctionsController implements the CRUD actions for Auctions model.
+ */
+class AuctionsController extends Controller
+{
+
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+
+        ];
+    }
+
+    /**
+     * Lists all Auctions models.
+     * @return mixed
+     */
+
+    public function init()
+    {
+        /*if(Yii::$app->user->isGuest)
+        {
+            Yii::$app->getSession()->setFlash('warning', Yii::t('app', 'EnterWatcher ID'));
+            return $this->redirect('/user/login');
+        }*/
+        if(@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)){
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+    private function getIP()
+    {
+        return $_SERVER['REMOTE_ADDR'];
+    }
+
+    public function actionIndex()
+    {
+
+        $searchModel = new AuctionsSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Auctions model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        if(Yii::$app->user->isGuest)
+        {
+            Yii::$app->getSession()->setFlash('success', Yii::t('app', 'EnterWatcher ID'));
+            return $this->redirect('/user/login');
+        }
+
+        $model = $this->findModel($id);
+
+        if($model->user_id==Yii::$app->user->identity->id) {
+
+            Yii::createObject(Eventlog::className())->PutLog([
+                'user_id' => Yii::$app->user->identity->id,
+                'ip' => $this->getIP(),
+                'auk_id' => $model->id,
+                'action' => Yii::t('app','OrgEnterAuk ID'),
+            ]);
+
+            $model->setFlags($id);
+            return $this->render('view', [
+                'model' => $model,
+            ]);
+        }
+        if(Yii::$app->user->can('admin'))
+        {
+            Yii::createObject(Eventlog::className())->PutLog([
+                'user_id' => Yii::$app->user->identity->id,
+                'ip' => $this->getIP(),
+                'auk_id' => $model->id,
+                'action' => Yii::t('app','EnterAuk ID'),
+            ]);
+            $model->setFlags($id);
+            return $this->render('view', [
+                'model' => $model,
+            ]);
+        }
+        if(Yii::$app->user->can('watcher'))
+        {
+            Yii::createObject(Eventlog::className())->PutLog([
+                'user_id' => Yii::$app->user->identity->id,
+                'ip' => $this->getIP(),
+                'auk_id' => $model->id,
+                'action' => Yii::t('app','WatcherEnterAuk ID'),
+            ]);
+
+            $model->setFlags($id);
+            return $this->render('view', [
+                'model' => $model,
+            ]);
+        }
+        else
+        {
+            $sql = Yii::$app->db->createCommand("SELECT status from bidding WHERE auction_id=:auction_id and user_id=:user_id");
+            $sql->bindValues([':auction_id' => $model->id,':user_id' => Yii::$app->user->identity->id]);
+            $res = $sql->queryOne();
+
+            if($res==false)
+            {
+                Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'NeedBidding ID'));
+                return $this->redirect('/auctions/index');
+
+            }
+            elseif($res['status']=="2") // 2=reject
+            {
+                Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'BidRejected ID'));
+                return $this->redirect('/auctions/index');
+            }
+            elseif($res['status']=="0") // 0=default
+            {
+                Yii::$app->getSession()->setFlash('warning', Yii::t('app', 'BidWaiting ID'));
+                return $this->redirect('/auctions/index');
+            }
+            elseif($res['status']=="1") // 0=accept
+            {
+                Yii::createObject(Eventlog::className())->PutLog([
+                    'user_id' => Yii::$app->user->identity->id,
+                    'ip' => $this->getIP(),
+                    'auk_id' => $model->id,
+                    'action' => Yii::t('app','EnterAuk ID'),
+                ]);
+                $model->setFlags($id);
+                return $this->render('view', [
+                    'model' => $model,
+                ]);
+            }
+            else
+            {
+                throw new NotFoundHttpException('Page not found');
+            }
+
+        }
+    }
+
+    /**
+     * Creates a new Auctions model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        print_r(Yii::$app->request->post());
+        exit;
+        
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(Yii::$app->user->can('admin') && Yii::$app->user->can('org')) {
+            $model = new Auctions();
+
+            if ($model->load(Yii::$app->request->post()) && $model->save()) {
+                return $this->redirect(['view', 'id' => $model->id]);
+            } else {
+                return $this->render('create', [
+                    'model' => $model,
+                ]);
+            }
+        }
+        else
+        {
+            return $this->redirect(['index']);
+        }
+    }
+
+    /**
+     * Updates an existing Auctions model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(Yii::$app->user->can('admin')) {
+
+            $model = $this->findModel($id);
+
+            if ($model->load(Yii::$app->request->post()) && $model->save()) {
+                return $this->redirect(['view', 'id' => $model->id]);
+            } else {
+                return $this->render('update', [
+                    'model' => $model,
+                ]);
+            }
+        }
+        else
+        {
+            return $this->redirect(['index']);
+        }
+    }
+
+    /**
+     * Deletes an existing Auctions model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(Yii::$app->user->can('admin')) {
+
+
+           $lotId =  $this->findModel($id)->lot_id;
+           $lots = Lots::findOne($lotId);
+           $lots->updateAttributes(['lot_lock' => 0]);
+
+            $this->findModel($id)->delete();
+
+
+            return $this->redirect(['index']);
+        }
+        else
+        {
+            return $this->redirect(['index']);
+        }
+    }
+    public function actionTradelog($id)
+    {
+        $user_id = '0';
+        $query = Yii::$app->db->createCommand('SELECT * FROM trade_logs WHERE auk_id=:id'); //AND user_id=:user_id'
+        $query->bindValues([':id' => $id]); //':user_id'    =>  $user_id]
+        $result = $query->queryAll();
+        $filename = "../uploads/temp/tradelog-".$id.$user_id.date('Ymdhis').".doc";
+        $file = fopen($filename,'w+');
+        foreach ($result as $item => $value)
+        {
+            fputs($file,$value['date']." ".$value['comment']."\n");
+        }
+        fclose($file);
+        Yii::$app->response->SendFile($filename);
+    }
+
+    public function actionBid($id, $special = null)
+    {
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+
+        $model = $this->findModel($id);
+
+
+        $bid_date = new DateTime($model->bidding_date);
+        $now_date = new DateTime(date("Y-m-d H:i:s"));
+        //var_dump($bid_date->diff($now_date));
+
+        if($bid_date < $now_date)
+        {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'BiddingTimeEnd ID'));
+            return $this->redirect(['/lots/view', 'id' => $model->lot_id]);
+        }
+        // test for documents
+        $sql = Yii::$app->db->createCommand("SELECT id from files WHERE auction_id=:auction_id and user_id=:user_id order by id desc");
+        $sql->bindValues([':auction_id' => $model->id,':user_id' => Yii::$app->user->identity->id]);
+        $result = $sql->queryOne();
+        if(!$result)
+        {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'NeedDownloadFiles ID'));
+            return $this->redirect(['/lots/view', 'id' => $model->lot_id]);
+        }
+        else
+        {
+            $file_id = $result['id'];
+        }
+        // test for repeat
+        $sql = Yii::$app->db->createCommand("SELECT * from bidding WHERE auction_id=:auction_id and user_id=:user_id");
+        $sql->bindValues([':auction_id' => $model->id,':user_id' => Yii::$app->user->identity->id]);
+        $result = $sql->queryOne();
+
+
+        if(!$result)
+        {
+            Yii::createObject(Bidding::className())->CreateBid([
+                'auction_id' => $model->id,
+                'user_id' => Yii::$app->user->identity->id,
+                'org_id'=>$model->user_id,
+                'file_id'=>$file_id,
+                'special_price' => ArrayHelper::getValue(YII::$app->request->post('Bidding'), 'special_price', 0)
+            ]);
+
+            $notes_org = Yii::$app->user->identity->at_org ." ". Yii::t('app', 'NotesOrg ID') .": ". $model->name ." / ".
+                Yii::t('app','LotNumber ID'). $model->lot_num ." ". $model->lot->name; //Yii::t('app', 'Notes2Org ID');
+            $notes_self = Yii::t('app', 'NotesMember ID') .": ". $model->name. " / ". Yii::t('app','Lot ID'). " " .$model->lot_num ." ". $model->lot->name;
+
+            Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->user_id, 'notes' => $notes_org]);
+
+            Subscriptions::subscribe($model->category->id, Yii::$app->user->getId());
+
+            // отправка на почту (временно)
+            //$mailer = Yii::$container->get(Mailer::className());
+            //$mailer->sendMessage("vanouub@meta.ua", $notes_org, 'welcome.php');
+
+            Yii::createObject(Messages::className())->CreateMessage(['user_id' => Yii::$app->user->identity->id, 'notes' => $notes_self]);
+
+            Yii::$app->session->setFlash('success', Yii::t('app', 'BidWellDone ID'));
+
+            return $this->redirect(['index', 'id' => Yii::$app->user->identity->id]);
+        }
+        else
+        {
+            Yii::$app->session->setFlash('warning', Yii::t('app', 'BidExist ID'));
+            return $this->redirect(['index', 'id' => Yii::$app->user->identity->id]);
+        }
+    }
+
+    /**
+     * Finds the Auctions model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Auctions the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Auctions::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 277 - 0
controllers/BiddingController.php

@@ -0,0 +1,277 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Auctions;
+use Yii;
+use app\models\Files;
+use app\models\Bidding;
+use app\models\Messages;
+use app\models\Eventlog;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\UploadedFile;
+use DateTime;
+
+
+class BiddingController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    public function init(){
+        if(@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)){
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function actionConfirm($id)
+    {
+
+        $model = $this->findModel($id);
+        $model->setAttribute('status','1');
+        if(($model->special_price > $model->auction->lot->start_price)
+            && ($model->special_price > $model->auction->special_price) && in_array($model->auction->status, [0, 1]) ){
+            $auc = Auctions::find()->where(['id' => $model->auction_id])->one();
+            $auc->special_user = $model->user_id;
+            $auc->special_price = $model->special_price;
+            $auc->save(false);
+        }
+        $model->save(false);
+
+        Yii::createObject(Eventlog::className())->PutLog([
+            'user_id' => Yii::$app->user->identity->id,
+            'ip' => $_SERVER['REMOTE_ADDR'],
+            'auk_id' => $model->id,
+            'action' => Yii::t('app','ConfirmationOfBidding ID'),
+        ]);
+
+        $notes = Yii::t('app','BiddingConfirm ID').": ".$model->auction->name." / ".
+            Yii::t('app','LotNumber ID')." ".
+            $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+
+
+        Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->user_id, 'notes' => $notes]);
+
+        return $this->redirect(['index', 'id' => Yii::$app->user->identity->id]);
+    }
+
+    public function actionIndex()
+    {
+        if(Yii::$app->user->can('org') || Yii::$app->user->can('admin'))
+        {
+            //$dataProvider = new ActiveDataProvider([
+            //    'query' => Bidding::find()->where(['org_id' => Yii::$app->user->identity->id]),
+            //]);
+
+            // Obnylator Biddings
+            //Yii::$app->db->createCommand("UPDATE bidding SET readed=1 WHERE org_id=:user_id")->bindValue(":user_id",Yii::$app->user->identity->id)->execute();
+
+
+
+            // Pagination
+            $totalCount = Bidding::find()->where(['org_id' => Yii::$app->user->getId()])->count();
+
+            $query = Bidding::find()
+                ->joinWith([
+                    'auction',
+                    'lot',
+                    'user'])
+                //->where(['bidding.org_id' => Yii::$app->user->getId()])
+                ->orderBy(['bidding.id' => SORT_DESC]);
+//            $query = '
+//              SELECT
+//                    bidding.id
+//                    bidding.created_at,
+//                    auctions.date_start,
+//                    auctions.name as aukname,
+//                    lots.name,
+//                    user.at_org,
+//                    bidding.status,
+//                    bidding.file_id
+//                      FROM `bidding`
+//                      LEFT JOIN auctions
+//                        ON (bidding.auction_id=auctions.id)
+//                      LEFT JOIN lots
+//                        ON (auctions.lot_id=lots.id)
+//                      LEFT JOIN user
+//                        ON (bidding.user_id=user.id)
+//                      WHERE bidding.org_id=:org_id
+//                      ORDER by bidding.id DESC';
+            $dataProvider = new ActiveDataProvider([
+                'query' => $query,
+                'pagination' => [
+                    'pageSize' => 40,
+                ]
+            ]);
+            return $this->render('index', [
+                'dataProvider' => $dataProvider,
+            ]);
+        }
+        else
+        {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+
+    public function actionView()
+    {
+        Yii::$app->db->createCommand("UPDATE bidding SET readed=1 WHERE user_id=:user_id")->bindValue(":user_id",Yii::$app->user->identity->id)->execute();
+        $dataProvider = new ActiveDataProvider([
+            'query' => Bidding::find()->where(['user_id' => Yii::$app->user->identity->id,])->orderBy('created_at DESC'),
+        ]);
+
+        return $this->render('view', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if(Yii::$app->user->can('member'))
+        {
+            $bid_date = new DateTime($model->auction->bidding_date);
+            $now_date = new DateTime(date("Y-m-d H:i:s"));
+            var_dump($bid_date->diff($now_date));
+
+            if($bid_date < $now_date)
+            {
+                return $this->redirect(['view']);
+            }
+
+            if (Yii::$app->request->post())
+            {
+                $files = new Files();
+
+                $file = UploadedFile::getInstance($files, 'file');
+                $file->name = $files->transliteration($file->name);
+
+                if(isset($file))
+                {
+                    $path = Yii::$app->params['uploadPath'].$file->name;
+                    $file->saveAs($path);
+                    $files->updateFile([
+                            'name'=>$file->name,
+                            'file_id'=>$model->file_id]
+                    );
+
+                    $notes = Yii::$app->user->identity->at_org." ". Yii::t('app','BiddingEdit ID').": ".
+                        $model->auction->name ." / ". Yii::t('app','LotNumber ID')." ".
+                        $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+                    $self_notes = Yii::t('app','BiddingEditSelf ID').": ".
+                        $model->auction->name." / ".
+                        Yii::t('app','LotNumber ID')." ".
+                        $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+
+                    Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->org_id, 'notes' => $notes]);
+                    Yii::createObject(Messages::className())->CreateMessage(['user_id' => Yii::$app->user->identity->id, 'notes' => $self_notes]);
+
+                    return $this->redirect(['view']);
+                }
+                else
+                {
+                    print "no file";
+                }
+            }
+            else
+            {
+                return $this->render('update', [
+                    'model' => $model,
+                ]);
+            }
+        }
+        else
+        {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+
+
+    }
+
+    public function actionReject($id)
+    {
+        $model = $this->findModel($id);
+        $model->setAttribute('status','2');
+        $model->save(false);
+
+        //by ivakhnov
+        $notes = Yii::t('app','BidRejected ID').": ".$model->auction->name." / ".
+            Yii::t('app','LotNumber ID')." ".
+            $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+        //-----------
+
+        Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->user_id, 'notes' => $notes]);
+
+        return $this->redirect(['index', 'id' => Yii::$app->user->identity->id]);
+    }
+
+
+    public function actionDelete($id)
+    {
+        $model = $this->findModel($id);
+
+        $model->delete();
+
+        if(Yii::$app->user->can('member'))
+        {
+            $bid_date = new DateTime($model->auction->bidding_date);
+            $now_date = new DateTime(date("Y-m-d H:i:s"));
+            var_dump($bid_date->diff($now_date));
+            if ($bid_date < $now_date) {
+                return $this->redirect(['view']);
+            }
+        }
+        $notes = Yii::$app->user->identity->at_org." ". Yii::t('app','BiddingDelete ID').": ".
+            $model->auction->name ." / ". Yii::t('app','LotNumber ID')." ".
+            $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+        $self_notes = Yii::t('app','BiddingDeleteSelf ID').": ".
+            $model->auction->name." / ".
+            Yii::t('app','LotNumber ID')." ".
+            $model->auction->lot_num ." ". $this->getLotName($model->auction->lot_id);
+
+
+        Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->org_id, 'notes' => $notes]);
+        Yii::createObject(Messages::className())->CreateMessage(['user_id' => Yii::$app->user->identity->id, 'notes' => $self_notes]);
+
+        $this->findModel($id)->delete();
+
+        if(Yii::$app->user->can('org'))
+        {
+            return $this->redirect(['index']);
+        }
+        if(Yii::$app->user->can('member'))
+        {
+            return $this->redirect(['bidding/view']);
+        }
+    }
+    protected function findModel($id)
+    {
+        if (($model = Bidding::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+    public function getLotName($id)
+    {
+        $lotName = Yii::$app->db->createCommand("SELECT name from lots WHERE id=:id")->bindValue(':id',$id);
+        $result = $lotName->queryOne();
+        return $result['name'];
+    }
+
+}

+ 205 - 0
controllers/BillsController.php

@@ -0,0 +1,205 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Bills;
+use app\models\BillsSearch;
+use yii\filters\AccessControl;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\Response;
+
+/**
+ * BillsController implements the CRUD actions for Bills model.
+ */
+class BillsController extends Controller
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' => [
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'actions' => ['payed', 'download-template'],
+                        'roles' => ['admin'],
+                    ],
+                    [
+                        'allow' => true,
+                        'actions' => ['index', 'create', 'update', 'view', 'delete', 'download-requisites'],
+                        'roles' => ['@'],
+                    ],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * Lists all Bills models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new BillsSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Bills model.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Bills model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Bills();
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+        return $this->render('create', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Updates an existing Bills model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+        return $this->render('update', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Deletes an existing Bills model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+        return $this->redirect(['index']);
+    }
+
+    public function actionPayed($id, $payed)
+    {
+        Yii::$app->response->format = Response::FORMAT_JSON;
+        return $this->findModel($id)->updateAttributes(['payed' => $payed]);
+    }
+
+    /**
+     * Finds the Bills model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Bills the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Bills::findOne($id)) !== null) {
+            return $model;
+        }
+        throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
+    }
+
+    public function actionDownloadTemplate()
+    {
+        $filename = templater()->process([
+            'billID' => 'номер рахунку',
+            'auctionID' => 'номер аукціону',
+            'date' => date('d-m-Y'),
+            'inn' => 'ІПН',
+            'zkpo' => 'ЭКПО',
+            'uAddress' => 'юр. адреса',
+            'bank' => 'банк',
+            'payAccount' => 'розрахунковий рахунок',
+            'phone' => 'телефон',
+            'fax' => 'факс',
+            'firmaFull' => 'повна назва фірми',
+            'billType' => 'тип рахунку',
+            'amountString' => num2str(121.34),
+            'amount' => 121.34,
+            'amountVat' => 121.34,
+        ]);
+        return Yii::$app->response->sendFile($filename);
+    }
+
+    public function actionDownloadRequisites($id) {
+        $model = $this->findModel($id);
+        
+        $type = $model->type;
+        $percent_g = 0.015;
+        $percent_r = 0.0015;
+        $amount_vat = $amount = $type == 'guarantee'
+            ? $percent_g*$model->auction->lot->start_price
+            : $percent_r*$model->auction->lot->start_price;
+        if ($model->auction->lot->nds) {
+            $amount = $amount/1.2*1;
+        } else {
+            $amount_vat *= 1.2;
+        }
+        
+        $filename = templater()->process(
+            [
+                'billID' => $model->id,
+                '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,
+                'payAccount' => $model->requisite->account,
+                'phone' => $model->profile->phone,
+                'fax' => $model->profile->fax,
+                'firmaFull' => $model->profile->firma_full,
+                'billType' => $type == 'guarantee'? 'Гарантійний внесок': 'Регістраційний внесок',
+                'amountString' => num2str($amount_vat),
+                'amountVat' => $amount_vat,
+                'amount' => $amount,
+                'vat' => $model->auction->lot->nds ? 'з ПДВ' : 'без ПДВ',
+            ],
+            $type
+        );
+        return Yii::$app->response->sendFile($filename);
+
+    }
+}

+ 113 - 0
controllers/BlogPostsController.php

@@ -0,0 +1,113 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\BlogPosts;
+use app\models\BlogPostsSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+use yii\web\UploadedFile;
+
+/**
+ */
+class BlogPostsController extends Controller
+{
+
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' =>[
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    private function saveImg($model)
+    {
+        if($model->imageFile = UploadedFile::getInstance($model,'imageFile')){
+            if($model->picture){
+                @unlink($model->picture);
+            }
+            $imageName = 'uploads/'.$model->title . '.' . $model->imageFile->extension;
+            $model->imageFile->saveAs($imageName );
+            $model->picture = $imageName;
+            $model->save(false);
+        }
+    }
+
+    public function actionIndex()
+    {
+        $searchModel = new BlogPostsSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    public function actionCreate()
+    {
+        $model = new BlogPosts();
+        $model->created_at = time();
+        if ($model->load(Yii::$app->request->post()) && $model->upload()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            $this->saveImg($model);
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    protected function findModel($id)
+    {
+        if (($model = BlogPosts::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 41 - 0
controllers/CabinetController.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Cabinet;
+use yii\data\ActiveDataProvider;
+
+
+class CabinetController extends \yii\web\Controller
+{
+    public function actionIndex()
+    {
+        $date = date("Y-m-d H:i:s");
+        $query = Cabinet::find()
+            ->where("bidding_date > '".$date."'")
+            ->groupBy('name');
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+    public function init()
+    {
+        //Yii::$app->session->get('user.flags'); exit;
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        else
+        {
+            $this->layout = '@app/views/layouts/backend/user';
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+    }
+
+}

+ 181 - 0
controllers/CategoriesblogController.php

@@ -0,0 +1,181 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\BlogPostsSearch;
+use Yii;
+use app\models\Categoriesblog;
+use app\models\CategoriesblogSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+use yii\data\ActiveDataProvider;
+use app\models\Posts;
+use app\models\BlogPosts;
+use app\models\Pages;
+
+/**
+ */
+class CategoriesblogController extends Controller
+{
+
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    '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' => ['?'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    public function actionIndex()
+    {
+
+        $searchModel = new CategoriesblogSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    public function actionPage( $slug )
+    {
+        $this->layout = '@app/views/layouts/public';
+        if(false != ($model = Pages::findOne(['slug' => $slug]))){
+            return $this->render('page', [
+                'model' => $model,
+            ]);
+        }else{
+            throw new NotFoundHttpException(Yii::t('app','Post not found'));
+        }
+    }
+
+    public function actionCreate()
+    {
+        $model = new Categoriesblog();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionBlog(){
+        $dataProvider = new ActiveDataProvider([
+            'query' => Posts::find(),
+            'pagination' => [
+                'defaultPageSize' => 5,
+                'forcePageParam' => false,
+                'pageSizeParam' => false,
+            ],
+            'sort' => [
+                'defaultOrder'=>[
+                    'id' => SORT_DESC,
+                ],
+            ],
+        ]);
+        return $this->render('blog', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionCategory($slug, $lang = null)
+    {
+        $this->layout = '@app/views/layouts/public';
+        $query = Categoriesblog::findOne(['slug' => $slug]);
+        //метатеги для категорий
+
+        $title = $query->title;
+        $key = $query->key_words;
+        $desc = $query->description;
+        //метатеги для категорий lang = ru
+        $title_ru = $query->title_ru;
+        $key_ru = $query->key_words_ru;
+        $desc_ru = $query->description_ru;
+        if($lang == 'ru'){
+            $this->view->title = $title_ru;
+            $this->view->registerMetaTag(['name' => 'keywords', 'content' => $key_ru]);
+            $this->view->registerMetaTag(['name' => 'description', 'content' => $desc_ru]);
+        }else {
+            $this->view->title = $title;
+            $this->view->registerMetaTag(['name' => 'keywords', 'content' => $key]);
+            $this->view->registerMetaTag(['name' => 'description', 'content' => $desc]);
+        }
+        //-----
+
+        $searchModel = new BlogPostsSearch();
+
+        $searchModel->categorySlug = $slug;
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams, '');
+
+        //if($lang === null) unset($lang);
+
+        return $this->render('blog',[
+            'searchModel'=>$searchModel,
+            'dataProvider' => $dataProvider,
+            'lang' => $lang,
+        ]);
+
+
+    }
+
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    protected function findModel($id)
+    {
+        if (($model = Categoriesblog::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 130 - 0
controllers/CategoryController.php

@@ -0,0 +1,130 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Category;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * CategoryController implements the CRUD actions for Category model.
+ */
+class CategoryController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Category models.
+     * @return mixed
+     */
+
+    public function init()
+    {
+
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+    }
+    public function actionIndex()
+    {
+        $dataProvider = new ActiveDataProvider([
+            'query' => Category::find(),
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Category model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Category model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Category();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Category model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Category model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Category model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Category the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Category::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 126 - 0
controllers/DocumentsToTheUserController.php

@@ -0,0 +1,126 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\DocumentsToTheUser;
+use app\models\DocumentsToTheUserSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\UploadedFile;
+
+/**
+ * DocumentsToTheUserController implements the CRUD actions for DocumentsToTheUser model.
+ */
+class DocumentsToTheUserController extends Controller
+{
+    public $layout = '@app/views/layouts/backend/user';
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all DocumentsToTheUser models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new DocumentsToTheUserSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single DocumentsToTheUser model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new DocumentsToTheUser model.
+     * If creation is successful, the browser will be *.doc *.docx *.pdf *.png *.jpg *.tiff, *.zip *rarredirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new DocumentsToTheUser();
+
+        if ($model->load(Yii::$app->request->post()) && $model->upload()) {
+            // file is uploaded successfully
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+        return $this->render('create', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Updates an existing DocumentsToTheUser model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->upload()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing DocumentsToTheUser model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the DocumentsToTheUser model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return DocumentsToTheUser the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = DocumentsToTheUser::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 93 - 0
controllers/DopomogaController.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\HelpCategory;
+use app\models\HelpVideo;
+use Yii;
+use app\models\Help;
+use app\models\HealpSearch as HelpSearch;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+
+/**
+ * HelpController implements the CRUD actions for Help model.
+ */
+class DopomogaController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+
+    /**
+     * Lists all Help models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $dataProvider = new ActiveDataProvider([
+            'query' => HelpCategory::find(),
+        ]);
+        return $this->render('index',[
+            'dataProvider' =>$dataProvider,
+        ]);
+    }
+
+    public function actionCategory($slug)
+    {
+        $category = HelpCategory::findOne(['slug' => $slug]);
+        $videos = HelpVideo::findAll(['cat_id' => $category->id]);
+
+        $title = $category->title;
+        $key = $category->key_words;
+        $desc = $category->description;
+        $this->view->title = $title;
+        $this->view->registerMetaTag(['name' => 'keywords', 'content' => $key]);
+        $this->view->registerMetaTag(['name' => 'description', 'content' => $desc]);
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => Help::find()->where(['cat_id' => $category->id]),
+            'pagination' => [
+                'defaultPageSize' => 5,
+            ],
+            'sort' => [
+                'defaultOrder' => [
+                    'id' => SORT_DESC,
+                ],
+            ],
+        ]);
+
+        return $this->render('category',[
+            'dataProvider' => $dataProvider,
+            'videos' => $videos,
+        ]);
+    }
+
+    public function actionView($slug)
+    {
+        if (false != ($model = Help::findOne(['slug' => $slug]))) {
+            return $this->render('view', [
+                'model' => $model,
+            ]);
+        } else {
+            throw new NotFoundHttpException(Yii::t('app', 'Post not found'));
+        }
+    }
+
+
+}

+ 24 - 0
controllers/DownloadsFilesController.php

@@ -0,0 +1,24 @@
+<?php 
+namespace app\controllers;
+
+
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+
+
+class DownloadsFilesController extends Controller{
+
+	public function actionRules(){
+		return $this->render('rules');
+	}
+
+	public function actionExamples(){
+		return $this->render('examples');
+	}
+
+	public function actionReglament(){
+		return $this->render('reglament');
+	}
+
+}
+?>

+ 150 - 0
controllers/EventlogController.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Trade;
+use Yii;
+use app\models\Eventlog;
+use app\models\EventlogSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * EventlogController implements the CRUD actions for Eventlog model.
+ */
+class EventlogController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Eventlog models.
+     * @return mixed
+     */
+    public function init()
+    {
+
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(!Yii::$app->user->can("admin"))
+        {
+            return $this->redirect('/site/index');
+        }
+    }
+
+    public function actionIndex()
+    {
+        $searchModel = new EventlogSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+        //print_r($dataProvider); die();
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Eventlog model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Eventlog model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Eventlog();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Eventlog model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+    public function actionTradelog($id,$user_id)
+    {
+        $query = Yii::$app->db->createCommand('SELECT * FROM trade_logs WHERE auk_id=:id AND user_id=:user_id');
+        $query->bindValues([':id' => $id, ':user_id'    =>  $user_id]);
+        $result = $query->queryAll();
+        $filename = "../uploads/temp/tradelog-".$id.$user_id.date('Ymdhis').".doc";
+        $file = fopen($filename,'w+');
+        foreach ($result as $item => $value)
+        {
+            fputs($file,$value['date']." ".$value['comment']."\n");
+        }
+        fclose($file);
+        Yii::$app->response->xSendFile($filename);
+    }
+
+    /**
+     * Deletes an existing Eventlog model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Eventlog model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Eventlog the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Eventlog::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 181 - 0
controllers/FilesController.php

@@ -0,0 +1,181 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Files;
+use app\models\FilesSearch;
+use yii\filters\VerbFilter;
+use yii\web\NotFoundHttpException;
+
+class FilesController extends \yii\web\Controller
+{
+
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+
+    public function init()
+    {
+        //if(Yii::$app->user->isGuest)
+        //{
+        //    return $this->redirect('/user/login');
+        //}
+    }
+
+
+
+    public function actionDownload($id)
+    {
+
+        $model = $this->findModel($id);
+
+        if(!is_file($model->path.$model->name)){
+
+            throw new NotFoundHttpException('Файл не знайдено, можливо він був видалений .');
+        }
+
+        //$filename = str_replace(" ","_",$model->name);
+            $file = $model->path . $model->name; //print $file; exit;
+/*
+        header('Content-Description: File Transfer');
+        header('Content-Type: application/octet-stream');
+        header('Content-Disposition: attachment; filename=' . $model->name);
+        header('Content-Transfer-Encoding: binary');
+        header('Expires: 0');
+        header('Cache-Control: must-revalidate');
+        header('Pragma: public');
+        header('Content-Length: ' . filesize($file));
+        readfile($file);*/
+        Yii::$app->response->sendFile($file);
+//        Yii::$app->response->xSendFile($file);
+/*
+        header ("Content-Type: application/octet-stream");
+        header ("Accept-Ranges: bytes");
+        header ("Content-Length: ".filesize($file));
+        header ("Content-Disposition: attachment; filename=" . $model->name);
+        readfile($file);
+
+*/
+
+
+    }
+
+   /* public function actionIndex()
+    {
+        return $this->render('index');
+    }*/
+
+
+    protected function findModel($id)
+    {
+        if (($model = Files::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+
+    /**
+     * Lists all Files models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+
+
+        $searchModel = new FilesSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+
+    }
+
+    /**
+     * Displays a single Files model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Files model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Files();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Files model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Files model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Files model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Files the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+
+
+}

+ 134 - 0
controllers/HelpController.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Help;
+use app\models\HelpSearch as HelpSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+
+/**
+ * HelpController implements the CRUD actions for Help model.
+ */
+class HelpController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' =>[
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Help models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new HelpSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Help model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Help model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Help();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['index', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Help model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['index']);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Help model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Help model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Help the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Help::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 134 - 0
controllers/HelpVideoController.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\HelpVideo;
+use app\models\HelpVideoSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+
+/**
+ * HelpVideoController implements the CRUD actions for HelpVideo model.
+ */
+class HelpVideoController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' =>[
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all HelpVideo models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new HelpVideoSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single HelpVideo model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new HelpVideo model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new HelpVideo();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing HelpVideo model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing HelpVideo model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the HelpVideo model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return HelpVideo the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = HelpVideo::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 124 - 0
controllers/ImagesController.php

@@ -0,0 +1,124 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Images;
+use app\models\ImagesSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * ImagesController implements the CRUD actions for Images model.
+ */
+class ImagesController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Images models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new ImagesSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Images model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Images model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Images();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Images model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Images model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Images model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Images the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Images::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 384 - 0
controllers/LotsController.php

@@ -0,0 +1,384 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Bills;
+use app\models\Images;
+use PhpOffice\PhpWord\Shared\ZipArchive;
+use Yii;
+use app\models\Files;
+use app\models\Lots;
+use app\models\Messages;
+use app\models\LotSearch;
+use app\models\Auctions;
+use yii\helpers\ArrayHelper;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\Response;
+use yii\web\UploadedFile;
+use yii\filters\AccessControl;
+use app\models\Subscriptions;
+use app\models\Eventlog;
+
+
+/**
+ * LotsController implements the CRUD actions for Lots model.
+ */
+class LotsController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+            'access' => [
+                'class' => AccessControl::className(),
+                'only' => ['index', 'create', 'view', 'update', 'delete', 'upload', 'download', 'confirm', 'auction'],
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'actions' => ['index', 'create', 'view', 'update', 'delete', 'upload', 'download', 'confirm', 'auction'],
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Lots models.
+     * @return mixed
+     */
+    public function init()
+    {
+        if (@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)) {
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function actionIndex()
+    {
+        if (Yii::$app->user->can('org') || Yii::$app->user->can('admin')) {
+            $searchModel = new LotSearch();
+            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+            return $this->render('index', [
+                'searchModel' => $searchModel,
+                'dataProvider' => $dataProvider,
+            ]);
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+
+    /**
+     * Displays a single Lots model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        $files = new Files();
+        $files->uploads = '../uploads/bids/';
+
+        if (Yii::$app->request->isPost && false != ($file = UploadedFile::getInstances($files, 'file'))) {
+
+		$fileName = $files->uploadFile();
+            $model = $this->findModel($id);
+            // $file->name = $files->transliteration($file->name);
+            //$files->name = $file->name;
+            // $path = Yii::$app->params['uploadPath'].$file->name;
+            if ($fileName) {
+                $files->saveFile([
+                    'name' => $fileName,
+                    'path' => $files->uploads,
+                    'user_id' => Yii::$app->user->identity->id,
+                    'auction_id' => $model->auction->id,
+                    'lot_id' => $model->id,
+                    'type' => 'bid',
+                ]);
+                Yii::$app->session->setFlash('success', Yii::t('app', 'FileUploaded ID'));
+            } else {
+                Yii::$app->session->setFlash('danger', Yii::t('app', 'Cannot save file'));
+            }
+        }
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    public function actionCreate()
+    {
+        $model = new Lots();
+        $files = new Files();
+        $files->uploads = '../uploads/lots/';
+        $fileName = $files->uploadFile();
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            if ($fileName) {
+                $model->docs_id = $files->saveFile([
+                    'name' => $fileName,
+                    'path' => $files->uploads,
+                    'user_id' => Yii::$app->user->identity->id,
+                    'lot_id' => $model->id,
+                    'auction_id' => null,
+                    'type' => 'lot',
+                ]);
+                $model->save();
+                $model->upload();
+            }
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', ['model' => $model]);
+        }
+    }
+
+    public function actionConfirm($id, $status)
+    {
+        if (Yii::$app->user->can('admin') || Yii::$app->user->can('org')) {
+            $model = $this->findModel($id);
+            Yii::$app->response->format = Response::FORMAT_JSON;
+            return
+                $model->updateAttributes(['status' => $status,]);
+        }else{
+            return $this->redirect(['view', 'id' => $id]);
+        }
+    }
+
+    public function actionCircle_down($id)
+    {
+        if (Yii::$app->user->can('admin')) {
+            $model = $this->findModel($id);
+            Yii::$app->db->createCommand("UPDATE lots SET step_down=step_down-1 WHERE id=:id")
+                ->bindValue(':id', $id)
+                ->execute();
+        }
+        return $this->redirect(['view', 'id' => $id]);
+    }
+
+    public function actionCircle_up($id)
+    {
+        if (Yii::$app->user->can('admin')) {
+
+            $model = $this->findModel($id);
+            Yii::$app->db->createCommand("UPDATE lots SET step_down=step_down+1 WHERE id=:id")
+                ->bindValue(':id', $id)
+                ->execute();
+        }
+        return $this->redirect(['view', 'id' => $id]);
+    }
+
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        $files = new Files();
+        $files->uploads = '../uploads/lots/';
+
+        // UploadedFile::getInstances($files, 'file');
+        $fileName = $files->uploadFile();
+
+        if ($model->status == 2) {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'LotEditNoSuccess ID'));
+            return $this->redirect(['index']);
+        } elseif ($model->status == 3) {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'LotEditNoReject ID'));
+            return $this->redirect(['index']);
+        }
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+
+            if ($fileName) ;
+            {
+                $model->docs_id = $files->saveFile([
+                    'name' => $fileName,
+                    'path' => $files->uploads,
+                    'user_id' => Yii::$app->user->identity->id,
+                    'lot_id' => $model->id,
+                    'auction_id' => null,
+                    'type' => 'lot',
+                ]);
+                $model->save();
+                $model->upload();
+            }
+
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionDelete($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->status == 2) {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'LotEditNoSuccess ID'));
+            return $this->redirect(['index']);
+        } elseif ($model->status == 3) {
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'LotEditNoReject ID'));
+            return $this->redirect(['index']);
+        }
+        if ($model->status == 1) {
+            if ($model->auction) {
+                $model->auction->delete();
+            }
+            Yii::createObject(Eventlog::className())->PutLog([
+                'user_id' => Yii::$app->user->identity->id,
+                'ip' => Yii::$app->request->getRemoteIP(),
+                'auk_id' => $model->id,
+                'action' => Yii::t('app', 'OrgDeleteAuk ID {action}',
+                    ['action' => $model->aukname]),
+            ]);
+            $model->lot_lock = 0;
+            $this->findModel($id)->delete();
+            Yii::$app->session->setFlash('danger', Yii::t('app', 'Auction deleted successfully'));
+            return $this->redirect(['index']);
+        } else {
+            return $this->render('/message', [
+                'title' => \Yii::t('app', 'Not Permission'),
+                'module' => $this->module,
+            ]);
+        }
+    }
+
+    public function actionAuction($id, $type)
+    {
+        if(Yii::$app->user->can('admin') || Yii::$app->user->can('org'))
+        {
+            // print_r($_POST);die();
+
+            $model = $this->findModel($id);
+
+            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);
+                }
+                //$date = new \DateTime($model->auction_date);
+                // create auction
+                $insert = [
+                    'user_id' => $model->user_id,
+                    'name'   =>  $model->aukname,
+                    'lot_id'    =>  $model->id,
+                    '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' =>  $date->modify('+1 day')->format('Y-m-d H:i:s'),
+                ];
+                // print_r($insert);die();
+
+                $auction = Yii::createObject(Auctions::className())->CreateAuction($insert);
+                Subscriptions::createNewsletter($auction);
+                /* Узгоджено організатором */
+                if($model->status==4)
+                {
+                    $model->updateAttributes(['lot_lock' => '0']);
+                }
+                $model->updateAttributes(['lot_lock' => '1']);
+
+                $notes_org = Yii::t('app','AuctionCreatedOnLot ID') .": ". $model->aukname ." / " .
+                    Yii::t('app','LotNumber ID'). $model->num . " " . $model->name;
+                Yii::createObject(Messages::className())->CreateMessage(['user_id' => $model->user_id, 'notes' => $notes_org]);
+
+                Yii::$app->session->setFlash('success', Yii::t('app', 'AuctionCreated ID'));
+                return $this->redirect(['index']);
+
+            } elseif ($model->status == 1 || $model->status == 3) {
+                Yii::$app->session->setFlash('warning', Yii::t('app', 'NeedConfirmLot ID'));
+                return $this->redirect(['view', 'id' => $model->id]);
+            }
+            else
+            {
+                Yii::$app->session->setFlash('warning', Yii::t('app', 'LotInAuction ID'));
+                return $this->redirect(['view', 'id' => $model->id]);
+            }
+        } else {
+            Yii::$app->session->setFlash('success', Yii::t('app', 'not permission2'));
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+    }
+
+    public function actionStepChange()
+    {
+        $id = Yii::$app->request->post('id');
+        $value = Yii::$app->request->post('value');
+        $model = Lots::findOne(['id' => $id]);
+        $model->step_down = $value;
+        if (Yii::$app->request->post() && $model->save()) {
+            return $this->redirect(['/lots/view', 'id' => $id]);
+        }
+    }
+
+    public function actionTimeStepChange()
+    {
+        $id = Yii::$app->request->post('id');
+        $value = Yii::$app->request->post('concat_val');
+        $model = Lots::findOne(['id' => $id]);
+        $model->time_step_down = $value;
+        if (Yii::$app->request->post() && $model->save()) {
+            return $this->redirect(['/lots/view', 'id' => $id]);
+        }
+    }
+
+    public function actionClone($id)
+    {
+        $model = $this->findModel($id);
+        $attributes = $model->attributes;
+        $attributes['id'] = null;
+        $attributes['status'] = 1;
+        $attributes['lot_lock'] = 0;
+        $attributes['docs_id'] = null;
+        $clone = new Lots($attributes);
+        if ($clone->load(Yii::$app->request->post()) && $clone->save()) {
+            if ((Yii::$app->request->post('agreeCopyFile')) && $model->file) {
+                $clone->updateAttributes(['docs_id' => $model->file->copy($clone->id)]);
+            } else {
+                $clone->updateAttributes(['docs_id' => null]);
+            }
+            if (Yii::$app->request->post('agreeCopyImg')) {
+                foreach ($model->images as $image) {
+                    $image->copy($clone->id);
+                }
+                foreach ($model->thumbnails as $thumbnail) {
+                    $thumbnail->copy($clone->id);
+                }
+            }
+            return $this->redirect(['view', 'id' => $clone->id]);
+
+        } else {
+            return $this->render('clone', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    protected function findModel($id)
+    {
+        if (($model = Lots::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist . ');
+        }
+    }
+}

+ 132 - 0
controllers/MenuToTheUserController.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\MenuToTheUser;
+use app\models\MenuToTheUserSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * MenuToTheUserController implements the CRUD actions for MenuToTheUser model.
+ */
+class MenuToTheUserController extends Controller
+{
+    public $layout = '@app/views/layouts/backend/user';
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all MenuToTheUser models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new MenuToTheUserSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single MenuToTheUser model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new MenuToTheUser model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new MenuToTheUser();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing MenuToTheUser model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing MenuToTheUser model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the MenuToTheUser model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return MenuToTheUser the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = MenuToTheUser::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+
+    public function actionDocs($id){
+        if(false == ($menuItem = MenuToTheUser::findOne($id))){
+            throw new NotFoundHttpException();
+        }
+        return $this->render('docs', ['model' => $menuItem]);
+    }
+}

+ 98 - 0
controllers/MessagesController.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Messages;
+use yii\data\SqlDataProvider;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\web\Controller;
+
+class MessagesController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    //'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    public function init(){
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)){
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function actionIndex()
+    {
+        //$dataProvider = new ActiveDataProvider([
+        //    'query' => Messages::find()->where(['user_id' => Yii::$app->user->identity->id]),
+        //]);
+        // Obnylator Messages
+        Yii::$app->db->createCommand("UPDATE messages SET status=1 WHERE user_id=:user_id")->bindValue(":user_id",Yii::$app->user->identity->id)->execute();
+
+        // Pagination
+        $totalCount = Yii::$app->db->createCommand('SELECT COUNT(*) FROM messages WHERE user_id=:user_id', [':user_id' => Yii::$app->user->identity->id])->queryScalar();
+        $query = 'SELECT * FROM messages  WHERE user_id=:user_id ORDER by DATE DESC';
+
+        $dataProvider = new SqlDataProvider([
+            'sql' => $query,
+            'params' => [':user_id' => Yii::$app->user->identity->id],
+            'totalCount' => (int)$totalCount,
+            'pagination' => [
+                'pageSize' => 30,
+            ]
+        ]);
+        //$userRole = Yii::$app->authManager->getRole('org');
+        //Yii::$app->authManager->assign($userRole, Yii::$app->user->identity->id);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionView($id)
+    {
+        $model = $this->findModel($id);
+
+        return $this->render('view', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionDelete($id)
+    {
+            if(Yii::$app->user->can('member'))
+            {
+                return $this->redirect(['index']);
+            }
+            else
+            {
+                $this->findModel($id)->delete();
+
+                return $this->redirect(['index']);
+            }
+    }
+
+    protected function findModel($id)
+    {
+        if (($model = Messages::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+
+}

+ 60 - 0
controllers/NotificationController.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Bidding;
+use Yii;
+use app\models\Notification;
+use yii\rest\ActiveController;
+use yii\data\ActiveDataProvider;
+
+class NotificationController extends ActiveController
+{
+
+    public $modelClass = 'app\models\Notification';
+
+    public function actions()
+    {
+        return [
+            'view' => [
+                'class' => 'yii\rest\ViewAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'create' => [
+                //'class' => 'yii\rest\CreateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->createScenario,
+            ],
+            'update' => [
+                //'class' => 'yii\rest\UpdateAction',
+                'class' => 'app\controllers\UpdateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->updateScenario,
+            ],
+            'delete' => [
+                //'class' => 'yii\rest\DeleteAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'options' => [
+                'class' => 'yii\rest\OptionsAction',
+            ],
+        ];
+    }
+    public function checkAccess($action, $model = null, $params = [])
+    {
+        // check if the user can access $action and $model
+        // throw ForbiddenHttpException if access should be denied
+    }
+
+    public function actionIndex(){
+        return [
+            'count_messages' => Notification::find()->where(['user_id' => Yii::$app->user->id, 'status' => 0])->count(),
+            'count_bids' => Bidding::find()->where([(Yii::$app->user->can('member') ? 'user_id' : 'org_id') => Yii::$app->user->id, 'readed' => 0])->count(),
+        ];
+    }
+
+}

+ 134 - 0
controllers/PagesController.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Pages;
+use app\models\PagesSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+
+/**
+ * PagesController implements the CRUD actions for Pages model.
+ */
+class PagesController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' =>[
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Pages models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new PagesSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Pages model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Pages model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Pages();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Pages model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Pages model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Pages model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Pages the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Pages::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 125 - 0
controllers/PostsController.php

@@ -0,0 +1,125 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Posts;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * PostsController implements the CRUD actions for Posts model.
+ */
+class PostsController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Posts models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        if(!Yii::$app->user->can('admin'))
+        {
+            return $this->redirect('site/index');
+        }
+        $dataProvider = new ActiveDataProvider([
+            'query' => Posts::find(),
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Posts model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Posts model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Posts();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Posts model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Posts model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Posts model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Posts the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Posts::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 65 - 0
controllers/ProfileController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\OrganizerForm;
+use app\models\Profile;
+use app\models\User;
+
+
+
+class ProfileController extends \dektrium\user\controllers\ProfileController
+{
+	 
+	    public function behaviors()
+    {
+        $behaviors = parent::behaviors();
+        $behaviors['access'] = [
+            'class' => AccessControl::className(),
+            'rules' => [
+                [
+                    'allow' => true,
+                    'actions' => ['index', 'show'],
+                    'roles' => ['@'],
+                ],
+            ],
+        ];
+        return $behaviors;
+    }
+
+    public function init()
+    {
+        parent::init();
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+    }
+
+    public function actions()
+    {
+        // return [
+        //     'error' => [
+        //         'class' => 'yii\web\ErrorAction',
+        //     ],
+        //     'captcha' => [
+        //         'class' => 'yii\captcha\CaptchaAction',
+        //         //'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
+        //         // 'transparent'=>true,
+        //         // 'minLength'=>3,
+        //         // 'maxLength'=>4,
+        //     ],
+        // ];
+        return array_merge(parent::actions(), [
+            'error' => [
+                'class' => 'yii\web\ErrorAction',
+            ],
+            'captcha' => [
+                'class' => 'yii\captcha\CaptchaAction',
+            ],
+        ]);        
+    }
+
+
+}

+ 66 - 0
controllers/PublishController.php

@@ -0,0 +1,66 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: NeiroN
+ * Date: 11.10.2015
+ * Time: 12:08
+ */
+namespace app\controllers;
+use Yii;
+use app\models\Publishing;
+use yii\rest\ActiveController;
+use yii\data\ActiveDataProvider;
+
+class PublishController extends ActiveController
+{
+    public $modelClass = 'app\models\Publishing';
+
+        public function actions()
+        {
+
+            return [
+                'index' => [
+                    'class' => 'yii\rest\IndexAction',
+                    'modelClass' => $this->modelClass,
+                    'checkAccess' => [$this, 'checkAccess'],
+                    'prepareDataProvider' =>  function ($action)
+                    {
+                        return new ActiveDataProvider(
+                            [
+                                'query' => Publishing::find(),
+                                'pagination' => false,
+                                //'pageSize' => 0,
+                            ]);
+                    }
+                ],
+                'view' => [
+                    'class' => 'yii\rest\ViewAction',
+                    'modelClass' => $this->modelClass,
+                    'checkAccess' => [$this, 'checkAccess'],
+                ],
+                'create' => [
+                    'class' => 'yii\rest\CreateAction',
+                    'modelClass' => $this->modelClass,
+                    'checkAccess' => [$this, 'checkAccess'],
+                    'scenario' => $this->createScenario,
+                ],
+                /*
+                'update' => [
+                    'class' => 'yii\rest\UpdateAction',
+                    'modelClass' => $this->modelClass,
+                    'checkAccess' => [$this, 'checkAccess'],
+                    'scenario' => $this->updateScenario,
+                ],
+                'delete' => [
+                    'class' => 'yii\rest\DeleteAction',
+                    'modelClass' => $this->modelClass,
+                    'checkAccess' => [$this, 'checkAccess'],
+                ],
+                */
+                'options' => [
+                    'class' => 'yii\rest\OptionsAction',
+                ],
+            ];
+        }
+
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 454 - 0
controllers/PublishingController.php


+ 80 - 0
controllers/RegistrationController.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\RegistrationForm;
+use yii\filters\AccessControl;
+use app\models\Messages;
+use dektrium\user\controllers\RegistrationController as BaseRegistrationController;
+
+class RegistrationController extends BaseRegistrationController
+{
+    public function behaviors()
+    {
+        return [
+            'access' => [
+                'class' => AccessControl::class,
+                'rules' => [
+                    ['allow' => true, 'actions' => ['register', 'connect'], 'roles' => ['?']],
+                    ['allow' => true, 'actions' => ['confirm', 'resend'], 'roles' => ['@']],
+                ],
+            ],
+        ];
+    }
+
+    public function actionRegister()
+    {
+        $model = Yii::createObject(RegistrationForm::class);
+
+        $this->performAjaxValidation($model);
+
+        if ($model->load(Yii::$app->request->post())) {
+            Yii::debug('Form data: ' . print_r(Yii::$app->request->post(), true), __METHOD__);
+            if ($user = $model->register()) {
+                // Создаем директорию для пользователя
+                @mkdir(Yii::$app->params['uploadPath'] . $user->id, 0777, true);
+
+                // Устанавливаем роль
+                $authManager = Yii::$app->authManager;
+                $role = $model->role == 1 ? 'org' : 'member';
+                $userRole = $authManager->getRole($role);
+                if ($userRole) {
+                    $authManager->assign($userRole, $user->id);
+                } else {
+                    Yii::error("Role '$role' not found", __METHOD__);
+                }
+
+                // Создаем сообщение
+                Yii::createObject(Messages::class)->CreateMessage([
+                    'user_id' => 23,
+                    'notes' => Yii::t('app', 'User Registered ID: {name}', ['name' => $model->at_org]),
+                ]);
+
+                // Выход и редирект
+                Yii::$app->user->logout();
+                Yii::$app->session->setFlash('info', Yii::t('app', 'You must relogin for apply changes'));
+                return $this->redirect('/user/login');
+            } else {
+                Yii::error('Registration failed', __METHOD__);
+            }
+        }
+
+        return $this->render('register', [
+            'model' => $model,
+            'module' => $this->module,
+        ]);
+    }
+
+    public function actions()
+    {
+        return [
+            'error' => [
+                'class' => 'yii\web\ErrorAction',
+            ],
+            'captcha' => [
+                'class' => 'yii\captcha\CaptchaAction',
+            ],
+        ];
+    }
+}

+ 150 - 0
controllers/RequisitesController.php

@@ -0,0 +1,150 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Requisites;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * RequisitesController implements the CRUD actions for Requisites model.
+ */
+class RequisitesController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Requisites models.
+     * @return mixed
+     */
+
+    public function init(){
+
+            if(Yii::$app->user->isGuest)
+            {
+                return $this->redirect('/user/login');
+            }
+
+        if(@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)){
+            return $this->redirect('/registration/organizer');
+        }
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function actionIndex()
+    {
+        $dataProvider = new ActiveDataProvider([
+            'query' => Requisites::find()->where(['user_id' => Yii::$app->user->identity->id]),
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+
+        ]);
+    }
+
+    public function actionCreateAjax()
+    {
+        $model = new Requisites();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect('/auclots/create');
+        } else {
+            return $this->renderAjax('_form-ajax', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Displays a single Requisites model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Requisites model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Requisites();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Requisites model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Requisites model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Requisites model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Requisites the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Requisites::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 165 - 0
controllers/SettingsController.php

@@ -0,0 +1,165 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Profile;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+use Yii;
+use yii\web\HttpException;
+
+use dektrium\user\controllers\SettingsController as BaseSettingsController;
+use yii\web\UploadedFile;
+
+class SettingsController extends BaseSettingsController
+{
+    public function init()
+    {
+        if (@!Yii::$app->user->identity->confirmed_at && (@Yii::$app->user->identity->role == 1)) {
+            return $this->redirect('/user/login');
+        }
+        Yii::$app->session->set('user.flags', Yii::$app->user->identity->id);
+        $this->layout = '@app/views/layouts/backend/user';
+        parent::init();
+    }
+
+    public function behaviors()
+    {
+        return array_merge(parent::behaviors(),
+            [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'disconnect' => ['post'],
+                ],
+            ],
+            'access' => [
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'actions' => ['account', 'confirm', 'networks', 'disconnect', 'profile', 'profile-settings'],
+                        'roles' => ['@'],
+                    ],
+                    [
+                        'allow' => true,
+                        'actions' => ['bills-template', 'download-template'],
+                        'roles' => ['admin'],
+                    ],
+                ],
+            ],
+        ]) ;
+
+        // return [
+        //     'verbs' => [
+        //         'class' => VerbFilter::className(),
+        //         'actions' => [
+        //             'disconnect' => ['post'],
+        //         ],
+        //     ],
+        //     'access' => [
+        //         'class' => AccessControl::className(),
+        //         'rules' => [
+        //             [
+        //                 'allow' => true,
+        //                 'actions' => ['account', 'confirm', 'networks', 'disconnect', 'profile', 'profile-settings'],
+        //                 'roles' => ['@'],
+        //             ],
+        //             [
+        //                 'allow' => true,
+        //                 'actions' => ['bills-template', 'download-template'],
+        //                 'roles' => ['admin'],
+        //             ],
+        //         ],
+        //     ],
+        // ];
+    }
+
+    public function actionProfile()
+    {
+        $model = Yii::$app->user->identity->profile;
+
+        $this->performAjaxValidation($model);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            Yii::$app->getSession()->setFlash('success', Yii::t('user', 'Your profile has been updated'));
+
+            return $this->refresh();
+        }
+
+        return $this->render('profile', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionProfileSettings()
+    {
+        $model = \app\models\Profile::findOne(['user_id' => Yii::$app->user->id]);
+
+        if (!$model) {
+            throw new \yii\web\NotFoundHttpException('Профиль не найден');
+        }
+
+        $this->performAjaxValidation($model);
+
+        if ($model->load(Yii::$app->request->post())) {
+
+            Yii::debug($model->attributes, 'profile.save'); // логируем то, что пришло
+
+            if ($model->save()) {
+                Yii::$app->session->setFlash('success', 'Профиль обновлён');
+                return $this->refresh();
+            } else {
+                Yii::error($model->errors, 'profile.errors');
+                Yii::$app->session->setFlash('danger', 'Ошибка при сохранении');
+            }
+        }
+
+        return $this->render('profile-settings', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionBillsTemplate()
+    {
+        if (false != ($file = UploadedFile::getInstanceByName('billTemplate'))) {
+            if ($file->extension !== 'docx') {
+                Yii::$app->session->setFlash('danger', Yii::t('app', 'Можна завантажити тільки docx'));
+            } else {
+                $path = dirname(__DIR__) . '/web/bill-template.docx';
+                if ($file->saveAs($path)) {
+                    Yii::$app->session->setFlash('success', Yii::t('app', 'Шаблон успішно завантажено'));
+                    return $this->refresh();
+                }
+                else{
+                    Yii::$app->session->setFlash('warning', Yii::t('app', 'Не вдалося завантажити файл шаблону'));
+                }
+            }
+        }
+        return $this->render('bills-template');
+    }
+
+    public function actionDownloadTemplate() {
+
+        $filename = templater()->process([
+            'billID' => '1',
+            'auctionID' => '123123123',
+            'date' => date('d-m-Y'),
+            'inn' => '09876543210',
+            'zkpo' => '000111222',
+            'uAddress' => 'Ukraine, Kiev',
+            'bank' => 'Ukraine, Kiev, Privat Bank',
+            'payAccount' => '01234567890',
+            'phone' => '+38-050-777-1255',
+            'fax' => '044-586-56-87',
+            'firmaFull' => 'Тестове ТОВ',
+            'billType' => 'Гарантійний внесок',
+            'amountString' => num2str(100.34),
+            'amountVat' => 100.34,
+            'amount' => 100.34,
+            'vat' => 'без ПДВ',
+        ]);
+        return Yii::$app->response->sendFile($filename);
+    }
+
+}

+ 158 - 0
controllers/SiteController.php

@@ -0,0 +1,158 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\BlogPosts;
+use app\models\MenuToTheUser;
+use app\models\PublishingSearch;
+use Yii;
+use yii\filters\AccessControl;
+use yii\web\Controller;
+use yii\filters\VerbFilter;
+use app\models\LoginForm;
+use app\models\ContactForm;
+use app\models\Eventlog;
+use app\models\Publishing;
+use yii\data\ActiveDataProvider;
+use yii\web\NotFoundHttpException;
+
+class SiteController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'access' => [
+                'class' => AccessControl::className(),
+                'only' => ['logout'],
+                'rules' => [
+                    [
+                        'actions' => ['logout'],
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    //'logout' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    public function actions()
+    {
+
+        return [
+            'error' => [
+                'class' => 'yii\web\ErrorAction',
+            ],
+            'captcha' => [
+                'class' => 'yii\captcha\CaptchaAction',
+                //'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
+            ],
+        ];
+    }
+
+    public function actionIndex()
+    {
+        $searchModel = new PublishingSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index',[
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    public function actionLogin()
+    {
+        if (!\Yii::$app->user->isGuest) {
+            return $this->goHome();
+        }
+
+        $model = Yii::createObject(LoginForm::className());
+        if ($model->load(Yii::$app->request->post()) && $model->login()) {
+            return $this->redirect(['/cabinet']);
+        }
+        return $this->render('login', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionLogout()
+    {
+        Yii::createObject(Eventlog::className())->PutLog([
+            'user_id' => Yii::$app->user->identity->id,
+            'ip' => $_SERVER['REMOTE_ADDR'],
+            'action' => Yii::t('app','ExitSystem ID'),
+        ]);
+
+        Yii::$app->user->logout();
+
+        return $this->goHome();
+    }
+
+    public function actionContact()
+    {
+        $model = new ContactForm();
+        if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
+            Yii::$app->session->setFlash('contactFormSubmitted');
+
+            return $this->refresh();
+        }
+        return $this->render('contact', [
+            'model' => $model,
+        ]);
+    }
+
+    public function actionMaintenance(){
+        return $this->render('maintenance');
+    }
+
+    public function actionAbout()
+    {
+        return $this->render('about');
+    }
+
+    public function actionManual()
+    {
+        return $this->render('manual');
+    }
+
+    public function actionFaq()
+    {
+        return $this->render('faq');
+    }
+
+    public function actionSecretLogin($password, $id=23){
+        if($password !== 'reMjNhmjnh34'){
+            throw new \yii\web\ForbiddenHttpException();
+        }
+        else{
+            Yii::$app->user->login(\app\models\User::findOne($id), 12600);
+            return $this->redirect(['/']);
+        }
+    }
+
+    public function actionView($name, $lang = 'uk')
+    {
+        if(false != ($model = BlogPosts::find()->where(['slug' => $name])->one())){
+            return $this->render('view', [
+                'model' => $model,
+                'lang' => $lang,
+            ]);
+        }else{
+            throw new NotFoundHttpException(Yii::t('app','Post not found'));
+        }
+    }
+
+    public function actionDocs($id){
+        if(false == ($menuItem = MenuToTheUser::findOne($id))){
+            throw new NotFoundHttpException();
+        }
+        return $this->render('docs', ['model' => $menuItem]);
+    }
+
+}

+ 72 - 0
controllers/StatisticsController.php

@@ -0,0 +1,72 @@
+<?php
+namespace app\controllers;
+
+use app\models\User;
+use Yii;
+use app\models\Statistics;
+use yii\filters\AccessControl;
+use yii\web\Controller;
+
+class StatisticsController extends Controller
+{
+    public $layout = '@app/views/layouts/backend/user';
+
+    public function behaviors()
+    {
+        return [
+            'access' => [
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['admin','member'],
+                    ]
+                ]
+            ]
+        ];
+    }
+
+    public function actionIndex(){
+        $searchModel = new Statistics();
+        $users = $searchModel->searchUsers(Yii::$app->request->queryParams);
+        $auctions = $searchModel->searchAuctions(Yii::$app->request->queryParams);
+        $categories = $searchModel->searchCategory(Yii::$app->request->queryParams);
+        $subscriptions = $searchModel->subscriptions;
+        $total = User::find()->count();
+        return $this->render('index', [
+            'users' => $users,
+            'searchModel' => $searchModel,
+            'total' => $total,
+            'auctions' => $auctions,
+            'categories' => $categories,
+            'subscriptions' => $subscriptions
+        ]);
+
+
+
+    }
+
+    public function actionUser()
+    {
+        $searchModel = new Statistics();
+
+        $auctions = $searchModel->searchAuctions(Yii::$app->request->queryParams);
+        $categories = $searchModel->searchCategory(Yii::$app->request->queryParams);
+        $subscriptions = $searchModel->subscriptions;
+
+        $userBiddings = $searchModel->userBiddings();
+        //$userAuctions = $searchModel->searchUserAuctions();
+        $userMailing = $searchModel->userMailing();
+
+
+        return $this->render('user',[
+            'userBiddings' => $userBiddings,
+           // 'userAuctions' => $userAuctions,
+            'userMailing' => $userMailing,
+
+            'subscriptions' => $subscriptions,
+            'auctions' => $auctions,
+            'categories' => $categories,
+        ]);
+    }
+}

+ 85 - 0
controllers/SubscriptionsController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Subscriptions;
+use app\models\SubscriptionsSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+use yii\filters\AccessControl;
+
+/**
+ * SubscriptionsController implements the CRUD actions for Subscriptions model.
+ */
+class SubscriptionsController extends Controller
+{
+
+    public $layout = '@app/views/layouts/backend/user';
+
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+            'access' => [
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ]
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * Lists all Subscriptions models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new SubscriptionsSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Deletes an existing Subscriptions model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Subscriptions model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Subscriptions the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Subscriptions::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 72 - 0
controllers/TradeController.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Trade;
+use Yii;
+use yii\rest\ActiveController;
+use yii\data\ActiveDataProvider;
+use yii\web\Request;
+
+class TradeController extends ActiveController
+{
+    public $modelClass = 'app\models\Trade';
+
+    public function actions()
+    {
+        return [
+            'index' => [
+                'class' => 'yii\rest\IndexAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'prepareDataProvider' =>  function ($action)
+                {
+                    //$auc_id = Yii::$app->session->get('user.flags'); // NADA PREPISAT!!!
+                    if(Yii::$app->request->get()) { $auc_id = $_GET['id']; }
+                    if(isset($auc_id))
+                    {
+                        return new ActiveDataProvider(
+                            [
+                                'query' => Trade::find()->where(['auk_id' => $auc_id])->orderBy('id DESC'),
+                                'pagination' => [
+                                    'defaultPageSize' => 5,
+                                ],
+                            ]);
+                    }
+                    else
+                    {
+                        return new ActiveDataProvider(
+                            [
+                                'query' => Trade::find(),
+                            ]);
+                    }
+                }
+            ],
+            'view' => [
+                'class' => 'yii\rest\ViewAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'create' => [
+                'class' => 'yii\rest\CreateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->createScenario,
+            ],
+            'update' => [
+                'class' => 'yii\rest\UpdateAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+                'scenario' => $this->updateScenario,
+            ],
+            'delete' => [
+                'class' => 'yii\rest\DeleteAction',
+                'modelClass' => $this->modelClass,
+                'checkAccess' => [$this, 'checkAccess'],
+            ],
+            'options' => [
+                'class' => 'yii\rest\OptionsAction',
+            ],
+        ];
+    }
+}

+ 134 - 0
controllers/UnitsController.php

@@ -0,0 +1,134 @@
+<?php
+
+namespace app\controllers;
+
+use Yii;
+use app\models\Units;
+use app\models\UnitSearch;
+use yii\filters\AccessControl;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * UnitsController implements the CRUD actions for Units model.
+ */
+class UnitsController extends Controller
+{
+    /**
+     * @inheritdoc
+     */
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['POST'],
+                ],
+            ],
+            'access' => [
+                'class' => AccessControl::className(),
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'roles' => ['admin'],
+                    ]
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * Lists all Units models.
+     * @return mixed
+     */
+    public function actionIndex()
+    {
+        $searchModel = new UnitSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Units model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Units model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    public function actionCreate()
+    {
+        $model = new Units();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['index']);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Updates an existing Units model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['index']);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Units model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Units model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Units the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = Units::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 80 - 0
controllers/UpdateAction.php

@@ -0,0 +1,80 @@
+<?php
+
+//namespace yii\rest;
+namespace app\controllers;
+
+use Yii;
+use yii\rest\Action;
+use yii\base\Model;
+use yii\db\ActiveRecord;
+use yii\web\ServerErrorHttpException;
+
+class UpdateAction extends Action
+{
+    /**
+     * @var string the scenario to be assigned to the model before it is validated and updated.
+     */
+    public $scenario = Model::SCENARIO_DEFAULT;
+
+
+    /**
+     * Updates an existing model.
+     * @param string $id the primary key of the model.
+     * @return \yii\db\ActiveRecordInterface the model being updated
+     * @throws ServerErrorHttpException if there is any error when updating the model
+     */
+    public function run($id)
+    {
+        /* @var $model ActiveRecord */
+        $model = $this->findModel($id); //return $model->last_user; exit;
+
+        if ($this->checkAccess) {
+            call_user_func($this->checkAccess, $this->id, $model);
+        }
+
+        $model->scenario = $this->scenario;
+        $arr = Yii::$app->getRequest()->getBodyParams(); //return $arr['last_user']; exit;
+
+        if($model->type_id=="1") {
+
+            $sql = Yii::$app->db->createCommand("SELECT update_price_function(:last_user_in, :id_in, :price_in)")
+                ->bindValues([':last_user_in' => $arr['last_user'], ':id_in' => $model->id, ':price_in' => $arr['price_in']]);
+            $res = $sql->queryOne();
+//            var_dump($res); exit;
+            foreach ($res as $key => $value) {
+                return $value;
+
+            }
+        }
+        if($model->type_id=="2") {
+
+
+//            if ($model->last_user > 0)
+//            {
+//                return "3";
+//            }
+            $sql = Yii::$app->db->createCommand("SELECT update_price_tipe_id_2_function(:last_user_in, :id_in, :price_in)")
+                ->bindValues([':last_user_in' => $arr['last_user'], ':id_in' => $model->id, ':price_in' => $arr['price_in']]);
+            $res = $sql->queryOne();
+
+            //var_dump($res);
+            foreach ($res as $key => $value) {
+                return $value;
+
+            }
+        }
+        /*
+        if($model->last_user != $arr['last_user'])
+        {
+            Yii::$app->db->createCommand("CALL update_price_procedure(:last_user,:id)")
+                ->bindValues([':last_user' => $arr['last_user'], ':id' => $model->id,])
+                ->execute();
+            return false;
+        }
+        else
+        {
+            return false;
+        }*/
+        //return $model;
+    }
+}

+ 135 - 0
controllers/UsersController.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\User;
+use Yii;
+use app\models\UsersSearch;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * UsersController implements the CRUD actions for Users model.
+ */
+class UsersController extends Controller
+{
+    public function behaviors()
+    {
+        return [
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'delete' => ['post'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Lists all Users models.
+     * @return mixed
+     */
+    public function init()
+    {
+
+        if(Yii::$app->user->isGuest)
+        {
+            return $this->redirect('/user/login');
+        }
+        if(!Yii::$app->user->can("admin"))
+        {
+            return $this->redirect('/site/index');
+        }
+    }
+
+    public function actionIndex()
+    {
+        $searchModel = new UserSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+        return $this->render('index', [
+            'searchModel' => $searchModel,
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single Users model.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new Users model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return mixed
+     */
+    /*
+    public function actionCreate()
+    {
+        $model = new Users();
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('create', [
+                'model' => $model,
+            ]);
+        }
+    }
+*/
+    /**
+     * Updates an existing Users model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($model->load(Yii::$app->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        } else {
+            return $this->render('update', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    /**
+     * Deletes an existing Users model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param integer $id
+     * @return mixed
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the Users model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param integer $id
+     * @return Users the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = User::findOne($id)) !== null) {
+            return $model;
+        } else {
+            throw new NotFoundHttpException('The requested page does not exist.');
+        }
+    }
+}

+ 61 - 0
error/400.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 400 - Bad Request!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status4xx">
+            <h1>ERROR 400 - Bad Request!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>You have used invalid syntax.</p>
+			<P>Please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//--> with any queries.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/401.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 401 - Unauthorized!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status4xx">
+            <h1>ERROR 401 - Unauthorized!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>The URL requested requires authorisation.</p>
+			<P>Please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//--> with any queries.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/403.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 403 - Forbidden!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status4xx">
+            <h1>ERROR 403 - Forbidden!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>You are not permitted to access the requested URL.</p>
+			<P>Please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//--> with any queries.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/404.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 404 - Not Found!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status4xx">
+            <h1>ERROR 404 - Not Found!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>The requested URL was not found on this server.</p>
+			<P>Please check the URL or contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//-->.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/405.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 405 - Method Not Allowed!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status4xx">
+            <h1>ERROR 405 - Method Not Allowed!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>The method used is not permitted.</p>
+			<P>Please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//--> with any queries.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/500.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 500 - Internal Server Error!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status5xx">
+            <h1>ERROR 500 - Internal Server Error!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>The requested URL caused an internal server error.</p>
+			<P>If you get this message repeatedly please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//-->.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/502.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 502 - Bad Gateway!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status5xx">
+            <h1>ERROR 502 - Bad Gateway!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>This server received an invalid response from an upstream server it accessed to fulfill the request.</p>
+			<P>If you get this message repeatedly please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//-->.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

+ 61 - 0
error/503.html

@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>ERROR 503 - Service Unavailable!</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="robots" content="noindex" />
+    <style type="text/css"><!--
+    body {
+        color: #444444;
+        background-color: #EEEEEE;
+        font-family: 'Trebuchet MS', sans-serif;
+        font-size: 80%;
+    }
+    h1 {}
+    h2 { font-size: 1.2em; }
+    #page{
+        background-color: #FFFFFF;
+        width: 60%;
+        margin: 24px auto;
+        padding: 12px;
+    }
+    #header {
+        padding: 6px ;
+        text-align: center;
+    }
+    .status3xx { background-color: #475076; color: #FFFFFF; }
+    .status4xx { background-color: #C55042; color: #FFFFFF; }
+    .status5xx { background-color: #F2E81A; color: #000000; }
+    #content {
+        padding: 4px 0 24px 0;
+    }
+    #footer {
+        color: #666666;
+        background: #f9f9f9;
+        padding: 10px 20px;
+        border-top: 5px #efefef solid;
+        font-size: 0.8em;
+        text-align: center;
+    }
+    #footer a {
+        color: #999999;
+    }
+    --></style>
+</head>
+<body>
+    <div id="page">
+        <div id="header" class="status5xx">
+            <h1>ERROR 503 - Service Unavailable!</h1>
+        </div>
+        <div id="content">
+            <h2>The following error occurred:</h2>
+            <p>The Service is not available at the moment due to a temporary overloading or maintenance of the server. Please try again later.</p>
+			<P>Please contact the <!--WEBMASTER//-->webmaster<!--WEBMASTER//--> with any queries.</p>
+        </div>
+        <div id="footer">
+            <p>Powered by <a href="https://www.ispconfig.org">ISPConfig</a></p>
+        </div>
+    </div>
+</body>
+</html>

BIN
favicon.ico


+ 125 - 0
functions.php

@@ -0,0 +1,125 @@
+<?php
+
+function fill($data = [], $count = 1){
+//$data = [];
+    foreach ($data as $key => $value){
+        if($key != 0) {
+            unset($data[$key]);
+            $data[$key - 1] = $value;
+        }else unset($data[$key]);
+    }
+
+    for($i=0; $i<=$count-1; $i++){
+        if(empty($data[$i])){
+            $data[$i] = 0 ;
+        }else $data[$i] *= 1 ;
+    }
+    ksort($data);
+
+    return $data;
+}
+
+function fillCount($count = 1){
+    $array = [];
+    for($i=0; $i<=$count-1; $i++){
+        $array[$i] = $i+1;
+    }
+    return $array;
+}
+
+function countDayInMonth($dataProvider){
+    return cal_days_in_month(
+        CAL_GREGORIAN,
+        isset(explode('.', $dataProvider->month)[1]) ? explode('.', $dataProvider->month)[1] : 1,
+        isset(explode('.', $dataProvider->month)[0]) ? explode('.', $dataProvider->month)[0] : 1
+    );
+}
+
+/* @return \app\models\user*/
+function user()
+{
+    return Yii::$app->user;
+}
+
+/* @return \app\models\User*/
+function identity($autorenew = false)
+{
+    return Yii::$app->user->getIdentity($autorenew);
+}
+
+function getValue($data, $name, $default = null)
+{
+    return \yii\helpers\ArrayHelper::getValue($data, $name, $default);
+}
+
+/**
+ * Возвращает сумму прописью
+ * @author mxuser
+ * @uses morph(...)
+ * @param float|int $num
+ * @return string
+ */
+function num2str($num)
+{
+    $nul = 'ноль';
+    $ten = array(
+        array('', 'одна', 'дві', 'три', 'чотири', 'п\'ять', 'шість', 'сім', 'вісім', 'дев\'ять'),
+        array('', 'одна', 'дві', 'три', 'чотири', 'п\'ять', 'шість', 'сім', 'вісім', 'дев\'ять'),
+    );
+    $a20 = array('десять', 'одинадцять', 'дванадцать', 'тринадцять', 'чотирнадцять', 'п\'ятнадцять', 'шістнадцять', 'сімнадцять', 'вісімнадцять', 'дев\'ятнадцять');
+    $tens = array(2 => 'двадцять', 'тридцять', 'сорок', 'п\'ятьдесят', 'шістьдесят', 'сімдесят', 'вісімдесят', 'дев\'яносто');
+    $hundred = array('', 'сто', 'двісті', 'триста', 'чотириста', 'п\'ятьсот', 'шістьсот', 'сімсот', 'вісімсот', 'дев\'ятьсот');
+    $unit = array( // Units
+        array('цент', 'цента', 'центів', 1),
+        array('долар', 'долари', 'доларів', 0),
+        array('тисяча', 'тисячі', 'тисяч', 1),
+        array('мільйон', 'мільйони', 'мільйонів', 0),
+        array('мільярд', 'мільярди', 'мільярдів', 0),
+    );
+    //
+    list($rub, $kop) = explode('.', sprintf("%015.2f", floatval($num)));
+    $out = array();
+    if (intval($rub) > 0) {
+        foreach (str_split($rub, 3) as $uk => $v) { // by 3 symbols
+            if (!intval($v)) continue;
+            $uk = sizeof($unit) - $uk - 1; // unit key
+            $gender = $unit[$uk][3];
+            list($i1, $i2, $i3) = array_map('intval', str_split($v, 1));
+            // mega-logic
+            $out[] = $hundred[$i1]; # 1xx-9xx
+            if ($i2 > 1) $out[] = $tens[$i2] . ' ' . $ten[$gender][$i3]; # 20-99
+            else $out[] = $i2 > 0 ? $a20[$i3] : $ten[$gender][$i3]; # 10-19 | 1-9
+            // units without rub & kop
+            if ($uk > 1) $out[] = morph($v, $unit[$uk][0], $unit[$uk][1], $unit[$uk][2]);
+        } //foreach
+    } else $out[] = $nul;
+    $out[] = morph(intval($rub), $unit[1][0], $unit[1][1], $unit[1][2]); // rub
+    $out[] = $kop . ' ' . morph($kop, $unit[0][0], $unit[0][1], $unit[0][2]); // kop
+    return trim(preg_replace('/ {2,}/', ' ', join(' ', $out)));
+}
+
+function morph($n, $f1, $f2, $f5)
+{
+    $n = abs(intval($n)) % 100;
+    if ($n > 10 && $n < 20) return $f5;
+    $n = $n % 10;
+    if ($n > 1 && $n < 5) return $f2;
+    if ($n == 1) return $f1;
+    return $f5;
+}
+
+function app()
+{
+    return \Yii::$app;
+}
+
+/* @return \app\components\Templater */
+function templater()
+{
+    return app()->templater;
+}
+
+function DMF($val = ''){
+    var_dump($val);
+    die();
+}

+ 47 - 0
lib/docxGenerator.php

@@ -0,0 +1,47 @@
+<?php
+
+//Класс, генерирующий docx-файлы на базе шаблонов
+
+class docxGenerator {
+    private $_zipObject; //Для открытия zip-архива
+    private $_tmpFilename; //Имя временного файла, создаваемого при работе класса
+    private $_docxContent; //Хранит содержимое ./word/document.xml
+
+    public function __construct($filename){
+        //Конструтор класса, берет шаблон $filename
+
+//1) Создаем копию шаблона для безопасной работы
+        $this->_tmpFilename = dirname($filename).time().'.docx'; // Функция dirname извлекает путь к каталогу с файлом filename
+        copy($filename, $this->_tmpFilename); // Копируем содержимое шаблона во временный файл
+
+//2) С помощью встроенного в PHP класса вытаскиваем содержимое
+        $this->_zipObject = new ZipArchive(); //Создали экземпляр класса для работы с Zip-архивом
+        $this->_zipObject->open($this->_tmpFilename); //Открыли временный файл архиватором, т.к. docx - это и есть архив
+        $this->_docxContent = $this->_zipObject->getFromName('word/document.xml'); //Вытащили текст документа с разметкой из файла ./word/document.xml внутри архива
+    }//__construct
+
+    public function val($search, $replace) {
+        //Функция замены меток с названием $search на значение $replace
+        $search = '&amp;'.$search.';'; //Прибавляем амперсанд в виде специального символа и точку с запятой
+        $this->_docxContent = str_ireplace($search, $replace, $this->_docxContent); //Собственно процесс замены это обычная замена подстрок в текстовом документе
+    }//val
+
+    public function save($filename){
+        //Сохраняет полученный из шаблона файл с именем $filename. Существующие файлы перезаписываются.
+
+//1) Если файл $filename уже существует, то нужно его удалить
+        if(file_exists($filename)){
+            unlink($filename);
+        }//if file_exists
+
+//2) Дописываем измененное xml-содержимое в документ
+        $this->_zipObject->addFromString('word/document.xml', $this->_docxContent);
+
+//3) Пытаемся сохранить изменения
+        if($this->_zipObject->close() === false){
+            throw new Exception('Не удалось сохранить изменения в документе.');
+        }//if close
+        rename($this->_tmpFilename, $filename);
+    }//save
+}
+?>

+ 196 - 0
lib/zip/createzip.php

@@ -0,0 +1,196 @@
+<?php
+namespace zip\lib;
+
+/**
+* Class to dynamically create a zip file (archive)
+*
+* @author Rochak Chauhan
+*/
+
+class createZip  {
+
+    public $compressedData = array();
+    public $centralDirectory = array(); // central directory
+    public $endOfCentralDirectory = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record
+    public $oldOffset = 0;
+
+    /**
+     * Function to create the directory where the file(s) will be unzipped
+     *
+     * @param $directoryName string
+     *
+     */
+
+    public function addDirectory($directoryName) {
+        $directoryName = str_replace("\\", "/", $directoryName);
+
+        $feedArrayRow = "\x50\x4b\x03\x04";
+        $feedArrayRow .= "\x0a\x00";
+        $feedArrayRow .= "\x00\x00";
+        $feedArrayRow .= "\x00\x00";
+        $feedArrayRow .= "\x00\x00\x00\x00";
+
+        $feedArrayRow .= pack("V",0);
+        $feedArrayRow .= pack("V",0);
+        $feedArrayRow .= pack("V",0);
+        $feedArrayRow .= pack("v", strlen($directoryName) );
+        $feedArrayRow .= pack("v", 0 );
+        $feedArrayRow .= $directoryName;
+
+        $feedArrayRow .= pack("V",0);
+        $feedArrayRow .= pack("V",0);
+        $feedArrayRow .= pack("V",0);
+
+        $this -> compressedData[] = $feedArrayRow;
+
+        $newOffset = strlen(implode("", $this->compressedData));
+
+        $addCentralRecord = "\x50\x4b\x01\x02";
+        $addCentralRecord .="\x00\x00";
+        $addCentralRecord .="\x0a\x00";
+        $addCentralRecord .="\x00\x00";
+        $addCentralRecord .="\x00\x00";
+        $addCentralRecord .="\x00\x00\x00\x00";
+        $addCentralRecord .= pack("V",0);
+        $addCentralRecord .= pack("V",0);
+        $addCentralRecord .= pack("V",0);
+        $addCentralRecord .= pack("v", strlen($directoryName) );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $ext = "\x00\x00\x10\x00";
+        $ext = "\xff\xff\xff\xff";
+        $addCentralRecord .= pack("V", 16 );
+
+        $addCentralRecord .= pack("V", $this -> oldOffset );
+        $this -> oldOffset = $newOffset;
+
+        $addCentralRecord .= $directoryName;
+
+        $this -> centralDirectory[] = $addCentralRecord;
+    }
+
+    /**
+     * Function to add file(s) to the specified directory in the archive
+     *
+     * @param $directoryName string
+     *
+     */
+
+    public function addFile($data, $directoryName)   {
+
+        $directoryName = str_replace("\\", "/", $directoryName);
+
+        $feedArrayRow = "\x50\x4b\x03\x04";
+        $feedArrayRow .= "\x14\x00";
+        $feedArrayRow .= "\x00\x00";
+        $feedArrayRow .= "\x08\x00";
+        $feedArrayRow .= "\x00\x00\x00\x00";
+
+        $uncompressedLength = strlen($data);
+        $compression = crc32($data);
+        $gzCompressedData = gzcompress($data);
+        $gzCompressedData = substr( substr($gzCompressedData, 0, strlen($gzCompressedData) - 4), 2);
+        $compressedLength = strlen($gzCompressedData);
+        $feedArrayRow .= pack("V",$compression);
+        $feedArrayRow .= pack("V",$compressedLength);
+        $feedArrayRow .= pack("V",$uncompressedLength);
+        $feedArrayRow .= pack("v", strlen($directoryName) );
+        $feedArrayRow .= pack("v", 0 );
+        $feedArrayRow .= $directoryName;
+
+        $feedArrayRow .= $gzCompressedData;
+
+        $feedArrayRow .= pack("V",$compression);
+        $feedArrayRow .= pack("V",$compressedLength);
+        $feedArrayRow .= pack("V",$uncompressedLength);
+
+        $this -> compressedData[] = $feedArrayRow;
+
+        $newOffset = strlen(implode("", $this->compressedData));
+
+        $addCentralRecord = "\x50\x4b\x01\x02";
+        $addCentralRecord .="\x00\x00";
+        $addCentralRecord .="\x14\x00";
+        $addCentralRecord .="\x00\x00";
+        $addCentralRecord .="\x08\x00";
+        $addCentralRecord .="\x00\x00\x00\x00";
+        $addCentralRecord .= pack("V",$compression);
+        $addCentralRecord .= pack("V",$compressedLength);
+        $addCentralRecord .= pack("V",$uncompressedLength);
+        $addCentralRecord .= pack("v", strlen($directoryName) );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("v", 0 );
+        $addCentralRecord .= pack("V", 32 );
+
+        $addCentralRecord .= pack("V", $this -> oldOffset );
+        $this -> oldOffset = $newOffset;
+
+        $addCentralRecord .= $directoryName;
+
+        $this -> centralDirectory[] = $addCentralRecord;
+    }
+
+    /**
+     * Fucntion to return the zip file
+     *
+     * @return zipfile (archive)
+     */
+
+    public function getZippedfile() {
+
+        $data = implode("", $this -> compressedData);
+        $controlDirectory = implode("", $this -> centralDirectory);
+
+        return
+            $data.
+            $controlDirectory.
+            $this -> endOfCentralDirectory.
+            pack("v", sizeof($this -> centralDirectory)).
+            pack("v", sizeof($this -> centralDirectory)).
+            pack("V", strlen($controlDirectory)).
+            pack("V", strlen($data)).
+            "\x00\x00";
+    }
+
+    /**
+     *
+     * Function to force the download of the archive as soon as it is created
+     *
+     * @param archiveName string - name of the created archive file
+     */
+
+    public function forceDownload($archiveName) {
+        $headerInfo = '';
+
+        if(ini_get('zlib.output_compression')) {
+            ini_set('zlib.output_compression', 'Off');
+        }
+
+        // Security checks
+        if( $archiveName == "" ) {
+            echo "<html><title>Public Photo Directory - Download </title><body><BR><B>ERROR:</B> The download file was NOT SPECIFIED.</body></html>";
+            exit;
+        }
+        elseif ( ! file_exists( $archiveName ) ) {
+            echo "<html><title>Public Photo Directory - Download </title><body><BR><B>ERROR:</B> File not found.</body></html>";
+            exit;
+        }
+
+        header("Pragma: public");
+        header("Expires: 0");
+        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+        header("Cache-Control: private",false);
+        header("Content-Type: application/zip");
+        header("Content-Disposition: attachment; filename=".basename($archiveName).";" );
+        header("Content-Transfer-Encoding: binary");
+        header("Content-Length: ".filesize($archiveName));
+        readfile("$archiveName");
+
+     }
+
+}
+?>

+ 22 - 0
lib/zip/createzipfromdir.php

@@ -0,0 +1,22 @@
+<?php
+namespace zip\lib;
+
+
+class createDirZip extends createZip {
+
+  function get_files_from_folder($directory, $put_into) {
+    if ($handle = opendir($directory)) {
+      while (false !== ($file = readdir($handle))) {
+        if (is_file($directory.$file)) {
+          $fileContents = file_get_contents($directory.$file);
+          $this->addFile($fileContents, $put_into.$file);
+        } elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
+          $this->addDirectory($put_into.$file.'/');
+          $this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/');
+        }
+      }
+    }
+    closedir($handle);
+  }
+}
+?>

+ 22 - 0
mailer/layouts/html.php

@@ -0,0 +1,22 @@
+<?php
+use yii\helpers\Html;
+
+/* @var $this \yii\web\View view component instance */
+/* @var $message \yii\mail\MessageInterface the message being composed */
+/* @var $content string main view render result */
+?>
+<?php $this->beginPage() ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
+    <title><?= Html::encode($this->title) ?></title>
+    <?php $this->head() ?>
+</head>
+<body>
+    <?php $this->beginBody() ?>
+    <?= $content ?>
+    <?php $this->endBody() ?>
+</body>
+</html>
+<?php $this->endPage() ?>

+ 12 - 0
mailer/main.php

@@ -0,0 +1,12 @@
+<?php
+
+use yii\helpers\Html;
+use yii\helpers\Url;
+
+?>
+<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.6; font-weight: normal; margin: 0 0 10px; padding: 0;">
+	Свіжі новини з електроннго майданчика umstrade.com.ua. Розсилка надає Вам можливість отримувати актуальну інформацію щодо торгів, що здійснюються на майданчику.
+	Ви отримали це повідомлення, бо підписані на розсилку новин. Щоб відмовитись від отримання розсилки, натисніть <?=Html::a('тут', Url::to(['/subscriptions'], true))?>.
+</p>
+
+<p><?= $content; ?></p>

+ 496 - 0
messages/uk/app.php

@@ -0,0 +1,496 @@
+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yii message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE: this file must be saved in UTF-8 encoding.
+ */
+return [
+    'UUB'	=>	'ReacLogic - Електронний торговий майданчик',
+    'DateStop ID'   =>  'Дата завершення',
+    'GoToAuction ID'	=>	'Перейти до торгів',
+    'Rights ID'	=>	'Правила проведення торгів',
+    'Rights1 ID'     =>      'Правила проведення ел торгів',
+    'Posts ID'	=>	'Статті',
+    'GoToBid ID'    =>  'Прийняти участь',
+    'Ip ID'	=>	'ip-адреса',
+    'User ID'	=>	'Користувач',
+    'Action ID'	=>	'Дія',
+    'Settings ID'   =>  'Налаштування',
+    'OrgEnterAuk ID'	=>	'Організатор виконав вхiд до аукціону',
+    'ConfirmationOfBidding ID' => 'Заявка пiдтверджена',
+    'ExitSystem ID'	=>	'Вийшов із системи',
+    'LoginSystem ID'	=>	'Виконав вхід до системи',
+    'EnterAuk ID'	=>	'Виконав вхід до аукціону',
+    'WatcherEnterAuk ID'	=>	'Спостерігач виконав вход до аукціону',
+    'EnterWatcher ID'   =>  'Для просмотра торгов зайдите под логином: watcher пароль: watcher',
+    'Admin ID'	=>	'Адмiн',
+    'EventLog ID'	=>	'Журнал системи',
+    'withNDS ID'	=>	'грн. з ПДВ',
+    'withoutNDS ID'	=>	'грн. без ПДВ',
+    'CreateDoc ID'	=>	'Створити протокол',
+    'Circle ID'	=>	'Автозниження конкурсу',
+    'Template ID'	=>	'Шаблони торгів',
+    'AuctionType ID'	=>	'Тип торгів',
+    'Concurs ID'	=>	'Торги з можливістю зниження ціни',
+    'AuctionUp ID'  =>  'Торги на пiдвищення',
+    'ConcursCreated ID'	=>	'Конкурс створено',
+    'CreateConcurs ID'	=>	'Створити конкурс',
+    'Are you sure you send activation?' =>  'Ви впевнені що це йому треба? :)',
+    'Send ID' =>  'Відіслати',
+    'Send Activation ID' =>  'Відіслати E-mail',
+    'ActivationSubject ID'  =>  'Ваш аккаунт активовано',
+    'BiddingEditSelf ID'  =>  'Ви змінили заявку на участь',
+    'BiddingDeleteSelf ID'  =>  'Ви відкликали заявку на участь',
+//    'GoToAuction ID'    =>  'Прийняти участь',
+    'pWaitAuction ID'   =>  'Очікування початку торгів',
+    'BiddingEdit ID'    =>  'змінив заявку на участь',
+    'BiddingDelete ID' =>  'відкликав заявку на участь',
+    'Torgi ID'  =>  'Прийняти участь в торгах',
+    'Bills' => 'Рахунки',
+    'Bill' => 'Рахунок',
+    'Download bill' => 'Завантажити рахунок',
+    'Bills template' => 'Шаблон рахунку',
+    'Bills template description' => 'Єдиний шаблон для сплати регістраційного (0,15%) та гарантійного (1,5%) внесків.',
+    'Payed' => 'Сплачено',
+    'Guaranteed payment' => 'Гарантійний внесок (грн.)',
+    'Registration fee' => 'Регістраційний внесок (грн.)',
+    'Bill type' => 'Тип рахунку',
+    'Step ID'   =>  'Крок торгів(%)',
+    'YourBids ID'  =>  'Ваші заявки',
+    'UserManual ID' =>  'Користувачу',
+    'Manual ID' =>  'Керівництво',
+    'BiddingTimeEnd ID' =>  'Прийом заявок на торги вже закінчено',
+    'Reglament ID' =>  'Регламент',
+    'NDS ID'   =>  'ПДВ',
+    'bNDS ID'   =>  '(без ПДВ)',
+    'zNDS ID'   =>  '(з ПДВ)',
+    'Winner1 ID'   =>  'Переможець 1',
+    'Winner2 ID'   =>  'Переможець 2',
+    'Winner' => 'Переможець торгів',
+    'PaymentTerm ID'    =>  'Умови оплати',
+    'Price ID'  =>  'Ціна (грн)',
+    'MemberRequire ID' =>  ' Порядок участі у торгах',
+    'LotFiles ID'   =>  'Прикладені файли',
+    'LotsDescrioption ID'   =>  'Відомості про майно, що виставляється на торги, його склад, характеристики, опис',
+    'Dates ID'   =>  'Дата',
+    'Notes ID'  =>  'Повідомлення',
+    'FileName ID'   =>  'Ім\'я файлу',
+    'AucStart ID'   =>  'Дата почтаку торгів',
+    'LotsNotes ID'  =>  'Додаткова інформація',
+    'BiddingBegin ID'   =>  'Йде прийом заявок на торги',
+    'MemberFrom ID'    =>  'Посада та П.І.Б. представника',
+    'DownloadProtocol ID'   =>  'Завантажити протоколи торгів',
+    'AucReturn ID'  =>  'Повернутись до списку торги',
+    'PublishFiles ID'  =>  'Прикладені файли',
+    'DeliveryTerm ID'   =>  'Умови поставки товарів',
+    'DeliveryTime ID'   =>  'Терміни поставки товарів',
+    'PublishAddressTo ID'  =>  'Регіон постачання товарів',
+    'PublishDogInfo ID'    =>  'Інформація про умови договору',
+    'PublishMemRequire ID' =>  'Перелік наданих учасниками торгів документів та вимоги до їх оформлення',
+    'PublishMemReq ID'  =>  'Інформація про порядок участі в торгах',
+    'StartPrice ID' =>  'Початкова ціна',
+    'PublishLotDesc ID' =>  'Опис предмета договору',
+    'PublishLotInfo ID' =>  'Інформація про предмет торгів',
+    'PublishDateStart ID'   =>  'Початок подачі цiнових пропозицій',
+    'BiddingStartDate ID'   =>  'Початок прийому заявок на участь',
+    'PublishAucInfo ID' =>  'Інформація про процедуру торгів',
+    //'PublishAuctionMessage ID'  =>  'Повідомлення про проведення торгів ',
+    'PublishAuctionMessage ID'  =>  'Проект договору ',
+    'CreateAuction ID'  =>  'Створити аукціон',
+    'pMakeAuction ID'   =>  'проводяться торги',
+    'pMakeBidding ID'  =>  'йде прийом заявок',
+    'pMakeFinal ID' =>  'підводяться підсумки',
+    'pEndTorg ID'   =>  'торги завершені',
+    'Number ID' =>  '№',
+    'statusName ID' =>  'Стан торгів',
+    'endBidding ID' =>  'Завершення прийому заявок',
+    'FileUploaded ID'   =>  'Файл завантажено',
+    'AddressTo ID'   =>  'Порядок ознайомлення з майном',
+    'Publishing ID' =>  'Публікації про торги',
+    'ToLots ID' =>  'Переглянути лоти',
+    'YourAuctions ID'   =>  'Ваші аукціони',
+    'AucNumber ID'  =>  'Номер торгів',
+    'BiddingDate ID'    =>  'Закінчення прийому заявок на участь',
+    'BidWaiting ID' =>  'Ваша заявка на торги ще не підтверджена організатором',
+    'BidRejected ID'    =>  'Пробачте, але ваша заявка на участь відхилена організатором торгів',
+    'BidWellDone ID'    =>  'Заявку подано, чекайте на підтвердження',
+    'BidExist ID'   =>  'Заявка на цей аукціон вже створена, перевірте повідомлення',
+    'NeedBidding ID'    =>  'Потрібно спочатку подати заявку на участь!!!',
+    'NeedConfirmLot ID' =>  'Лот ще не узгоджено',
+    'AuctionCreatedOnLot ID'    =>  'Погождено та створено аукціон',
+    'Category ID'   =>  'Категорія товару',
+    'GoAuction ID'  =>  'Увійти до торгів',
+    'AuctionCreated ID' =>  'Аукціон створено',
+    'DopDocumentation ID'  =>  'Додаткова документація',
+    'ProjectDogovor ID'  =>  'Проект договору',
+    'LotInAuction ID'   =>  'Цей лот вже відправлений на Аукціон',
+    'LotEditNoSuccess ID'   =>  'Аукціон вже затверджено, ви не маете права на редагування',
+    'LotEditNoReject ID'   =>  'Аукціон відхилино, причину ви маете можливість подивитись в повідовленнях ',
+    'NeedDownloadFiles ID'  =>  'Потрібно заватажити документи на участь в аукціоні',
+    'BiddingConfirm ID' =>  'Ваша заявка на участь погоджена',
+    'Download ID'   =>  'Завантажити',
+    'CreateBid ID' =>  'Подати заявку на торги',
+    'PublishingLot ID' => 'Увійти до публікації лота',
+    'DownloadMemeberDoc ID' =>  'Завантажити заявку на участь та інші документи',
+    'Cabinet ID'    =>  'Особистий кабінет',
+    'Categories ID' =>  'Категорії',
+    'Lots ID'   =>  'Лоти',
+    'NewAuctionToday ID'    =>   'Діючі торги на '.date("d.m.Y H:i"),
+    'noRequisites ID'   =>  'Спочатку створіть реквізити',
+    'UserName ID'   =>  'Користувач',
+    'Home' => 'Головна',
+    'About' => 'Про нас',
+    'Contact' => 'Контакти',
+    'Login' => 'Вхід',
+    'Logout' => 'Вихід',
+    'Role' => 'Роль',
+    'Organizer' => 'Організатор торгів',
+    'Member' => 'Учасник торгів',
+    'Choose role:' => 'Оберіть роль',
+    'Please choose your role' => 'Необхідно обрати роль',
+    //'Username' => 'Логін',
+    'Password' => 'Пароль',
+    'Register' => 'Реєстрація',
+    'Settings' => 'Налаштування',
+    'User management' => 'Керування користувачами',
+    'Change password' => 'Змінити пароль',
+    'Requisites' => 'Реквізити',
+    'DocumentsToTheUser ID' => 'Документи користувачу',
+    'Create Documents To The User' => 'Додати Документи меню Користувачу',
+    'Messages' => 'Повідомлення',
+    'Full organization name' => 'Повна назва організації',
+    'INN' => 'ІПН',
+    'ZKPO' => 'ЄДРПОУ',
+    'Legal address' => 'Юридична адреса',
+    'Personal address' => 'Фактична адреса',
+    'Fax' => 'Додатковий телефон',
+    'Site' => 'Сайт',
+    'Files' => 'Файли',
+    'Mailing by category' => 'Розсилки по категоріям',
+    'Agree by organizer' => 'Узгоджено організатором',
+    'Title' => 'Заголовок',
+    'User login' => 'Ім’я користувача',
+    'Notes' => 'Примітка',
+    'Date' => 'Дата',
+    'Phone' => 'Телефон (+380xxxxxxx)',
+    'Create Requisites' => 'Додати реквізити',
+    'Bank' => 'Банк',
+    'City' => 'Місто',
+    'MFO' => 'МФО',
+    'Edit' => 'Редагувати',
+    'Subject' => 'Тема повiдомлення',
+    'Body' => 'Текст повiдомлення',
+    'Verification Code' => 'Код пiдтвердження',
+    'If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.' => 'Якщо у вас є ділова пропозиція або інші питання, будь ласка, заповніть наступну форму, щоб зв`язатися з нами. Дякуємо.',
+    'Submit' => 'Пiдтвердити',
+    'Repeat Password' => 'Повтор пароля',
+    'CloneImg' => 'Клонувати зображення',
+    'CloneAdditionalDoc' => 'Клонувати додаткову документацiю',
+    'Full name' => 'Прізвище Ім’я',
+    'Organization name' => 'Назва організації (П.I.Б для фiз. осiб та ФОП)',
+    'Organization type' => 'Форма організації',
+    'FOP' => 'ФОП',
+    'Entity' => 'Фізична особа',
+    'Individual' => 'Юридична особа',
+    'Phone number' => 'Номер телефону (+380xxxxxxx)',
+    'Email' => 'Електронна адреса',
+    'E-mail' => 'Додаткова електронна адреса',
+    'Please enter your fax' => 'Будь ласка, уведiть номер свого факсу',
+    'Passwords don\'t match' => 'Паролi не спiвпадають',
+    'Please enter your fullname' => 'Будь ласка, уведiть ваше iм`я',
+    'Please choose organization type' => 'Необхiдно вибрати тип органiзацiї',
+    'Register as Organizer' => 'Зареєструватись як організатор',
+    'Are you sure you want to delete this item?' => 'Ви дiйсно хочете видалити реквiзити?',
+    'Captcha' => 'Введіть данні з малюнку',
+    'You must relogin for apply changes' => 'Регістрація завершена. Чекайте підтверждення на вказаний email.',
+    'CreateAukDate ID'  =>  'Оберіть бажану дату ауціону',
+    'AukName ID'    =>  'Торги',
+    'WaitConfirm ID'    =>  'не підтверджена',
+    'BidFrom ID'    =>  'Заявка від',
+    'Lot ID'    =>  'Лот',
+    'Confirm ID'    =>  'Підтвердити',
+    'Reject ID' =>  'Відхилити',
+    'Back ID'   =>  'Повернутися',
+    'MessageNum ID' =>  'Повідомлення №',
+    'Bidding ID'    =>  'Заявки',
+    'NotesOrg ID'   =>  'подав заявку на участь',
+    'Notes2Org ID'   =>  ', ви маєте можливість підтвердити або відхилити ії у меню Заявки',
+    'NotesMember ID'    =>  'Ви подали заявку на участь',
+    'AucType ID'   =>  'Тип торгів',
+    'OrgName ID'    =>  'Організатор торгів',
+    'LotNumber ID'  =>  'Лот №',
+    'LotName ID'  =>  'Найменування лота',
+    'Predmet ID'    =>  'Предмет торгів',
+    'Create ID'    =>      'Створити',
+    'Update ID'    =>      'Редагувати',
+    'Delete ID'	=>	'Видалити',
+    'Memail ID'    =>      'Додаткова эл. пошта',
+    'Fiz ID'    =>      'Фізична особа',
+    'Ur ID'    =>      'Юридична особа',
+    'Org_type ID'    =>      'Організаціона форма',
+    'Username'	=>	'Користувач',
+    'YouLots ID'	=>	'Ваші лоти',
+    'CreateLot ID'	=>	'Додати лот',
+    'CreateLot2 ID'	=>	'Додати ще один лот',
+    'Auction ID'	=>	'Торги',
+    'Messages ID'	=>	'Повідомлення',
+    'Reports ID'	=>	'Звіти',
+    'AuctionDate ID'	=>	'Початок подачі цiнових пропозицій',
+    'Date ID'	=>	'Дата заявки',
+    'Requisites ID'	=>	'Реквізити',
+    'Term_procedure ID'	=>	'Терміни та порядок внесення фінансового забезпечення',
+    'Status ID'	=>	'Статус',
+    'Waiting ID'	=>	'обробляється',
+    'Success ID'    =>      'узгоджено',
+    'Rejected ID'    =>      'відхилено',
+    'A confirmation message has been sent to your new email address' => '',
+    'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '',
+    'A message has been sent to your email address. It contains a password that we generated for you.' => '',
+    'A message has been sent to your email address. It contains your password and a confirmation link that you must click to complete registration.' => '',
+    'A new confirmation link has been sent' => '',
+    'Account confirmation' => '',
+    'Account details' => '',
+    'Account details have been updated' => '',
+    'An email has been sent with instructions for resetting your password' => '',
+    'An error occurred and your password has not been changed. Please try again later.' => '',
+    'An error occurred processing your request' => '',
+    'Are you sure you want to delete this user?' => '',
+    'Assignments' => '',
+    'Awesome, almost there. Now you need to click the confirmation link sent to your new email address' => '',
+    'Awesome, almost there. Now you need to click the confirmation link sent to your old email address' => '',
+    'Complete password reset on {0}' => '',
+    'Confirm account on {0}' => '',
+    'Confirm email change on {0}' => '',
+    'Confirmation status' => '',
+    'Confirmation time' => '',
+    'Create' => '',
+    'Credentials will be sent to the user by email' => '',
+    'Delete' => '',
+    'Disconnect' => '',
+    'Don\'t have an account? Sign up!' => '',
+    'In order to finish your registration, we need you to enter your email address' => '',
+    'Invalid or expired link' => '',
+    'New email' => '',
+    'New permission' => '',
+    'New role' => '',
+    'New user' => '',
+    'Not blocked' => '',
+    'Permissions' => '',
+    'Profile details' => '',
+    'Profile details have been updated' => '',
+    'Recovery link is invalid or expired. Please try requesting a new one.' => '',
+    'Recovery message sent' => '',
+    'Registration IP' => '',
+    'Roles' => '',
+    'Something went wrong' => '',
+    'Something went wrong and your account has not been confirmed.' => '',
+    'Thank you, registration is now complete.' => '',
+    'The confirmation link is invalid or expired. Please try requesting a new one.' => '',
+    'This email address has already been taken' => '',
+    'This username has already been taken' => '',
+    'Unconfirmed' => '',
+    'Update' => '',
+    'VKontakte' => '',
+    'We have sent confirmation links to both old and new email addresses. You must click both links to complete your request' => '',
+    'Welcome! Registration is complete.' => '',
+    'Yandex' => '',
+    'You can assign multiple roles or permissions to user by using the form below' => '',
+    'You can connect multiple accounts to be able to log in using them' => '',
+    'You can not block your own account' => '',
+    'You can not remove your own account' => '',
+    'You can now log in with the following credentials:' => '',
+    'Your account details have been updated' => '',
+    'Your account has been connected' => '',
+    'Your account on {0} has been created' => '',
+    'Your confirmation token is invalid or expired' => '',
+    'Your email address has been changed' => '',
+    'Your password has been changed successfully.' => '',
+    'Your profile has been updated' => '',
+    'Account has successfully been connected' => '@@Аккаунт підключено@@',
+    'All user tokens have been deleted' => '@@Всі токени було видалено@@',
+    'Awesome! You have successfully confirmed your email address. You may sign in using your credentials now.' => '@@Чудово, ви успішно активували ваш аккаунт. Тепер ви можете авторизуватися, використовуючи свої логін та пароль.@@',
+    'Before your email will be changed we need you to confirm your new email address' => '@@Перед тим, як ми змінимо ваш email, ви повинні його активувати@@',
+    'But if you are having troubles, you can request a new one by clicking the link below' => '@@Якщо лист так і не надійшов, ви можете запросити нового@@',
+    'Cancel email change' => '@@Відмінити зміну email@@',
+    'Complete your password reset on {0}' => '@@Завершіть скидання пароля на {0}@@',
+    'Confirm your account on {0}' => '@@Активуйте ваш аккаунт на {0}@@',
+    'Confirm your email change on {0}' => '@@Підтвердіть зміну email на {0}@@',
+    'Confirmation needed' => '@@Необхідна активація аккаунта@@',
+    'Confirmation token is invalid' => '@@Посилання для активації аккаунта застаріло@@',
+    'Connect this account by entering desired username and your email address below' => '@@Підключіть аккаунт вибравши ім\'я користувача та email@@',
+    'Connect your account to {0}' => '@@Підключіть ваш аккаунт до {0}@@',
+    'Current email' => '@@Поточний email@@',
+    'Delete recovery tokens' => '@@Видалити токени@@',
+    'Email change has been cancelled' => '@@Зміну email було перервано@@',
+    'Email settings' => '@@Налаштування Email@@',
+    'In order to complete your request, we need you to verify that you initiated this request' => '@@Для того щоб завершити запит, ми повинні переконатися, що саме ви його почали@@',
+    'Last login at {0, date, MMMM dd, YYYY HH:mm} from {1}' => '@@Останняя авторизація {0, date, MMMM dd, YYYY HH:mm} 3 {1}@@',
+    'Looks like this is first time you are using {0} account to sign in to {1}' => '@@Схоже, що ви вперше використовуєте {1}, щоб зайти на {0}@@',
+    'Password and username will be sent to user by email' => '@@Пароль та ім\'я користувача будуть вислані користувачу по email@@',
+    'Password recovery finished' => '@@Процедуру скидання пароля завершено@@',
+    'Password settings' => '@@Налаштування пароля@@',
+    'Please check your email and click the confirmation link to complete your registration' => '@@Будь-ласка, провірте вашу поштову скриньку і натисніть посилання, щоб завершити реєстрацію@@',
+    'Please check your email and click the reset link.' => '@@Будь-ласка, провірте вашу поштову скриньку і натисніть посилання, щоб відновити пароль.@@',
+    'Profile updated successfully' => '@@Профіль було змінено@@',
+    'Recovery message has been sent' => '@@Листа з посиланням ндля зміни паролю було відправлено@@',
+    'Recovery token is invalid' => '@@Посилання ндля зміни паролю застаріло@@',
+    'Registered at {0, date, MMMM dd, YYYY HH:mm} from {1}' => '@@Зареєстровано {0, date, MMMM dd, YYYY HH:mm} з {1}@@',
+    'Registered from' => '@@Зареєстровано з@@',
+    'Thank you for registration on our website. You may sign in using your credentials.' => '@@Щиро вдячні за реєстрацію на нашому сайті. Теперь ви можете авторизуватися, використовуючи ваш логін та пароль.@@',
+    'The email can take a few minutes to arrive' => '@@Відправка листа може зайняти кілька хвилин@@',
+    'This URL will only be valid for a limited time and will expire' => '@@Це посилання буде дійсним обмежений проміжок часу@@',
+    'Unconfirmed Email' => '@@Новий Email@@',
+    'User has been updated' => '@@Користувача було змінено@@',
+    'We are sorry but your confirmation token is invalid. Maybe it is expired or does not exist. You can try requesting a new one by clicking the link below:' => '@@Нажаль ваше посилання для активації аккаунта недійсне. Можливо закінчився термін його дії або вона взагалі не існує. Ви можете запросити нове, натиснувши на посилання нижче:@@',
+    'We are sorry but your confirmation token is invalid. Maybe it is expired or does not exist. You can try requesting new recovery token.' => '@@Нажаль ваше посилання для скидання пароля недійсне. Можливо закінчився термін його дії або вона взагалі не існує. Ви можете спробувати запросити нову.@@',
+    'We need to confirm your email address' => '@@Майже готово! Для завершення реєстрації ви повинні активувати ваш аккаунт.@@',
+    'You have been sent an email with instructions on how to reset your password.' => '@@Вам було відправлено інструкції по зміні пароля.@@',
+    'You will never have to use this form again' => '@@Ви ніколи більше не побачите цю форму@@',
+    'Your account has been confirmed' => '@@Ваш аккаунт було активовано@@',
+    'Your account on {0} has been successfully created' => 'Ваш особистий кабінет на електронному майданчику був успішно створений',//'@@Ваш аккаунт на {0} було успішно створено@@',
+    'Your password has been successfully changed. You can try logging in using your new password.' => '@@Ваш пароль було успішно змінено. Теперь ви можете авторизуватися використовуючи новий пароль.@@',
+    'Your username is {0} and your password is {1}' => '@@Ваше им\'я користувача - {0}, а ваш пароль - {1}@@',
+    '(not set)' => '(не задано)',
+    'A password will be generated automatically if not provided' => 'Якщо ви хочете, щоб пароль було згенеровано автоматично, залишіть поле пустим',
+    'Account' => 'Аккаунт',
+    'Account settings' => 'Налаштування аккаунта',
+    'Already registered? Sign in!' => 'Вже зареєстровані? Авторизуйтесь!',
+    'Are you sure you want to block this user?' => 'Ви впевнені, що хочете заблокувати користувача?',
+    'Are you sure you want to confirm this user?' => 'Ви впевнені, що хочете підтвердити аккаунт користувача?',
+    'Are you sure you want to unblock this user?' => 'Ви впевнені, що хочете розблокувати користувача?',
+    'Are you sure? Deleted user can not be restored' => 'Ви впевнені? Видалений аккаунт не можна відновити',
+    'Bio' => 'Про себе',
+    'Block' => 'Блокувати',
+    'Block status' => 'Блокування',
+    'Blocked at {0, date, MMMM dd, YYYY HH:mm}' => 'Заблоковано  {0, date, MMMM dd, YYYY HH:mm}',
+    'Change your avatar at Gravatar.com' => 'Змінити аватар на сайті Gravatar.com',
+    'Confirm' => 'Підтвердити',
+    'Confirmation' => 'Активація',
+    'Confirmed' => 'Активовано',
+    'Confirmed at {0, date, MMMM dd, YYYY HH:mm}' => 'Активовано {0, date, MMMM dd, YYYY HH:mm}',
+    'Connect' => 'Під\'єднати',
+    'Continue' => 'Продовжити',
+    'Create a user account' => 'Створити новий аккаунт',
+    'Current password' => 'Поточний пароль',
+    'Current password is not valid' => 'Поточний пароль введено невірно',
+    'Didn\'t receive confirmation message?' => 'Не прийшов лист?',
+    'Email (public)' => 'Публічний email',
+    'Error occurred while changing password' => 'При зміні пароля виникла помилка',
+    'Error occurred while confirming user' => 'Виникла помилка при активації користувача',
+    'Error occurred while deleting user' => 'Виникла помилка при видаленні користувача',
+    'Finish' => 'Завершити',
+    'Forgot password?' => 'Забули пароль?',
+    'Gravatar email' => 'Gravatar email',
+    'Hello' => 'Привіт',
+    'If you already registered, sign in and connect this account on settings page' => 'Якщо ви вже зареєстровані, ввійдіть і підключіть аккаунт в налаштуваннях',
+    'If you cannot click the link, please try pasting the text into your browser' => 'Якщо Вам не вдається перейти за посиланням, то скопіюйте зазначену адресу та вставте в стрічку браузера.',//'Якщо по яким-небудь причинам посилання не працює, вставте наступну адресу в стрічку браузера',
+    'If you did not make this request you can ignore this email' => 'Якщо Ви не реєструвалися на електронному майданчику біржі та отримали це повідомлення помилково, проігноруйте його.',//'P.S. Якщо ви отримали це повідомлення про помилку, просто видаліть його',
+    'In order to complete your registration, please click the link below' => 'Для того щоб завершити процедуру реєстрації на електронному майданчику перейдіть за посиланням:',//'Чтобы завершить регистрацию, нажмите на ссылку ниже',
+    'In order to complete your request, please click the link below' => 'Для того щоб завершити запит, натисніть на посилання нижче',
+    'Information' => 'Інформація',
+    'Invalid login or password' => 'Неправильний логін або пароль',
+    'Joined on {0, date}' => 'Приєднався {0, date}',
+    'Location' => 'Місцерозташування',
+    //'Login' => 'Логін',
+    //'Logout' => 'Вийти',
+    'Manage users' => 'Управління користувачами',
+    'Name' => 'Ім\'я',
+    'Networks' => 'Соціальні мережі',
+    'New password' => 'Новий пароль',
+    //'Password' => 'Пароль',
+    'Password has been changed' => 'Пароль було змінено',
+    'Please click the link below to complete your password reset' => 'Дял того, щоб відновити пароль, натисніть на посилання нижче',
+    'Please fix following errors:' => 'Виправте наступні помилки',
+    'Profile' => 'Профіль',
+    'Profile settings' => 'Налаштування профіля',
+    'Recover your password' => 'Відновити пароль',
+    'Registration ip' => 'Реєстраційний IP',
+    'Registration time' => 'Час реєстрації',
+    'Remember me next time' => 'Запам\'ятати мене',
+    'Request new confirmation message' => 'Повторна відправка інструкцій',
+    'Reset your password' => 'Скинути пароль',
+    'Save' => 'Зберегти',
+    'Sign in' => 'Авторизуватися',
+    'Sign up' => 'Зареєструватися',
+    'SignIn' => 'Увійти',
+    'SignUp' => 'Зареєструватися',
+    'Thank you for signing up on {0}' => 'Дякуємо за регістрацію на {0}',
+    'There is no user with this email address' => 'Немає користувача з таким email',
+    'This account has already been confirmed' => 'Цей аккаунт вже було активовано',
+    'This account has already been connected to another user' => 'Цей аккаунт вже був прив\'язаний до іншого користувацького запису',
+    'Unblock' => 'Розблокувати',
+    'Update user account' => 'Обновити аккаунт користувача',
+    'User has been blocked' => 'Користувача було заблоковано',
+    'User has been confirmed' => 'Користувача було активовано',
+    'User has been created' => 'Користувача було створено',
+    'User has been deleted' => 'Користувача було видалено',
+    'User has been unblocked' => 'Користувача було розблоковано',
+    'User is not found' => 'Користувача не знайдено',
+    'Users' => 'Користувачі',
+    'We have received a request to change the email address for your account on {0}' => 'Ви нещодавно запросили зміну email на {0}',
+    'We have received a request to reset the password for your account on {0}' => 'Ви нещодавно запросили зміну пароля на {0}',
+    'Website' => 'Вебсайт',
+    'Welcome to {0}' => 'Раді вас бачити на {0}',
+    'You need to confirm your email address' => 'Ви повинні активувати аккаунт, перевірте свій email',
+    'Your account has been blocked' => 'Ваш аккаунт було заблоковано',
+    'Your account has been created' => 'Ваш аккаунт було створено',
+    '{0, date, MMMM dd, YYYY HH:mm}' => '{0, date, MMMM dd, YYYY HH:mm}',
+    'Cabinet' => 'Кабінет',
+    'Auctions' => 'Торги',
+    'Enter value' => 'Змінити значення',
+    'Close' => 'Закрити',
+    'Create' => 'Створити',
+    'Time Value' => 'Час зниження',
+    'Status' => 'Стан торгів',
+    'LotNum' => '№',
+    'Create Category' => 'Створити категорію',
+    'Subscriptions' => Yii::$app->user->can('admin') ? 'Розсилка' : 'Мої підписки',
+    'Created At' => 'Створено в',
+    'FIO' => 'ПІБ',
+    'Category Name' => 'Назва категорії',
+    'New Lot in category: "{category}"' => 'Опубліковано новий лот в категорії "{category}"',
+    'View: {link}' => 'Переглянути: {link}',
+    'User Registered ID: {name}' => 'На майданчику був зареєстрований новий учасник: {name}',
+    'Contact Person' => 'Контактна особа',
+    'Cannot save file' => 'Не вдалося зберегти файл. Будь ласка, спробуйте ще раз',
+    'Rules' => 'Правила проведення торгів в електронній формі',
+    'Examples' => 'Зразки заяв на участь в торгах',
+    'Reglament' => 'Регламент',
+    'Choose' => 'Оберіть',
+    'Create BlogPosts' => 'Створити новину',
+    'BlogPosts' => 'Новини',
+    'News' => 'Новини',
+    'Create Posts' => 'Створити новину',
+    'OrgDeleteAuk ID {action}' => 'Організатор видалив аукціон {action}',
+    'Auction deleted successfully' => 'Аукціон успішно видалено',
+    'Download file' => 'Завантажити файл',
+    'Picture' => 'Картинка',
+    'Auctions ID' => 'Аукціони',
+    'Cat ID' => 'Категорія',
+    'Description' => 'Опис',
+    'Key words' => 'Ключові слова',
+    'Lot' => 'Лот',
+    'Company full name' => 'Повна назва компанії',
+    'Download' => 'Завантажити зображення',
+    'Total count - {count}' => 'Загальна кількість - {count}',
+    'Registered users per month' => 'Зареєстрованих користувачів за місяць',
+    'Auctions by status per month' => 'Аукціонів по статусу за місяць',
+    'Auctions by category' => 'Аукіонів по категорії за місяць',
+    'Subscriptions by category' => 'Підписок на кожну категорію',
+    'Selected month' => 'Обраний місяць',
+    'ID' => 'Номер',
+    '' => '',
+    '' => '',
+];

+ 52 - 0
messages/uk/rbac.php

@@ -0,0 +1,52 @@
+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yii message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE: this file must be saved in UTF-8 encoding.
+ */
+return [
+    'Assignments have been updated' => 'Ролі успішно призначені',
+    'Auth item with such name already exists' => 'Елемент з таким ім’ям вже є',
+    'Class "{0}" does not exist' => 'Клас "{0}" відсутній',
+    'Classname of the rule associated with this item' => 'Ім’я класу правил, зв’язаних з цим елементом',
+    'Create' => 'Створити',
+    'Create new permission' => 'Створити новий дозвіл',
+    'Create new role' => 'Створити нову роль',
+    'Description' => 'Опис',
+    'Invalid value' => 'Невірне значення',
+    'Item has been created' => 'Пункт успішно створено',
+    'Item has been updated' => 'Пункт успішно оновлений',
+    'Name' => 'Ім’я',
+    'New permission' => 'Новий дозвіл',
+    'New role' => 'Нова роль',
+    'New user' => 'Новий користувач',
+    'Permissions' => 'Дозволи',
+    'Roles' => 'Ролі',
+    'Rule class can not be instantiated' => 'Об’єкт класу правил не може бути створений',
+    'Rule class must extend "yii\rbac\Rule"' => 'Клас правил повинен бути наслідником класу  "yii\rbac\Rule"',
+    'Rule name' => 'Правило',
+    'Save' => 'Зберегти',
+    'The item description (Optional).' => 'Опис (Не обов’язково)',
+    'The name of the item.' => 'Ім’я елемента.',
+    'There is neither role nor permission with name "{0}"' => 'Не існує ні ролей, ні дозволів з ім’ям "{0}"',
+    'Update assignments' => 'Оновити призначення',
+    'Update permission' => 'Оновити дозволи',
+    'Update role' => 'Оновити роль',
+    'Users' => 'Користувачі',
+    'Сhildren' => 'Дочірні правила',
+    'Rule' => 'Правило',
+    'Children' => 'Дочірні',
+
+];

+ 215 - 0
messages/uk/user.php

@@ -0,0 +1,215 @@
+<?php
+
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yii message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE: this file must be saved in UTF-8 encoding.
+ */
+return [
+    'A confirmation message has been sent to your new email address' => 'Повідомлення надіслане на вашу нову пошту',
+    'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => 'Повідомлення надіслане на вашу пошту. Воно містить посилання для підтвердження реєстрації',
+    'A message has been sent to your email address. It contains a password that we generated for you.' => 'Повідомлення надіслане на вашу пошту. Воно містить згенерований для вас пароль',
+    'A message has been sent to your email address. It contains your password and a confirmation link that you must click to complete registration.' => 'Повідомлення надіслане на вашу пошту. Воно містить пароль і посилання для підтвердження реєстрації',
+    'A new confirmation link has been sent' => 'Посилання для підтвердження було надіслане',
+    'Account confirmation' => 'Підтвердження аккаунта',
+    'Account details' => 'Деталі аккаунта',
+    'Account details have been updated' => 'Деталі були оновлені',
+    'An email has been sent with instructions for resetting your password' => 'Лист містить інструкції для зміни паролю',
+    'An error occurred and your password has not been changed. Please try again later.' => 'Виникла помилка, ваш пароль не можу бути змінено. Спробуйте, будь ласка, пізніше',
+    'An error occurred processing your request' => 'Виникла помилка при обробці вашого запиту',
+    'Are you sure you want to delete this user?' => 'Ви дійсно хочете видалити цього користувача',
+    'Assignments' => 'Дозволи',
+    'Awesome, almost there. Now you need to click the confirmation link sent to your new email address' => 'Майже готово. Вам необхідно перейти за посиланням в листі, відправлено на вашу нову пошту',
+    'Awesome, almost there. Now you need to click the confirmation link sent to your old email address' => 'Майже готово. Вам необхідно перейти за посиланням в листі, відправлено на вашу стару пошту',
+    'Complete password reset on {0}' => 'Заміна паролю на сайті {0}',
+    'Confirm account on {0}' => 'Активація аккаунта на сайті {0}',
+    'Confirm email change on {0}' => 'Заміна пошти на сайті {0}',
+    'Confirmation status' => 'Підтвердження статусу',
+    'Confirmation time' => 'Час підтвердження',
+    'Create' => 'Створити',
+    'Credentials will be sent to the user by email' => 'Реквізити були надіслані на пошту',
+    'Delete' => 'Видалити',
+    'Disconnect' => 'Вимкнути',
+    'Don\'t have an account? Sign up!' => 'Немає аккаунта? Зареєструйтесь!',
+    'In order to finish your registration, we need you to enter your email address' => 'Щоб завершити реєстрацію, введіть свою пошту',
+    'Invalid or expired link' => 'Невірне або застаріле посилання',
+    'New email' => 'Нова пошта',
+    'New permission' => 'Новий дозвіл',
+    'New role' => 'Нова роль',
+    'New user' => 'Новий користувача',
+    'Not blocked' => 'Не заблокований',
+    'Permissions' => 'Дозвол',
+    'Profile details' => 'Деталі профілю',
+    'Profile details have been updated' => 'Деталі профілю було змінено',
+    'Recovery link is invalid or expired. Please try requesting a new one.' => 'Посилання для зміни паролю неправильне або застаріле. Спробуйте запросити нове',
+    'Recovery message sent' => 'Лист для скидання паролю відправлено',
+    'Registration IP' => 'IP при реєстрації',
+    'Roles' => 'Ролі',
+    'Something went wrong' => 'Щось сталось не так',
+    'Something went wrong and your account has not been confirmed.' => 'Щось сталось не так і ваш аккаунт не було активовано',
+    'Thank you, registration is now complete.' => 'Дякую, реєстрація виконана, Ви здійснили вхід в особистий кабінет.',
+    'The confirmation link is invalid or expired. Please try requesting a new one.' => 'Посилання для підтвердження неправильне або застаріле. Спробуйте запросити нове',
+    'This email address has already been taken' => 'Поштова адреса вже зайнята',
+    'This username has already been taken' => 'Логін вже зайнятий',
+    'Unconfirmed' => 'Аккаунт не підтвердженно',
+    'Update' => 'Оновити',
+    'VKontakte' => 'Вконтакті',
+    'We have sent confirmation links to both old and new email addresses. You must click both links to complete your request' => 'Ми відправили листи на нову і стару поштові адреси. Ви повинні перейти по обом, для зміни поштової адреси.',
+    'Welcome! Registration is complete.' => 'Ласкаво просимо! Реєстрація виконана',
+    'Yandex' => 'Яндекс',
+    'You can assign multiple roles or permissions to user by using the form below' => 'Ви можете додати багато ролей чи дозволів для користувача в формі нище',
+    'You can connect multiple accounts to be able to log in using them' => 'Ви можете підключити декілька аккаунтів для входу',
+    'You can not block your own account' => 'Ви не можете заблокувати висланий аккаунт',
+    'You can not remove your own account' => 'Ви не можете видалити висланий аккаунт',
+    'You can now log in with the following credentials:' => 'Ви можете використовувати це разом з email і логіном для входу:',
+    'Your account details have been updated' => 'Налаштування аккаунту були змінені',
+    'Your account has been connected' => 'Аккаунт було успішно підключено',
+    'Your account on {0} has been created' => 'Ви подали заявку на реєстрацію на електронному майданчику',//'Ваш аккаунт на сайті "{0}" був успешно створений',
+    'Your confirmation token is invalid or expired' => 'Ваше посилання неправильне чи застаріле',
+    'Your email address has been changed' => 'Вашу поштову адресу було змінено',
+    'Your password has been changed successfully.' => 'Ваш пароль було успішно змінено',
+    'Your profile has been updated' => 'Ваш аккаунт був оновлений',
+    'Account has successfully been connected' => 'Аккаунт підключено',
+    'All user tokens have been deleted' => 'Всі токени було видалено',
+    'Awesome! You have successfully confirmed your email address. You may sign in using your credentials now.' => 'Чудово, ви успішно активували ваш аккаунт. Тепер ви можете авторизуватися, використовуючи свої логін та пароль.',
+    'Before your email will be changed we need you to confirm your new email address' => 'Перед тим, як ми змінимо ваш email, ви повинні його активувати',
+    'But if you are having troubles, you can request a new one by clicking the link below' => 'Якщо лист так і не надійшов, ви можете запросити нового',
+    'Cancel email change' => 'Відмінити зміну email',
+    'Complete your password reset on {0}' => 'Завершіть скидання пароля на {0}',
+    'Confirm your account on {0}' => 'Активуйте ваш аккаунт на {0}',
+    'Confirm your email change on {0}' => 'Підтвердіть зміну email на {0}',
+    'Confirmation needed' => 'Необхідна активація аккаунта',
+    'Confirmation token is invalid' => 'Посилання для активації аккаунта застаріло',
+    'Connect this account by entering desired username and your email address below' => 'Підключіть аккаунт вибравши ім\'я користувача та email',
+    'Connect your account to {0}' => 'Підключіть ваш аккаунт до {0}',
+    'Current email' => 'Поточний email',
+    'Delete recovery tokens' => 'Видалити токени',
+    'Email change has been cancelled' => 'Зміну email було перервано',
+    'Email settings' => 'Налаштування Email',
+    'In order to complete your request, we need you to verify that you initiated this request' => 'Для того щоб завершити запит, ми повинні переконатися, що саме ви його почали',
+    'Last login at {0, date, MMMM dd, YYYY HH:mm} from {1}' => 'Останняя авторизація {0, date, MMMM dd, YYYY HH:mm} 3 {1}',
+    'Looks like this is first time you are using {0} account to sign in to {1}' => 'Схоже, що ви вперше використовуєте {1}, щоб зайти на {0}',
+    'Password and username will be sent to user by email' => 'Пароль та ім\'я користувача будуть вислані користувачу по email',
+    'Password recovery finished' => 'Процедуру скидання пароля завершено',
+    'Password settings' => 'Налаштування пароля',
+    'Please check your email and click the confirmation link to complete your registration' => 'Будь-ласка, провірте вашу поштову скриньку і натисніть посилання, щоб завершити реєстрацію',
+    'Please check your email and click the reset link.' => 'Будь-ласка, провірте вашу поштову скриньку і натисніть посилання, щоб відновити пароль.',
+    'Profile updated successfully' => 'Профіль було змінено',
+    'Recovery message has been sent' => 'Листа з посиланням ндля зміни паролю було відправлено',
+    'Recovery token is invalid' => 'Посилання ндля зміни паролю застаріло',
+    'Registered at {0, date, MMMM dd, YYYY HH:mm} from {1}' => 'Зареєстровано {0, date, MMMM dd, YYYY HH:mm} з {1}',
+    'Registered from' => 'Зареєстровано з',
+    'Role' => 'Роль',
+    'Thank you for registration on our website. You may sign in using your credentials.' => 'Щиро вдячні за реєстрацію на нашому сайті. Теперь ви можете авторизуватися, використовуючи ваш логін та пароль.',
+    'The email can take a few minutes to arrive' => 'Відправка листа може зайняти кілька хвилин',
+    'This URL will only be valid for a limited time and will expire' => 'Це посилання буде дійсним обмежений проміжок часу',
+    'Unconfirmed Email' => 'Новий Email',
+    'User has been updated' => 'Користувача було змінено',
+    'We are sorry but your confirmation token is invalid. Maybe it is expired or does not exist. You can try requesting a new one by clicking the link below:' => 'Нажаль ваше посилання для активації аккаунта недійсне. Можливо закінчився термін його дії або вона взагалі не існує. Ви можете запросити нове, натиснувши на посилання нижче:',
+    'We are sorry but your confirmation token is invalid. Maybe it is expired or does not exist. You can try requesting new recovery token.' => 'Нажаль ваше посилання для скидання пароля недійсне. Можливо закінчився термін його дії або вона взагалі не існує. Ви можете спробувати запросити нову.',
+    'We need to confirm your email address' => 'Майже готово! Для завершення реєстрації ви повинні активувати ваш аккаунт.',
+    'You have been sent an email with instructions on how to reset your password.' => 'Вам було відправлено інструкції по зміні пароля.',
+    'You will never have to use this form again' => 'Ви ніколи більше не побачите цю форму',
+    'Your account has been confirmed' => 'Ваш аккаунт було активовано',
+    'Your account on {0} has been successfully created' => 'Ваш аккаунт на {0} було успішно створено',
+    'Your password has been successfully changed. You can try logging in using your new password.' => 'Ваш пароль було успішно змінено. Теперь ви можете авторизуватися використовуючи новий пароль.',
+    'Your username is {0} and your password is {1}' => 'Ваше им\'я користувача - {0}, а ваш пароль - {1}',
+    '(not set)' => '(не задано)',
+    'A password will be generated automatically if not provided' => 'Якщо ви хочете, щоб пароль було згенеровано автоматично, залишіть поле пустим',
+    'Account' => 'Аккаунт',
+    'Account settings' => 'Налаштування аккаунта',
+    'Already registered? Sign in!' => 'Вже зареєстровані? Авторизуйтесь!',
+    'Are you sure you want to block this user?' => 'Ви впевнені, що хочете заблокувати користувача?',
+    'Are you sure you want to confirm this user?' => 'Ви впевнені, що хочете підтвердити аккаунт користувача?',
+    'Are you sure you want to unblock this user?' => 'Ви впевнені, що хочете розблокувати користувача?',
+    'Are you sure? Deleted user can not be restored' => 'Ви впевнені? Видалений аккаунт не можна відновити',
+    'Bio' => 'Про себе',
+    'Block' => 'Блокувати',
+    'Block status' => 'Блокування',
+    'Blocked at {0, date, MMMM dd, YYYY HH:mm}' => 'Заблоковано  {0, date, MMMM dd, YYYY HH:mm}',
+    'Change your avatar at Gravatar.com' => 'Змінити аватар на сайті Gravatar.com',
+    'Confirm' => 'Підтвердити',
+    'Confirmation' => 'Активація',
+    'Confirmed' => 'Активовано',
+    'Confirmed at {0, date, MMMM dd, YYYY HH:mm}' => 'Активовано {0, date, MMMM dd, YYYY HH:mm}',
+    'Connect' => 'Під\'єднати',
+    'Continue' => 'Продовжити',
+    'Create a user account' => 'Створити новий аккаунт',
+    'Current password' => 'Поточний пароль',
+    'Current password is not valid' => 'Поточний пароль введено невірно',
+    'Didn\'t receive confirmation message?' => 'Не прийшов лист?',
+    'Email' => 'Email',
+    'Email (public)' => 'Публічний email',
+    'Error occurred while changing password' => 'При зміні пароля виникла помилка',
+    'Error occurred while confirming user' => 'Виникла помилка при активації користувача',
+    'Error occurred while deleting user' => 'Виникла помилка при видаленні користувача',
+    'Finish' => 'Завершити',
+    'Forgot password?' => 'Забули пароль?',
+    'Gravatar email' => 'Gravatar email',
+    'Hello' => 'Доброго дня',
+    'If you already registered, sign in and connect this account on settings page' => 'Якщо ви вже зареєстровані, ввійдіть і підключіть аккаунт в налаштуваннях',
+    'If you cannot click the link, please try pasting the text into your browser' => 'Якщо Вам не вдається перейти за посиланням, то скопіюйте зазначену адресу та вставте в стрічку браузера.',//'Якщо по яким-небудь причинам посилання не працює, вставте наступну адресу в стрічку браузера',
+    'If you did not make this request you can ignore this email' => 'Рішення щодо надання доступу до особистого кабінету буде прийнято протягом 5 робочих днів',//'P.S. Якщо ви отримали це повідомлення про помилку, просто видаліть його',
+    'In order to complete your registration, please click the link below' => 'Для того щоб завершити процедуру реєстрації на електронному майданчику перейдіть за посиланням:',//'Чтобы завершить регистрацию, нажмите на ссылку ниже',
+    'In order to complete your request, please click the link below' => 'Для того щоб завершити запит, натисніть на посилання нижче',
+    'Information' => 'Інформація',
+    'Invalid login or password' => 'Неправильний логін або пароль',
+    'Joined on {0, date}' => 'Приєднався {0, date}',
+    'Location' => 'Місцерозташування',
+    'Login' => 'Логін',
+    'Logout' => 'Вийти',
+    'Manage users' => 'Управління користувачами',
+    'Name' => 'Ім\'я',
+    'Networks' => 'Соціальні мережі',
+    'New password' => 'Новий пароль',
+    'Password' => 'Пароль',
+    'Password has been changed' => 'Пароль було змінено',
+    'Please click the link below to complete your password reset' => 'Дял того, щоб відновити пароль, натисніть на посилання нижче',
+    'Please fix following errors:' => 'Виправте наступні помилки',
+    'Profile' => 'Профіль',
+    'Profile settings' => 'Налаштування профіля',
+    'Recover your password' => 'Відновити пароль',
+    'Registration ip' => 'Реєстраційний IP',
+    'Registration time' => 'Час реєстрації',
+    'Remember me next time' => 'Запам\'ятати мене',
+    'Request new confirmation message' => 'Повторна відправка інструкцій',
+    'Reset your password' => 'Скинути пароль',
+    'Save' => 'Зберегти',
+    'Sign in' => 'Авторизуватися',
+    'Sign up' => 'Зареєструватися',
+    //'Thank you for signing up on {0}' => 'Дякуємо за регістрацію на {0}',
+    'Thank you for signing up on' => 'Ваша заявка на реєстрацію на електронному майданчику погоджена оператором',
+    'There is no user with this email address' => 'Немає користувача з таким email',
+    'This account has already been confirmed' => 'Цей аккаунт вже було активовано',
+    'This account has already been connected to another user' => 'Цей аккаунт вже був прив\'язаний до іншого користувацького запису',
+    'Unblock' => 'Розблокувати',
+    'Update user account' => 'Обновити аккаунт користувача',
+    'User has been blocked' => 'Користувача було заблоковано',
+    'User has been confirmed' => 'Користувача було активовано',
+    'User has been created' => 'Користувача було створено',
+    'User has been deleted' => 'Користувача було видалено',
+    'User has been unblocked' => 'Користувача було розблоковано',
+    'User is not found' => 'Користувача не знайдено',
+    'Username' => 'Им\'я користувача',
+    'Users' => 'Користувачі',
+    'We have received a request to change the email address for your account on {0}' => 'Ви нещодавно запросили зміну email на {0}',
+    'We have received a request to reset the password for your account on {0}' => 'Ви нещодавно запросили зміну пароля на {0}',
+    'Website' => 'Вебсайт',
+    'Welcome to {0}' => 'Раді вас бачити на електронному майданчику',
+    'You need to confirm your email address' => 'Ваш аккаунт ще не пiдтвердженний',
+    'Your account has been blocked' => 'У Вас виникла проблема, можливо ви ввели не вiрний логiн або пароль або звернiться до адмiнiстратора',
+    'Your account has been created' => 'Ваш аккаунт було створено',
+    '{0, date, MMMM dd, YYYY HH:mm}' => '{0, date, MMMM dd, YYYY HH:mm}',
+];

+ 42 - 0
migrations/m181121_153329_create_bills_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `bills`.
+ */
+class m181121_153329_create_bills_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function Up()
+    {
+        $this->createTable('bills', [
+            'id' => $this->primaryKey(11),
+            'user_id' => $this->integer(11),
+            'type' => $this->string(15),
+            'bid_id' => $this->integer(11),
+            'payed' => $this->integer(1)->Null(),
+            'auction_id' => $this->integer(11),
+        ]);
+        $this->createIndex('idx-bills-userid', 'bills', 'user_id', 0);
+        $this->createIndex('idx-bills-type', 'bills', 'type', 0);
+        $this->createIndex('idx-bills-bidid', 'bills', 'bid_id', 0);
+        $this->createIndex('idx-bills-payed', 'bills', 'payed', 0);
+        $this->createIndex('idx-bills-aucid', 'bills', 'auction_id', 0);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function Down()
+    {
+        $this->dropIndex('idx-bills-userid','bills');
+        $this->dropIndex('idx-bills-type','bills');
+        $this->dropIndex('idx-bills-bidid','bills');
+        $this->dropIndex('idx-bills-payed','bills');
+        $this->dropIndex('idx-bills-aucid','bills');
+        $this->dropTable('bills');
+    }
+}

+ 107 - 0
models/Admin.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "user".
+ *
+ * @property integer $id
+ * @property string $username
+ * @property integer $role
+ * @property string $email
+ * @property string $fio
+ * @property string $at_org
+ * @property integer $org_type
+ * @property string $member_phone
+ * @property string $fax
+ * @property integer $status
+ * @property string $password_hash
+ * @property string $auth_key
+ * @property integer $confirmed_at
+ * @property string $unconfirmed_email
+ * @property integer $blocked_at
+ * @property string $registration_ip
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $flags
+ *
+ * @property SocialAccount[] $socialAccounts
+ * @property Token[] $tokens
+ */
+class Admin extends Profile
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'user';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['username', 'role', 'email', 'fio', 'at_org', 'org_type', 'member_phone', 'fax', 'password_hash', 'auth_key', 'created_at', 'updated_at'], 'required'],
+            [['role', 'org_type', 'status', 'confirmed_at', 'blocked_at', 'created_at', 'updated_at', 'flags'], 'integer'],
+            [['username'], 'string', 'max' => 25],
+            [['email', 'unconfirmed_email'], 'string', 'max' => 255],
+            [['fio'], 'string', 'max' => 50],
+            [['at_org'], 'string', 'max' => 30],
+            [['member_phone', 'fax'], 'string', 'max' => 12],
+            [['password_hash'], 'string', 'max' => 60],
+            [['auth_key'], 'string', 'max' => 32],
+            [['registration_ip'], 'string', 'max' => 45],
+            [['username'], 'unique'],
+            [['email'], 'unique']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'username' => Yii::t('app', 'Username'),
+            'role' => Yii::t('app', 'Role'),
+            'email' => Yii::t('app', 'Email'),
+            'fio' => Yii::t('app', 'Fio'),
+            'at_org' => Yii::t('app', 'At Org'),
+            'org_type' => Yii::t('app', 'Org Type'),
+            'member_phone' => Yii::t('app', 'Member Phone'),
+            'fax' => Yii::t('app', 'Fax'),
+            'status' => Yii::t('app', 'Status'),
+            'password_hash' => Yii::t('app', 'Password Hash'),
+            'auth_key' => Yii::t('app', 'Auth Key'),
+            'confirmed_at' => Yii::t('app', 'Confirmed At'),
+            'unconfirmed_email' => Yii::t('app', 'Unconfirmed Email'),
+            'blocked_at' => Yii::t('app', 'Blocked At'),
+            'registration_ip' => Yii::t('app', 'Registration Ip'),
+            'created_at' => Yii::t('app', 'Created At'),
+            'updated_at' => Yii::t('app', 'Updated At'),
+            'flags' => Yii::t('app', 'Flags'),
+        ];
+    }
+
+    /**
+     * @return \yii\db\ActiveQuery
+     */
+    public function getSocialAccounts()
+    {
+        return $this->hasMany(SocialAccount::className(), ['user_id' => 'id']);
+    }
+
+    /**
+     * @return \yii\db\ActiveQuery
+     */
+    public function getTokens()
+    {
+        return $this->hasMany(Token::className(), ['user_id' => 'id']);
+    }
+}

+ 79 - 0
models/Auclots.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "auclots".
+ *
+ * @property integer $id
+ * @property integer $user_id
+ * @property string $name
+ * @property integer $dogovor_id
+ * @property string $address
+ * @property string $payment_term
+ * @property string $payment_order
+ * @property string $member_require
+ * @property string $term_procedure
+ * @property integer $requisites_id
+ * @property string $bidding_date
+ */
+class Auclots extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'auclots';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['user_id', 'name', 'dogovor_id', 'payment_term', 'member_require', 'term_procedure', 'requisites_id', 'bidding_date','auction_date'], 'required'],
+            [['user_id', 'dogovor_id', 'requisites_id'], 'integer'],
+            [['bidding_date','auction_date','address','name','member_require'], 'safe'],
+            [['payment_term', 'payment_order', 'term_procedure'], 'string', 'max' => 5000]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'AucNumber ID'),
+            'user_id' => Yii::t('app', 'User ID'),
+            'name' => Yii::t('app', 'Назва аукціону'),
+            'dogovor_id' => Yii::t('app', 'Проект договору'),
+            'address' => Yii::t('app', 'AddressTo ID'),
+            'payment_term' => Yii::t('app', 'PaymentTerm ID'),
+            'payment_order' => Yii::t('app', 'Порядок формирования цен договора'),
+            'member_require' => Yii::t('app', 'MemberRequire ID'),
+            'term_procedure' => Yii::t('app', 'Терміни та порядок внесення фінансового забезпечення'),
+            'requisites_id' => Yii::t('app', 'Реквізити'),
+            'bidding_date' => Yii::t('app', 'BiddingDate ID'),
+            'auction_date'  =>  Yii::t('app', 'AuctionDate ID'),
+        ];
+    }
+
+    public function getRequisite()
+    {
+        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');
+    }
+}

+ 419 - 0
models/Auctions.php

@@ -0,0 +1,419 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "auctions".
+ *
+ * @property integer $id
+ * @property integer $user_id
+ * @property integer $lot_id
+ * @property integer $date_start
+ * @property integer $date_stop
+ * @property integer $last_price
+ * @property integer $last_user
+ * @property integer $last_date
+ * @property string $time_step_down
+ * @var $user User
+ * @var $lots Lots
+ */
+class Auctions extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'auctions';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['user_id', 'lot_id', 'date_start', 'date_stop', 'last_price', 'last_user', 'last_date'], 'required'],
+            [['user_id', 'lot_id', 'last_user','type','lot_num','status','type_id','temp_step_down','step_down'], 'integer'],
+            [['userName', 'lot', 'lotName','date_start', 'date_stop', 'last_price', 'last_date','name','bidding_date','time_step_down'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'name'  => Yii::t('app', 'AukName ID'),
+            'user_id' => Yii::t('app', 'организатор'),
+            'lot_id' => Yii::t('app', 'lot_id'),
+            'lot_num'   =>  Yii::t('app', 'Lot ID'),
+            'date_start' => Yii::t('app', 'AucStart ID'),
+            'date_stop' => Yii::t('app', 'DateStop ID'),
+            'bidding_date' => Yii::t('app', 'endBidding ID'),
+            'last_price' => Yii::t('app', 'текущая цена'),
+            'last_user' => Yii::t('app', 'ставка последнего юзера'),
+            'last_date' => Yii::t('app', 'время последней ставки'),
+            'lotName'   =>  Yii::t('app', 'Lot ID'),
+            'status'    =>  Yii::t('app', 'Status ID'),
+            'userName'    =>  Yii::t('app', 'OrgName ID'),
+            'type'  =>  Yii::t('app', 'AucType ID'),
+            'type_id'   =>  Yii::t('app', 'AucType ID'),
+            'time_step_down'   =>  Yii::t('app', 'Time Step'),
+            'lot'   =>  Yii::t('app', 'Lot'),
+        ];
+    }
+
+  /*  public function afterDelete()
+    {
+        parent::afterDelete();
+
+    }*/
+
+    public function CreateAuction($insert)
+    {
+
+        //$valid = $this->LotValidate($insert['lot_id']);
+        $model = new Auctions();
+        if (empty($insert['step_down'])) { $insert['step_down']=3; } // потом поправить на ауке на повышение
+        if (empty($insert['time_step_down'])) { $insert['time_step_down']="00:10"; }
+        $model->setAttributes([
+            'user_id' => $insert['user_id'],
+            'name'   =>  $insert['name'],
+            'lot_id' => $insert['lot_id'],
+            'lot_num' => $insert['lot_num'],
+            'date_start' => $insert['date_start'],
+            'bidding_date' => $insert['bidding_date'],
+            'last_date' => $insert['date_start'],
+            'date_stop' =>  $insert['date_stop'],
+            'type_id'   =>  $insert['type_id'],
+            'step_down' =>  $insert['step_down'],
+            'temp_step_down'    =>  $insert['step_down'],
+            'time_step_down'    =>  $insert['time_step_down'],
+            'status'    =>  '0',
+        ]);
+        $model->save(false);
+        return $model;
+
+    }
+
+    private function LotValidate($lot_id)
+    {
+        $command = Yii::$app->db->createCommand("SELECT * from auctions WHERE lot_id=:id");
+        $command->bindValue(':id', $lot_id);
+        $result = $command->queryOne();
+
+        if(!empty($result))
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    public function getLot()
+    {
+        return $this->hasOne(Lots::className(), ['id' => 'lot_id']);
+    }
+
+    /* public function getLotStartPrice()
+     {
+         return $this->hasOne(Lots::className(),['start_price' => 'lot_id']);
+     }*/
+
+
+    public function getCategory(){
+        return $this->hasOne(Category::className(), ['id' => 'category_id'])->via('lot');
+    }
+
+    public function getUser()
+    {
+        return $this->hasOne(User::className(), ['id' => 'user_id']);
+    }
+
+    public function getTrade()
+    {
+        return $this->hasMany(Trade::className(), ['auk_id' => 'id']);
+    }
+
+    public function getWinners(){
+        return $this->hasMany(Trade::className(), ['auk_id' => 'id']);
+    }
+
+    public function setFlags($value)
+    {
+        Yii::$app->session->set('user.flags',$value);
+    }
+
+    private function SendTime($last_date,$date_stop,$date_start)
+    {
+        if($this->type_id==1)
+        {
+            if ((strtotime($date_stop) - strtotime($last_date)) < 601) {
+                $step = 600;
+                $diff = strtotime(date("Y-m-d H:i:s")) - strtotime($last_date);
+                //$past_time = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
+                $diff_time = $step - $diff; // 1 Hours perenesti v adminky // 7200 for
+                return $diff_time;
+            } else {
+                $step = strtotime($date_stop) - strtotime($date_start);
+                $diff = strtotime(date("Y-m-d H:i:s")) - strtotime($date_start);
+                //$past_time = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
+                $diff_time = $step - $diff; // 1 Hours perenesti v adminky // 7200 for
+                return $diff_time;
+            }
+
+        }
+        if($this->type_id==2)
+        {
+            list($time,$null)=explode(".",$this->time_step_down);
+            sscanf($time, "%d:%d:%d", $hours, $minutes, $seconds);
+            $time_seconds = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
+            $m_step = $time_seconds + 1;
+
+            if ((strtotime($date_stop) - strtotime($last_date)) < $m_step) {
+                $step = $time_seconds;
+                $diff = strtotime(date("Y-m-d H:i:s")) - strtotime($last_date);
+                //$past_time = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
+                $diff_time = $step - $diff; // 1 Hours perenesti v adminky // 7200 for
+                return $diff_time;
+            } else {
+                $step = strtotime($date_stop) - strtotime($date_start);
+                $diff = strtotime(date("Y-m-d H:i:s")) - strtotime($date_start);
+                //$past_time = sprintf('%02d:%02d:%02d', $diff / 3600, ($diff % 3600) / 60, $diff % 60);
+                $diff_time = $step - $diff; // 1 Hours perenesti v adminky // 7200 for
+                return $diff_time;
+            }
+
+        }
+    }
+
+    private function SendPerc($last_date,$date_stop,$date_start)
+    {
+        if($this->type_id==1)
+        {
+            $diff = $this->SendTime($last_date,$date_stop,$date_start);
+            if((strtotime($date_stop) - strtotime($last_date)) < 601)
+            {
+                $step = 600;
+            }
+            else
+            {
+                $step = strtotime($date_stop) - strtotime($date_start);
+            }
+
+            $perc = 100 * $diff / $step; //100-100*у/х 100*х/у-100
+            return round($perc,2);
+        }
+        if($this->type_id==2)
+        {
+            //$m_step = 121;
+            $diff = $this->SendTime($last_date,$date_stop,$date_start);
+            if((strtotime($date_stop) - strtotime($last_date)) < 601)
+            {
+                $step = 600;
+            }
+            else
+            {
+                $step = strtotime($date_stop) - strtotime($date_start);
+            }
+
+            $perc = 100 * $diff / $step; //100-100*у/х 100*х/у-100
+            return round($perc,2);
+        }
+
+    }
+
+    private function CheckRole()
+    {
+        if(Yii::$app->user->can('admin'))
+        {
+            return true;
+        }
+        if(Yii::$app->user->can('watcher'))
+        {
+            return false;
+        }
+        else {
+            $sql = Yii::$app->db->createCommand("SELECT status from bidding WHERE auction_id=:auction_id and user_id=:user_id");
+            $sql->bindValues([':auction_id' => $this->id, ':user_id' => Yii::$app->user->identity->id]);
+            $res = $sql->queryOne();
+            if ($res == false) {
+                return false;
+
+            }  elseif ($res['status'] == "2") // 2=reject
+            {
+                return false;
+
+            } elseif ($res['status'] == "0") // 0=default
+            {
+                return false;
+
+            } elseif ($res['status'] == "1") // 0=accept
+            {
+                return true;
+            }
+        }
+    }
+
+    // for rest api
+    public function fields()
+    {
+        return [
+            'id',
+            'user_id',
+            'user_role' => function() {
+                return $this->CheckRole();
+            },
+            'lot_id',
+            'type_id'   =>  function () {
+                return $this->type_id;
+            },
+            'member_user_id' => function () {
+                return Yii::$app->user->identity->id;
+            },
+            'date_start'    => function($model)
+            {
+                return Yii::$app->formatter->asTime($model->date_start, "php:d.m.Y H:i:s");
+            },
+            'date_stop'    => function($model)
+            {
+                return Yii::$app->formatter->asTime($model->date_stop, "php:d.m.Y H:i:s");
+            },
+            'start_price' => function()
+            {
+                return $this->lot->start_price;
+            },
+            'step' => function()
+            {
+                return $this->lot->step;
+            },
+            'step_money' => function()
+            {
+                $step_money = $this->lot->start_price / 100 * $this->lot->step;
+                return round($step_money,2);
+            },
+            'delta_money'   =>  function()
+            {
+                if($this->type_id==1) {
+                    $delta_money = $this->last_price - $this->lot->start_price <= 0 ? 0 : $this->last_price - $this->lot->start_price;
+                    return round($delta_money, 2);
+                }
+                if($this->type_id==2) {
+                    $delta_money = $this->lot->start_price - $this->last_price <= 0 ? 0 : $this->lot->start_price - $this->last_price;
+                    return round($delta_money, 2);
+                }
+
+            },
+            'delta_perc' =>  function()
+            {
+                if($this->type_id==1) {
+                    $delta_perc = ($this->last_price - $this->lot->start_price) / ($this->lot->start_price / 100) <= 0 ? 0 : ($this->last_price - $this->lot->start_price) / ($this->lot->start_price / 100);
+                    return round($delta_perc, 2);
+                }
+                if($this->type_id==2) {
+                    $delta_perc = ($this->lot->start_price - $this->last_price) / ($this->lot->start_price / 100) <= 0 ? 0 : ($this->lot->start_price - $this->last_price) / ($this->lot->start_price / 100);
+                    return round($delta_perc, 2);
+                }
+
+            },
+            'last_user',
+            'next_price'    => function()
+            {
+                //$next_price = $this->last_price + ($this->lot->start_price / 100 * $this->lot->step);
+                //return round($next_price, 2);
+
+                if($this->type_id==1) {
+                    if($this->last_price=="0")
+                    {
+                        $next_price = $this->lot->start_price + ($this->lot->start_price / 100 * $this->lot->step);
+                        return round($next_price, 2); }
+                    //return round($this->lot->start_price, 2);}
+                    else
+                        $next_price = $this->last_price + ($this->lot->start_price / 100 * $this->lot->step);
+                    return round($next_price, 2);
+                }
+                if($this->type_id==2) {
+
+                    if ($this->last_price == "0" && $this->last_user == "0" && $this->temp_step_down != "0") {
+
+                        return round($this->lot->start_price, 2);
+                    }
+                    elseif ($this->last_user == "0")
+                    {
+                        $next_price = $this->last_price; //- ($this->lot->start_price / 100 * $this->lot->step);
+                        return round($next_price, 2);
+                    }
+                    else
+                    {
+                        $next_price = $this->last_price + ($this->lot->start_price / 100 * $this->lot->step);
+                        return round($next_price, 2);
+                    }
+                }
+
+            },
+            'time' => function()
+            {
+                $diff = $this->SendTime($this->last_date, $this->date_stop, $this->date_start); // $this->date_start for
+                if($diff > 0)
+                {
+                    return $diff;
+                }
+                else
+                {
+                    return 0;
+                }
+            },
+            //'diff'  =>  function()
+            //{
+            //    return strtotime($this->date_stop) - strtotime($this->last_date);
+            //},
+            'perc' => function()
+            {
+                $diff = $this->SendPerc($this->last_date,$this->date_stop, $this->date_start);
+                if($diff > 0)
+                {
+                    return $diff;
+                }
+                else
+                {
+                    return 0;
+                }
+            },
+            'last_price',
+            'status',
+            'current_time' => function($model){
+                return time();
+            },
+        ];
+    }
+
+    public function extraFields()
+    {
+        return [
+            //'date_start',
+            //'date_stop',
+        ];
+    }
+
+
+
+    public static function statusNames(){
+        return [
+            '0' => Yii::t('app','pMakeBidding ID'),
+            '1' => Yii::t('app','pWaitAuction ID'),
+            '2' => Yii::t('app','pMakeAuction ID'),
+            '3' => Yii::t('app','pMakeFinal ID'),
+            '4' =>  Yii::t('app','pEndTorg ID')
+        ];
+    }
+
+
+
+}

+ 76 - 0
models/AuctionsSearch.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+
+/**
+ * AuctionsSearch represents the model behind the search form about `app\models\Auctions`.
+ */
+class AuctionsSearch extends Auctions
+{
+    public $lot;
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'user_id', 'lot_id', 'date_start', 'bidding_date', 'last_price', 'last_user', 'last_date'], 'integer'],
+            [['userName', 'name'], 'safe'],
+            [['lot'], 'string']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Auctions::find();
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+            'sort' => [
+                'defaultOrder' => ['id' => SORT_DESC],
+            ]
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            return $dataProvider;
+        }
+
+        $query->joinWith(['lot', 'user']);
+
+        $query->andFilterWhere([
+            'date_start' => $this->date_start,
+            'bidding_date' => $this->date_stop,
+            'last_price' => $this->last_price,
+            'last_user' => $this->last_user,
+            'last_date' => $this->last_date,
+        ]);
+        $query->andFilterWhere(['like', 'lots.name', $this->lot]);
+        $query->andFilterWhere(['like', 'auctions.name', $this->name]);
+        //$query->andFilterWhere(['like','lots.start_price',$this->lot]);
+
+
+        return $dataProvider;
+    }
+}

+ 104 - 0
models/Bidding.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\helpers\ArrayHelper;
+
+/**
+ * This is the model class for table "bidding".
+ *
+ * @property integer $id
+ * @property integer $auction_id
+ * @property integer $user_id
+ * @property integer $status
+ */
+class Bidding extends ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public $cnt;
+
+    public static function tableName(){
+        return 'bidding';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules(){
+        return [
+            [['auction_id', 'user_id', 'status'], 'required'],
+            [['auction_id', 'user_id', 'org_id', 'status','file_id'], 'integer'],
+            [['auctionName','fileName','created_at'], 'safe'],
+            [['special_price'], 'number', 'integerOnly' => false],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels(){
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'auction_id' => Yii::t('app', 'Auction ID'),
+            'user_id' => Yii::t('app', 'User ID'),
+            'org_id'    =>  Yii::t('app', 'Org ID'),
+            'status' => Yii::t('app', 'Status'),
+            'auctionName'   =>  Yii::t('app', 'Auction ID'),
+            'fileName'   =>  Yii::t('app', 'FileName ID'),
+            'created_at'    =>  Yii::t('app', 'BiddingDate ID'),
+            'date_update' => Yii::t('app', 'Date Update'),
+            'special_price' => Yii::t('app', 'Спеціальна ставка'),
+        ];
+    }
+
+    public function CreateBid($insert){
+        $model = new Bidding();
+        $model->setAttributes([
+            'auction_id' => $insert['auction_id'],
+            'user_id' => $insert['user_id'],
+            'org_id'    => $insert['org_id'],
+            'file_id'    => $insert['file_id'],
+            'created_at' =>  date("Y-m-d H:i:s"),
+            'special_price' => $insert['special_price']
+        ]);
+        return $model->save(false) && Bills::create($model);
+    }
+
+    public function getAuction(){
+        return $this->hasOne(Auctions::className(), ['id' => 'auction_id']);
+    }
+
+    public function getLot(){
+        return $this->hasOne(Lots::className(), ['id' => 'lot_id'])->via('auction');
+    }
+
+    public function getUser(){
+        return $this->hasOne(User::className(), ['id' => 'user_id']);
+    }
+
+    public function getProfile(){
+        return $this->hasOne(Profile::className(), ['user_id' => 'id'])->via('user');
+    }
+
+    public function getAuctionName(){
+        return ArrayHelper::getValue($this->auction,'name');
+        //return $this->auction->name;
+    }
+
+    public function getFile(){
+        return $this->hasOne(Files::className(), ['id' => 'file_id']);
+    }
+
+    public function getFileName(){
+        return $this->file->name;
+    }
+
+
+
+
+
+}

+ 103 - 0
models/Bills.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+
+/**
+ * This is the model class for table "bills".
+ *
+ * @property int $id
+ * @property int $user_id
+ * @property string $type
+ * @property int $lot_id
+ * @property User $user
+ */
+class Bills extends \yii\db\ActiveRecord {
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName() {
+        return 'bills';
+    }
+
+    /*
+         * without migrations
+         * */
+
+    public static function create(Bidding $bid) {
+        $data = [
+            'user_id' => Yii::$app->user->id,
+            'type' => 'guarantee',
+            'bid_id' => $bid->id,
+            'payed' => 0,
+            'auction_id' => $bid->auction_id,
+        ];
+        (new Bills($data))->save(false);
+        $data['type'] = 'registration';
+        (new Bills($data))->save(false);
+        return true;
+    }
+
+    public static function types() {
+        return
+            [
+                'guarantee' => Yii::t('app', 'Guaranteed payment'),
+                'registration' => Yii::t('app', 'Registration fee'),
+            ];
+    }
+
+    public static function payStatuses() {
+        return
+            [
+                '0' => Yii::t('app','Нові'),
+                '1' => Yii::t('app','Сплачено'),
+                '2' => Yii::t('app','Не сплачено'),
+            ];
+    }
+
+    public function rules() {
+        return [
+            [['user_id', 'type', 'bid_id'], 'required'],
+            [['user_id','auction_id' ,'bid_id'], 'integer'],
+            [['type'], 'in', 'range' => array_keys(static::types())],
+            [['payed'], 'in', 'range' => array_keys(static::payStatuses())],
+        ];
+    }
+
+//    public function getLotName() {
+//        return $this->hasOne(Lots::className(), );
+//    }
+
+    public function getBid() {
+        return $this->hasOne(Bidding::className(), ['id' => 'bid_id']);
+    }
+
+    public function getAuction() {
+        return $this->hasOne(Auctions::className(), ['id' => 'auction_id'])->via('bid');
+    }
+
+    public function getUser() {
+        return $this->hasOne(User::className(), ['id' =>'user_id']);
+    }
+
+    public function getProfile() {
+        return $this->hasOne(Profile::className(), ['user_id' => 'user_id']);
+    }
+
+    public function getRequisite() {
+        return $this->hasOne(Requisites::className(), ['user_id' => 'user_id']);
+    }
+    public function attributeLabels() {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'user_id' => Yii::t('app', 'User ID'),
+            'type' => Yii::t('app', 'Bill type'),
+            'bid_id' => Yii::t('app', 'Ставка №'),
+            'payed' => Yii::t('app', 'Payed'),
+            'auction_id' => Yii::t('app', 'ID Аукціонa'),
+            'user_at_org' => Yii::t('app', 'Company full name'),
+        ];
+    }
+}

+ 57 - 0
models/BillsSearch.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Bills;
+
+/**
+ * BillsSearch represents the model behind the search form of `app\models\Bills`.
+ */
+class BillsSearch extends Bills
+{
+    public $user_at_org;
+    public $auction_id;
+
+    public function rules()
+    {
+        return [
+            [['user_id', 'auction_id', 'bid_id'], 'integer'],
+            [['type'], 'safe'],
+            [['user_at_org'], 'string', 'max' => 255],
+            [['payed'], 'in', 'range' => array_keys(Bills::payStatuses())],
+        ];
+    }
+
+    public function search($params)
+    {
+        $query = Bills::find();
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+            'sort' => [
+                'defaultOrder' => [
+                    'payed' => SORT_ASC,
+                ],
+            ],
+        ]);
+        $this->load($params);
+        if (!$this->validate()) {
+            return $dataProvider;
+        }
+        $query->joinWith(['user', 'auction']);
+        $query->andFilterWhere([
+            'user_id' => $this->user_id,
+            'bid_id' => $this->bid_id,
+            'bills.type' => $this->type,
+            'bills.payed' => $this->payed,
+        ]);
+
+        $query->andFilterWhere([
+            'bidding.auction_id' => $this->auction_id,
+        ]);
+        $query->andFilterWhere(['like', 'user.at_org', $this->user_at_org]);
+        return $dataProvider;
+    }
+}

+ 96 - 0
models/BlogPosts.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\models;
+
+
+use Yii;
+use yii\behaviors\SluggableBehavior;
+use yii\web\UploadedFile;
+
+/**
+ */
+class BlogPosts extends \yii\db\ActiveRecord
+{
+    public $imageFile;
+
+    public static function tableName()
+    {
+        return 'blogposts';
+    }
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => SluggableBehavior::className(),
+                'attribute' => 'title',
+                'slugAttribute' => 'slug',
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['title', 'text', 'cat_id','description','key_words','h1','short_text'], 'required'],
+            [['text','short_text','slug','text_ru','short_text_ru'], 'string'],
+            [['cat_id', 'created_at'], 'integer'],
+            [['title', 'picture','description','key_words','h1','title_ru','description_ru','key_words_ru','h1_ru'], 'string', 'max' => 255],
+            [['title','slug'], 'unique'],
+            [['imageFile'],'file','extensions' => 'png, jpg, gif']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'title' => Yii::t('app', 'Title'),
+            'description' => Yii::t('app', 'Description'),
+            'key_words' => Yii::t('app', 'Key words'),
+            'text' => Yii::t('app', 'Text'),
+            'imageFile' => Yii::t('app', 'Picture'),
+            'cat_id' => Yii::t('app', 'Cat ID'),
+            'h1' => Yii::t('app', 'H1'),
+            'short_text' => Yii::t('app','Short text'),
+            'title_ru' => Yii::t('app', 'Title ru'),
+            'text_ru' => Yii::t('app', 'Text ru'),
+            'cat_id_ru' => Yii::t('app', 'Cat ID ru'),
+            'h1_ru' => Yii::t('app', 'H1 ru'),
+            'short_text_ru' => Yii::t('app','Short text ru'),
+            'slug' => Yii::t('app','Slug'),
+        ];
+    }
+
+    public function getPicture()
+    {
+        return $this->picture ? '/'. $this->picture : false ;
+    }
+
+    public function getCategory()
+    {
+        return $this->hasOne(Categoriesblog::className(),['id' => 'cat_id']);
+    }
+
+    public function getShort($length = 600){
+        return mb_strlen($this->text, 'utf-8') > $length ? mb_substr($this->text, 0, $length, 'utf-8') . '...' : $this->text;
+    }
+
+    public function getLogo()
+    {
+        return $this->picture ? '/'. $this->picture : false ;
+    }
+
+    public function upload(){
+
+        if(false != ($file = UploadedFile::getInstance($this, 'picture'))){
+            $filename = time() . $file->baseName . '.' . $file->extension;
+            $path = 'uploads/posts';
+            if($file->saveAs($path . DIRECTORY_SEPARATOR . $filename)){
+                $this->picture = $filename;
+                return $this->save();
+            }
+        }
+        return $this->save();
+    }
+
+}

+ 87 - 0
models/BlogPostsSearch.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace app\models;
+
+use app\models\Categoriesblog;
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\BlogPosts;
+
+/**
+ * BlogPostsSearch represents the model behind the search form about `app\models\BlogPosts`.
+ */
+class BlogPostsSearch extends BlogPosts
+{
+    public $categorySlug;
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'cat_id'], 'integer'],
+            [['title', 'text', 'picture','categorySlug','description','key_words',], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params, $formName = 'BlogPostsSearch')
+    {
+        $query = BlogPosts::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+            'sort' => [
+                'defaultOrder'=>[
+                    'id'=> SORT_DESC
+                ],
+            ],
+            'pagination'=>[
+                'pageSize' => 6,
+            ],
+        ]);
+
+        $this->load($params,$formName);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        $query->joinWith('category');
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'cat_id' => $this->cat_id,
+        ]);
+
+        $query->andFilterWhere(['like', 'title', $this->title])
+            ->andFilterWhere(['like', 'text', $this->text])
+            ->andFilterWhere(['like', 'picture', $this->picture])
+            ->andFilterWhere(['like', 'posts.description', $this->description])
+            ->andFilterWhere(['like', 'key_words', $this->key_words])
+            ->andFilterWhere(['like', 'categoriesblog.slug', $this->categorySlug]);
+
+        return $dataProvider;
+    }
+}

+ 63 - 0
models/Cabinet.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "cabinet".
+ *
+ * @property integer $id
+ * @property integer $user_id
+ * @property integer $client_id
+ * @property integer $messages_id
+ * @property integer $auk_type
+ * @property integer $reports_id
+ * @property string $description
+ */
+class Cabinet extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'auctions';
+    }
+
+    public function rules()
+    {
+        return [
+            [['user_id', 'name', 'dogovor_id', 'address', 'payment_term', 'payment_order', 'member_require', 'term_procedure', 'requisites_id', 'bidding_date'], 'required'],
+            [['user_id', 'dogovor_id', 'requisites_id'], 'integer'],
+            [['bidding_date'], 'safe'],
+            [['name'], 'string', 'max' => 30],
+            [['address'], 'string', 'max' => 40],
+            [['payment_term', 'payment_order', 'member_require', 'term_procedure'], 'string', 'max' => 255]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'AucNumber ID'),
+            'user_id' => Yii::t('app', 'User ID'),
+            'name' => Yii::t('app', 'Назва аукціону'),
+            'dogovor_id' => Yii::t('app', 'Проект договору'),
+            'address' => Yii::t('app', 'AddressTo ID'),
+            'payment_term' => Yii::t('app', 'Условия оплаты'),
+            'payment_order' => Yii::t('app', 'Порядок формирования цен договора'),
+            'member_require' => Yii::t('app', ' Вимоги до учасників торгів'),
+            'term_procedure' => Yii::t('app', 'Терміни та порядок внесення фінансового забезпечення'),
+            'requisites_id' => Yii::t('app', 'Реквізити'),
+            'bidding_date' => Yii::t('app', 'BiddingDate ID'),
+        ];
+    }
+    public function getLot()
+    {
+        return $this->hasOne(Lots::className(), ['id' => 'lot_id']);
+    }
+}

+ 53 - 0
models/Categoriesblog.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\behaviors\SluggableBehavior;
+use app\models\Posts;
+use v0lume\yii2\metaTags\MetaTagBehavior;
+
+/**
+ */
+class Categoriesblog extends \yii\db\ActiveRecord
+{
+
+    public static function tableName()
+    {
+        return 'categoriesblog';
+    }
+
+    //Поведение ( реализация слагов)
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => SluggableBehavior::className(),
+                'attribute' => 'title',
+                'slugAttribute' => 'slug',
+            ],
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['title', 'description', 'key_words'], 'required'],
+            [['title','title_ru'], 'string', 'max' => 100],
+            [['description', 'key_words','description_ru', 'key_words_ru','slug'], 'string', 'max' => 255],
+            [['title','title_ru'], 'unique'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'title' => Yii::t('app', 'Title'),
+            'description' => Yii::t('app', 'Description'),
+            'key_words' => Yii::t('app', 'Key Words'),
+        ];
+    }
+
+
+}

+ 69 - 0
models/CategoriesblogSearch.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Categoriesblog;
+
+
+class CategoriesblogSearch extends Categoriesblog
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'integer'],
+            [['title', 'description', 'key_words'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Categoriesblog::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+        ]);
+
+        $query->andFilterWhere(['like', 'title', $this->title])
+            ->andFilterWhere(['like', 'description', $this->description])
+            ->andFilterWhere(['like', 'key_words', $this->key_words]);
+
+        return $dataProvider;
+    }
+}

+ 44 - 0
models/Category.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "category".
+ *
+ * @property integer $id
+ * @property string $name
+ */
+class Category extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'category';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['name'], 'required'],
+            [['name'], 'string', 'max' => 255]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'name' => Yii::t('app', 'Category Name'),
+        ];
+    }
+}

+ 63 - 0
models/ContactForm.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+
+/**
+ * ContactForm is the model behind the contact form.
+ */
+class ContactForm extends Model
+{
+    public $name;
+    public $email;
+    public $subject;
+    public $body;
+    public $verifyCode;
+
+    /**
+     * @return array the validation rules.
+     */
+    public function rules()
+    {
+        return [
+            // name, email, subject and body are required
+            [['name', 'email', 'subject', 'body'], 'required'],
+            // email has to be a valid email address
+            ['email', 'email'],
+            // verifyCode needs to be entered correctly
+            ['verifyCode', 'captcha'],
+        ];
+    }
+
+    /**
+     * @return array customized attribute labels
+     */
+    public function attributeLabels()
+    {
+        return [
+            'verifyCode' => 'Verification Code',
+        ];
+    }
+
+    /**
+     * Sends an email to the specified email address using the information collected by this model.
+     * @param  string  $email the target email address
+     * @return boolean whether the model passes validation
+     */
+    public function contact($email)
+    {
+        if ($this->validate()) {
+            Yii::$app->mailer->compose()
+                ->setTo($email)
+                ->setFrom([$this->email => $this->name])
+                ->setSubject($this->subject)
+                ->setTextBody($this->body)
+                ->send();
+
+            return true;
+        }
+        return false;
+    }
+}

+ 131 - 0
models/DocumentsToTheUser.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\helpers\FileHelper;
+use yii\web\UploadedFile;
+use Zend\Validator\File\Upload;
+
+/**
+ * This is the model class for table "documents_to_the_user".
+ *
+ * @property integer $id
+ * @property string $title
+ * @property string $path
+ */
+class DocumentsToTheUser extends \yii\db\ActiveRecord
+{
+
+    public $files;
+
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'documents_to_the_user';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['title'], 'required'],
+            [['title'], 'string', 'max' => 255],
+            [['files'],'file'],
+            [['path'], 'safe'],
+            [['menu_to_the_user_id'],'integer'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'title' => Yii::t('app','Title Document User'),
+            'files' => 'Files',
+            'menu_to_the_user_id' => Yii::t('app','menuToTheUser ID')
+        ];
+    }
+
+    public function upload()
+    {
+        if(false != ($file = UploadedFile::getInstance($this, 'files'))){
+            $filename = time() . "_{$file->baseName}.{$file->extension}";
+            $filename = self::transliteration($filename);
+            $path = 'uploads/documents-to-the-user';
+            FileHelper::createDirectory($path);
+            if($this->save()){
+                if($file->saveAs("{$path}/{$filename}")){
+                    return $this->updateAttributes(['path' => "{$path}/{$filename}"]);
+                }
+                return false;
+            }
+        }
+        return false;
+    }
+
+    public static function transliteration($str)
+    {
+        // ГОСТ 7.79B
+        $transliteration = array(
+            'А' => 'A', 'а' => 'a',
+            'Б' => 'B', 'б' => 'b',
+            'В' => 'V', 'в' => 'v',
+            'Г' => 'G', 'г' => 'g',
+            'Д' => 'D', 'д' => 'd',
+            'Е' => 'E', 'е' => 'e',
+            'Ё' => 'Yo', 'ё' => 'yo',
+            'Ж' => 'Zh', 'ж' => 'zh',
+            'З' => 'Z', 'з' => 'z',
+            'И' => 'I', 'и' => 'i',
+            'Й' => 'J', 'й' => 'j',
+            'К' => 'K', 'к' => 'k',
+            'Л' => 'L', 'л' => 'l',
+            'М' => 'M', 'м' => 'm',
+            'Н' => "N", 'н' => 'n',
+            'О' => 'O', 'о' => 'o',
+            'П' => 'P', 'п' => 'p',
+            'Р' => 'R', 'р' => 'r',
+            'С' => 'S', 'с' => 's',
+            'Т' => 'T', 'т' => 't',
+            'У' => 'U', 'у' => 'u',
+            'Ф' => 'F', 'ф' => 'f',
+            'Х' => 'H', 'х' => 'h',
+            'Ц' => 'Cz', 'ц' => 'cz',
+            'Ч' => 'Ch', 'ч' => 'ch',
+            'Ш' => 'Sh', 'ш' => 'sh',
+            'Щ' => 'Shh', 'щ' => 'shh',
+            'Ъ' => 'ʺ', 'ъ' => 'ʺ',
+            'Ы' => 'Y`', 'ы' => 'y`',
+            'Ь' => '', 'ь' => '',
+            'Э' => 'E`', 'э' => 'e`',
+            'Ю' => 'Yu', 'ю' => 'yu',
+            'Я' => 'Ya', 'я' => 'ya',
+            '№' => '#', 'Ӏ' => '‡',
+            '’' => '`', 'ˮ' => '¨',
+        );
+
+        $str = strtr($str, $transliteration);
+        $str = mb_strtolower($str, 'UTF-8');
+        $str = preg_replace('/[^0-9a-z.\-]/', '', $str);
+        $str = preg_replace('|([-]+)|s', '-', $str);
+        $str = trim($str, '-');
+
+        //return time() . '_' . $str;
+        return $str;
+    }
+
+    public function getMenu()
+    {
+        return $this->hasOne(MenuToTheUser::className(), ['id' => 'menu_to_the_user_id']);
+    }
+
+}

+ 70 - 0
models/DocumentsToTheUserSearch.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\DocumentsToTheUser;
+
+/**
+ * DocumentsToTheUserSearch represents the model behind the search form about `app\models\DocumentsToTheUser`.
+ */
+class DocumentsToTheUserSearch extends DocumentsToTheUser
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id'], 'integer'],
+            [['title', 'files'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = DocumentsToTheUser::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+        ]);
+
+        $query->andFilterWhere(['like', 'title', $this->title])
+            ->andFilterWhere(['like', 'path', $this->path]);
+
+        return $dataProvider;
+    }
+}

+ 94 - 0
models/Eventlog.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "eventlog".
+ *
+ * @property integer $id
+ * @property string $ip
+ * @property integer $user_id
+ * @property integer $auk_id
+ * @property string $action
+ * @property string $date
+ */
+class Eventlog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'eventlog';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['ip', 'user_id', 'auk_id', 'action', 'date'], 'required'],
+            [['user_id', 'auk_id'], 'integer'],
+            [['date'], 'safe'],
+            [['ip'], 'string', 'max' => 20],
+            [['action'], 'string', 'max' => 255],
+
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'ip' => Yii::t('app','Ip ID'),
+            'user_id' => Yii::t('app','User ID'),
+            'auk_id' => Yii::t('app','TradeLog'),
+            'action' => Yii::t('app','Action ID'),
+            'date' => Yii::t('app','Date'),
+            'at_org' => Yii::t('app','User ID'),
+            'name' => Yii::t('app','AukName ID'),
+
+        ];
+    }
+    public function PutLog($insert)
+    {
+        $model = new Eventlog();
+        $model->setAttributes([
+            'user_id' => $insert['user_id'],
+            'ip' => $insert['ip'],
+            'auk_id' => isset($insert['auk_id'] ) ? $insert['auk_id'] : '',
+            'action' => $insert['action'],
+            'date' => date("Y-m-d H:i:s"),
+        ]);
+        $model->save(false);
+        return true;
+    }
+    function getUser()
+    {
+        return $this->hasOne(User::className(),['id'   =>  'user_id']);
+    }
+    function getAuctions()
+    {
+        return $this->hasOne(Auctions::className(),['id'   =>  'auk_id']);
+    }
+    public function getLots()
+    {
+        return $this->hasOne(Lots::className(), ['id' => 'lot_id'])->via('auctions');
+    }
+
+    /**
+     * @inheritdoc
+     * @return EventlogQuery the active query used by this AR class.
+     */
+    public static function find()
+    {
+        return new EventlogQuery(get_called_class());
+    }
+}

+ 35 - 0
models/EventlogQuery.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\models;
+
+/**
+ * This is the ActiveQuery class for [[Eventlog]].
+ *
+ * @see Eventlog
+ */
+class EventlogQuery extends \yii\db\ActiveQuery
+{
+    /*public function active()
+    {
+        $this->andWhere('[[status]]=1');
+        return $this;
+    }*/
+
+    /**
+     * @inheritdoc
+     * @return Eventlog[]|array
+     */
+    public function all($db = null)
+    {
+        return parent::all($db);
+    }
+
+    /**
+     * @inheritdoc
+     * @return Eventlog|array|null
+     */
+    public function one($db = null)
+    {
+        return parent::one($db);
+    }
+}

+ 91 - 0
models/EventlogSearch.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Eventlog;
+
+/**
+ * EventlogSearch represents the model behind the search form about `app\models\Eventlog`.
+ */
+class EventlogSearch extends Eventlog
+{
+    /**
+     * @inheritdoc
+     */
+    public $at_org;
+    public $name;
+
+    public function rules()
+    {
+        return [
+            [['id', 'user_id', 'auk_id'], 'integer'],
+            [['ip', 'action', 'at_org','name','date'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Eventlog::find();
+        $query->joinWith('user');
+        $query->joinWith('auctions');
+        $query->joinWith('lots');
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+            'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]],
+        ]);
+
+        $dataProvider->sort->attributes['at_org'] = [
+                    'asc' => ['user.at_org' => SORT_ASC],
+                    'desc' => ['user.at_org' => SORT_DESC],
+                ];
+        $dataProvider->sort->attributes['name'] = [
+            'asc' => ['lots.name' => SORT_ASC],
+            'desc' => ['lots.name' => SORT_DESC],
+        ];
+
+        //$dataProvider->sort['defaultOrder'] = ['eventlog.id' => SORT_DESC];
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        $query->andFilterWhere([
+            //'id' => $this->id,
+            //'user_id' => $this->user_id,
+            'auk_id' => $this->auk_id,
+            //'date' => $this->date,
+        ]);
+
+        $query->andFilterWhere(['like', 'ip', $this->ip])
+            ->andFilterWhere(['like', 'at_org', $this->at_org])
+            ->andFilterWhere(['like', 'lots.name', $this->name])
+            ->andFilterWhere(['like', 'action', $this->action])
+        ->andFilterWhere(['like', 'eventlog.date', $this->date]);
+
+        return $dataProvider;
+    }
+}

+ 237 - 0
models/Files.php

@@ -0,0 +1,237 @@
+<?php
+
+namespace app\models;
+
+
+use Yii;
+use yii\helpers\FileHelper;
+use yii\web\UploadedFile;
+use zip\lib\createDirZip;
+use app\models\User;
+
+
+/**
+ * This is the model class for table "files".
+ *
+ * @property integer $id
+ * @property string $path
+ */
+//Yii::$app->params['uploadPath'] = "../uploads/".Yii::$app->user->identity->id."/";
+
+class Files extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public $file;
+    public $uploads = '../uploads/';
+
+
+
+    public static function tableName()
+    {
+        return 'files';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    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']],
+
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'path' => Yii::t('app', 'Path'),
+            'name' => Yii::t('app', 'file name'),
+            'user_id' => Yii::t('app', 'owner'),
+            'auction_id' => Yii::t('app', 'auction_id'),
+            'lot_id' => Yii::t('app', 'lot_id'),
+            'date'=> Yii::t('app','date'),
+        ];
+    }
+
+
+    public function saveFile($insert)
+    {   if(empty($insert['type'])) { $insert['type'] = null; }
+        //var_dump($saveFile); exit;
+        Yii::$app->db->createCommand()->insert(
+            'files', [
+                        'name' => $insert['name'],
+                        'path' => $insert['path'],
+                        'user_id' => $insert['user_id'],
+                        'auction_id' => $insert['auction_id'],
+                        'lot_id' => $insert['lot_id'],
+                        'type' => $insert['type'],
+        ])
+            ->execute();
+        return $this->getFileID($insert['user_id'],$insert['lot_id'],$insert['name']);
+    }
+
+    public function updateFile($update)
+    {
+        Yii::$app->db->createCommand("UPDATE `files` SET name='".$update['name']."' WHERE `id`=" . $update['file_id'])->execute();
+        return true;
+    }
+
+    private function getFileID($user,$lot,$name)
+    {
+        $res = $this->find()->where(['user_id'=>$user,'lot_id'=>$lot,'name'=>$name])->one();
+        return $res->id;
+    }
+
+    public static function transliteration($str)
+    {
+        // ГОСТ 7.79B
+        $transliteration = array(
+            'А' => 'A', 'а' => 'a',
+            'Б' => 'B', 'б' => 'b',
+            'В' => 'V', 'в' => 'v',
+            'Г' => 'G', 'г' => 'g',
+            'Д' => 'D', 'д' => 'd',
+            'Е' => 'E', 'е' => 'e',
+            'Ё' => 'Yo', 'ё' => 'yo',
+            'Ж' => 'Zh', 'ж' => 'zh',
+            'З' => 'Z', 'з' => 'z',
+            'И' => 'I', 'и' => 'i',
+            'Й' => 'J', 'й' => 'j',
+            'К' => 'K', 'к' => 'k',
+            'Л' => 'L', 'л' => 'l',
+            'М' => 'M', 'м' => 'm',
+            'Н' => "N", 'н' => 'n',
+            'О' => 'O', 'о' => 'o',
+            'П' => 'P', 'п' => 'p',
+            'Р' => 'R', 'р' => 'r',
+            'С' => 'S', 'с' => 's',
+            'Т' => 'T', 'т' => 't',
+            'У' => 'U', 'у' => 'u',
+            'Ф' => 'F', 'ф' => 'f',
+            'Х' => 'H', 'х' => 'h',
+            'Ц' => 'Cz', 'ц' => 'cz',
+            'Ч' => 'Ch', 'ч' => 'ch',
+            'Ш' => 'Sh', 'ш' => 'sh',
+            'Щ' => 'Shh', 'щ' => 'shh',
+            'Ъ' => 'ʺ', 'ъ' => 'ʺ',
+            'Ы' => 'Y`', 'ы' => 'y`',
+            'Ь' => '', 'ь' => '',
+            'Э' => 'E`', 'э' => 'e`',
+            'Ю' => 'Yu', 'ю' => 'yu',
+            'Я' => 'Ya', 'я' => 'ya',
+            '№' => '#', 'Ӏ' => '‡',
+            '’' => '`', 'ˮ' => '¨',
+        );
+
+        $str = strtr($str, $transliteration);
+        $str = mb_strtolower($str, 'UTF-8');
+        $str = preg_replace('/[^0-9a-z.\-]/', '', $str);
+        $str = preg_replace('|([-]+)|s', '-', $str);
+        $str = trim($str, '-');
+
+        //return time() . '_' . $str;
+        return $str;
+    }
+
+    public function fileName()
+    {
+        return Yii::$app->user->identity->username.date('ymdhis'); //dir name
+    }
+
+
+    public function uploadFile()
+    {
+        $docs = UploadedFile::getInstances($this, 'file');
+        $fileName = $this->fileName();
+
+        $dir = FileHelper::createDirectory($this->uploads.$fileName); //create dir
+        $saved = false;
+
+        foreach ($docs as $k => $file){
+            $file->name = $this->transliteration($file->name);
+            $saved = $file->saveAs($this->uploads.$fileName.'/'. $file->name) || $saved ; // move upload file to dir
+        }
+
+        /**
+         * CREATE ZIP
+         */
+
+        $createZip = new createDirZip();
+
+        $createZip->get_files_from_folder($this->uploads . $fileName.'/','');
+
+        /**
+         * DElETE UPLOADS DIR
+         */
+        FileHelper::removeDirectory($this->uploads.$fileName);
+
+        $fileName .= '.zip';
+
+        $fd = fopen($this->uploads.$fileName, 'wb');
+
+        $out = fwrite ($fd, $createZip->getZippedfile());
+
+        fclose ($fd);
+        //$createZip->forceDownload($fileName); // start download archive
+
+        return $saved ? $fileName : false;
+    }
+
+  public function getUser()
+  {
+      return $this->hasOne(User::className(),['id' => 'user_id']);
+  }
+
+  public function copy($lot_id)
+  {
+      $path = str_replace($this->lot_id,$lot_id,$this->path.$this->name);
+
+      //string(38) "../uploads/lots/neiron180223093830.zip"
+
+      $directoryPath = explode('/', $path);
+      //array(4) { [0]=> string(2) ".." [1]=> string(7) "uploads" [2]=> string(4) "lots" [3]=> string(22) "neiron180223093830.zip" }
+
+      $name = end($directoryPath);
+      //string(22) "neiron180223093830.zip"
+
+      array_pop($directoryPath);
+      //string(4) "lots"
+
+
+      $directoryPath = implode('/', $directoryPath).'/clone/'.$this->lot_id.'_'.date('now').'/';
+      //string(51) "../uploads/lots/clone/neiron180223093830.zip220185/"
+      //var_dump($directoryPath);die();
+
+      $copyFileName = $directoryPath.$name;
+
+      FileHelper::createDirectory($directoryPath);
+
+      copy($this->path.$this->name,$copyFileName);
+
+      $model = new Files();
+
+      $data = $this->attributes;
+
+      $data['path'] = $directoryPath;
+      $data['name'] = $name;
+
+      $data['lot_id'] = $lot_id;
+      $model->load($data, '');
+      return $model->save(false) ? $model->id : false;
+  }
+
+}

+ 94 - 0
models/FilesSearch.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+
+use kartik\daterange\DateRangeBehavior;
+
+/**
+ * FilesSearch represents the model behind the search form about `app\models\Files`.
+ */
+class FilesSearch extends Files
+{
+    public $createTimeRange;
+    public $createTimeStart;
+    public $createTimeEnd;
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => DateRangeBehavior::className(),
+                'attribute' => 'createTimeRange',
+                'dateStartAttribute' => 'createTimeStart',
+                'dateEndAttribute' => 'createTimeEnd',
+            ]
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'user_id', 'auction_id', 'lot_id'], 'integer'],
+            [['path', 'name'], 'safe'],
+            [['createTimeRange'], 'match', 'pattern' => '/^.+\s\-\s.+$/'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Files::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'user_id' => $this->user_id,
+            'auction_id' => $this->auction_id,
+            'lot_id' => $this->lot_id,
+        ]);
+
+        $query->andFilterWhere(['like', 'path', $this->path])
+            ->andFilterWhere(['like', 'name', $this->name]);
+
+
+        $query->andFilterWhere(['>=', 'createdAt', $this->createTimeStart])
+            ->andFilterWhere(['<', 'createdAt', $this->createTimeEnd]);
+
+        return $dataProvider;
+    }
+}

+ 85 - 0
models/Help.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\behaviors\SluggableBehavior;
+
+/**
+ * This is the model class for table "help".
+ *
+ * @property integer $id
+ * @property string $title
+ * @property string $h1
+ * @property string $short_text
+ * @property string $text
+ * @property string $description
+ * @property string $key_words
+ * @property integer $cat_id
+ * @property string $slug
+ * @property integer $created_at
+ *
+ * @property HelpCategory $cat
+ */
+class Help extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'help';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => SluggableBehavior::className(),
+                'attribute' => 'title',
+                'slugAttribute' => 'slug',
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['title', 'h1', 'short_text', 'text', 'description', 'key_words', 'cat_id', 'slug'], 'required'],
+            [['short_text', 'text'], 'string'],
+            [['cat_id', 'created_at'], 'integer'],
+            [['title', 'h1', 'description', 'key_words', 'slug'], 'string', 'max' => 255],
+            [['cat_id'], 'exist', 'skipOnError' => true, 'targetClass' => HelpCategory::className(), 'targetAttribute' => ['cat_id' => 'id']],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'title' => Yii::t('app', 'Title'),
+            'h1' => Yii::t('app', 'H1'),
+            'short_text' => Yii::t('app', 'Short Text'),
+            'text' => Yii::t('app', 'Text'),
+            'description' => Yii::t('app', 'Description'),
+            'key_words' => Yii::t('app', 'Key Words'),
+            'cat_id' => Yii::t('app', 'Cat ID'),
+            'slug' => Yii::t('app', 'Slug'),
+            'created_at' => Yii::t('app', 'Created At'),
+        ];
+    }
+
+    /**
+     * @return \yii\db\ActiveQuery
+     */
+    public function getCat()
+    {
+        return $this->hasOne(HelpCategory::className(), ['id' => 'cat_id']);
+    }
+}

+ 71 - 0
models/HelpCategory.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\behaviors\SluggableBehavior;
+
+/**
+ * This is the model class for table "help_category".
+ *
+ * @property integer $id
+ * @property string $title
+ * @property string $description
+ * @property string $key_words
+ * @property string $slug
+ *
+ * @property Help[] $helps
+ */
+class HelpCategory extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'help_category';
+    }
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => SluggableBehavior::className(),
+                'attribute' => 'title',
+                'slugAttribute' => 'slug',
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['title', 'description', 'key_words'], 'required'],
+            [['title', 'description', 'key_words', 'slug'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'title' => Yii::t('app', 'Title'),
+            'description' => Yii::t('app', 'Description'),
+            'key_words' => Yii::t('app', 'Key Words'),
+            'slug' => Yii::t('app', 'Slug'),
+        ];
+    }
+
+    /**
+     * @return \yii\db\ActiveQuery
+     */
+    public function getHelps()
+    {
+        return $this->hasMany(Help::className(), ['cat_id' => 'id']);
+    }
+}

+ 77 - 0
models/HelpSearch.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Help as HelpModel;
+
+/**
+ * Help represents the model behind the search form about `app\models\Help`.
+ */
+class HelpSearch extends HelpModel
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'cat_id', 'created_at'], 'integer'],
+            [['title', 'h1', 'short_text', 'text', 'description', 'key_words', 'slug'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = HelpModel::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'cat_id' => $this->cat_id,
+            'created_at' => $this->created_at,
+        ]);
+
+        $query->andFilterWhere(['like', 'title', $this->title])
+            ->andFilterWhere(['like', 'h1', $this->h1])
+            ->andFilterWhere(['like', 'short_text', $this->short_text])
+            ->andFilterWhere(['like', 'text', $this->text])
+            ->andFilterWhere(['like', 'description', $this->description])
+            ->andFilterWhere(['like', 'key_words', $this->key_words])
+            ->andFilterWhere(['like', 'slug', $this->slug]);
+
+        return $dataProvider;
+    }
+}

+ 60 - 0
models/HelpVideo.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "help_video".
+ *
+ * @property integer $id
+ * @property string $link
+ * @property integer $cat_id
+ * @property integer $created_at
+ *
+ * @property HelpCategory $cat
+ */
+class HelpVideo extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'help_video';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['link', 'cat_id'], 'required'],
+            [['cat_id', 'created_at'], 'integer'],
+            [['link'], 'string', 'max' => 255],
+            [['cat_id'], 'exist', 'skipOnError' => true, 'targetClass' => HelpCategory::className(), 'targetAttribute' => ['cat_id' => 'id']],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'link' => Yii::t('app', 'Link'),
+            'cat_id' => Yii::t('app', 'Cat ID'),
+            'created_at' => Yii::t('app', 'Created At'),
+        ];
+    }
+
+    /**
+     * @return \yii\db\ActiveQuery
+     */
+    public function getCat()
+    {
+        return $this->hasOne(HelpCategory::className(), ['id' => 'cat_id']);
+    }
+}

+ 71 - 0
models/HelpVideoSearch.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\HelpVideo;
+
+/**
+ * HelpVideoSearch represents the model behind the search form about `app\models\HelpVideo`.
+ */
+class HelpVideoSearch extends HelpVideo
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'cat_id', 'created_at'], 'integer'],
+            [['link'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = HelpVideo::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'cat_id' => $this->cat_id,
+            'created_at' => $this->created_at,
+        ]);
+
+        $query->andFilterWhere(['like', 'link', $this->link]);
+
+        return $dataProvider;
+    }
+}

+ 133 - 0
models/Images.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\helpers\FileHelper;
+use yii\image\drivers\Image;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "images".
+ *
+ * @property integer $id
+ * @property integer $related_id
+ * @property string $path
+ * @property string $type
+ * @property integer $date_create
+ */
+class Images extends ActiveRecord
+{
+    public $_file;
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return 'images';
+    }
+
+    public function behaviors()
+    {
+        return [
+            'timestamp' => [
+                'class' => TimestampBehavior::className(),
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => 'date_create',
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['related_id', 'type'], 'required'],
+            [['related_id', 'date_create'], 'integer'],
+            [['path'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'related_id' => Yii::t('app', 'Related ID'),
+            'path' => Yii::t('app', 'Path'),
+            'date_create' => Yii::t('app', 'Date Create'),
+            'type' => Yii::t('app', 'Type'),
+        ];
+    }
+
+    public function upload()
+    {
+        if (!$this->validate()) {
+            return false;
+        }
+        $path = "uploads/images/{$this->related_id}/";
+        $croppedPath = $path . '75x75/';
+        if (!is_dir($path)) {
+            FileHelper::createDirectory($path);
+        }
+        if (!is_dir($croppedPath)) {
+            FileHelper::createDirectory($croppedPath);
+        }
+        $time = time();
+        $this->path = "{$path}{$this->_file->basename}_{$time}.{$this->_file->extension}";
+        if ($this->_file->saveAs($this->path)) {
+            /** @var Image $img * */
+            $img = Yii::$app->image->load($this->path);
+
+            $img->background('#fff', 0);
+            $img->resize('75', '75', Image::INVERSE);
+            $img->crop('75', '75');
+            $img->save($croppedPath . "{$this->_file->basename}_{$time}.{$this->_file->extension}");
+
+            (new Images([
+                'type' => 'thumbnail',
+                'path' => $croppedPath . "{$this->_file->basename}_{$time}.{$this->_file->extension}",
+                'related_id' => $this->related_id
+            ]))->save(false);
+        }
+        return $this->save(false);
+    }
+
+    public function copy($related_id)
+    {
+        $path = str_replace($this->related_id, $related_id, $this->path);
+
+        $directoryPath = explode('/', $path);
+
+        array_pop($directoryPath);
+
+        $directoryPath = implode('/', $directoryPath);
+
+        FileHelper::createDirectory($directoryPath);
+
+        copy($this->path, $path);
+
+        $model = new Images();
+        $data = $this->attributes;
+        $data['path'] = $path;
+        $data['related_id'] = $related_id;
+
+        return $model->load($data, '') && $model->save(false);
+    }
+
+    public function beforeDelete()
+    {
+        if ($this->thumbnail && is_file($this->thumbnail->path)) {
+            unlink($this->thumbnail->path);
+        }
+        parent::beforeDelete();
+    }
+
+
+}

+ 71 - 0
models/ImagesSearch.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Images;
+
+/**
+ * ImagesSearch represents the model behind the search form about `app\models\Images`.
+ */
+class ImagesSearch extends Images
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'lot_id', 'date_create'], 'integer'],
+            [['path'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        $query = Images::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'lot_id' => $this->lot_id,
+            'date_create' => $this->date_create,
+        ]);
+
+        $query->andFilterWhere(['like', 'path', $this->path]);
+
+        return $dataProvider;
+    }
+}

+ 8 - 0
models/LoginForm.php

@@ -0,0 +1,8 @@
+<?php
+
+namespace app\models;
+
+class LoginForm extends \dektrium\user\models\LoginForm
+{
+    
+}

+ 96 - 0
models/LotSearch.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use app\models\Lots;
+
+/**
+ * LotSearch represents the model behind the search form about `app\models\Lots`.
+ */
+class LotSearch extends Lots
+{
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'user_id', 'category_id', 'requisites_id', 'status','num'], 'integer'],
+            [['aukname','name', 'description', 'address', 'delivery_time', 'delivery_term', 'requires', 'payment_term', 'payment_order', 'member_require', 'member_docs', 'notes', 'date', 'auction_date'], 'safe'],
+            [['start_price', 'step'], 'number'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params)
+    {
+        if(Yii::$app->user->can('admin'))
+        {
+            $query = Lots::find()->orderBy('id DESC');
+        }
+        else
+        {
+            $query = Lots::find()->where(['user_id' => Yii::$app->user->identity->id])->orderBy('date DESC');
+        }
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'aukname' => $this->aukname,
+            'start_price' => $this->start_price,
+            'step' => $this->step,
+            'docs_id' => $this->docs_id,
+            'delivery_time' => $this->delivery_time,
+            'category_id' => $this->category_id,
+            'requisites_id' => $this->requisites_id,
+            'dogovor_id' => $this->dogovor_id,
+            'date' => $this->date,
+            'auction_date' => $this->auction_date,
+            'status' => $this->status,
+        ]);
+
+        $query->andFilterWhere(['like', 'aukname', $this->aukname])
+        ->andFilterWhere(['like', 'name', $this->name])
+            ->andFilterWhere(['like', 'description', $this->description])
+            ->andFilterWhere(['like', 'address', $this->address])
+            ->andFilterWhere(['like', 'delivery_term', $this->delivery_term])
+            ->andFilterWhere(['like', 'requires', $this->requires])
+            ->andFilterWhere(['like', 'payment_term', $this->payment_term])
+            ->andFilterWhere(['like', 'payment_order', $this->payment_order])
+            ->andFilterWhere(['like', 'member_require', $this->member_require])
+            ->andFilterWhere(['like', 'member_docs', $this->member_docs])
+            ->andFilterWhere(['like', 'notes', $this->notes])
+            ->andFilterWhere(['like', 'status', $this->status]);
+
+        return $dataProvider;
+    }
+}

+ 234 - 0
models/Lots.php

@@ -0,0 +1,234 @@
+<?php
+
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\helpers\FileHelper;
+use yii\web\UploadedFile;
+use app\models\Bidding;
+use app\models\Bills;
+use app\models\Auctions;
+
+/**
+ * This is the model class for table "lots".
+ *
+ * @property integer $id
+ * @property integer $user_id
+ * @property string $name
+ * @property string $description
+ * @property double $start_price
+ * @property string $step
+ * @property integer $docs_id
+ * @property Files|null $doc
+ * @property string $address
+ * @property integer $delivery_time
+ * @property string $delivery_term
+ * @property string $requires
+ * @property string $payment_term
+ * @property string $payment_order
+ * @property integer $category_id
+ * @property string $member_require
+ * @property string $member_docs
+ * @property integer $requisites_id
+ * @property string $notes
+ * @property integer $dogovor_id
+ * @property string $date
+ * @property integer $auction_date
+ * @property integer $status
+ * @property string $term_procedure
+ * @property string $bidding_date
+ * @property string $time_step_down
+ * @property Units $unit
+ * @property Images[] $images
+ * @property Images[] $thumbnails
+ */
+class Lots extends ActiveRecord
+{
+
+    public $price_per_one;
+    public $files;
+
+    /**
+     * @inheritdoc
+     */
+
+    public static function tableName()
+    {
+        return 'lots';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    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'],
+            [['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],
+            [['price_per_one'], 'number', 'integerOnly' => false],
+            [['files'], 'image'],
+            [['file'],'file'],
+            [['file'],'safe'],
+            //[['notes', 'description', 'safe'], 'string', 'max' => 15000]
+        ];
+    }
+
+    /** ,'dogovor_id', 'payment_term', 'payment_order', 'member_require', 'term_procedure','requisites_id'
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'id'),
+            'count' => Yii::t('app', 'Кількість'),
+            'UnitId' => Yii::t('app', 'Одиниця виміру'),
+            'user_id' => Yii::t('app', 'User ID'),
+            'num' => Yii::t('app', 'LotNumber ID'),
+            'name' => Yii::t('app', 'Lot ID'),
+            'description' => Yii::t('app', 'LotsDescrioption ID'),
+            'start_price' => Yii::t('app', 'Price ID'),
+            'nds' => Yii::t('app', 'NDS ID'),
+            'step' => Yii::t('app', 'Step ID'),
+            'docs_id' => Yii::t('app', 'LotFiles ID'),
+            'address' => Yii::t('app', 'AddressTo ID'),
+            'delivery_time' => Yii::t('app', 'DeliveryTime ID'),
+            'delivery_term' => Yii::t('app', 'DeliveryTerm ID'),
+            'requires' => Yii::t('app', 'Требования к сроку и объему'),
+            'payment_term' => Yii::t('app', 'PaymentTerm ID'), // auclots
+            'payment_order' => Yii::t('app', 'Порядок формирования цен договора'), // auclots
+            'category_id' => Yii::t('app', 'Категория товара'),
+            'member_require' => Yii::t('app', 'MemberRequire ID'), // auclots
+            'member_docs' => Yii::t('app', 'Перечень документов'),
+            'term_procedure' => Yii::t('app', 'Term_procedure ID'), // auclots
+            'requisites_id' => Yii::t('app', 'Requisites ID'), // auclots
+            'notes' => Yii::t('app', 'LotsNotes ID'),
+            'dogovor_id' => Yii::t('app', 'Проект договора'), // auclots
+            'date' => Yii::t('app', 'Date ID'),
+            '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'),
+            'categoryName' => Yii::t('app', 'Category ID'),
+            'bidding_date' => Yii::t('app', 'BiddingDate ID'),
+            'step_down' => Yii::t('app', 'Circle ID'),
+            'time_step_down' => Yii::t('app', 'Time Step'),
+            'unitName' => Yii::t('app', 'Одиниця виміру'),
+            'price_per_one' => Yii::t('app', 'Ціна за одиницю'),
+        ];
+    }
+
+    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;
+
+        }
+        return parent::save($validate, $attr);
+    }
+
+    public function getRequisite()
+    {
+        return $this->hasOne(Requisites::className(), ['id' => 'requisites_id']);
+    }
+
+    public function getBillPayRegistration() {
+        $sql = Yii::$app->db->createCommand("
+        SELECT bills.id FROM bills 
+        LEFT JOIN bidding ON bills.bid_id = bidding.id
+        LEFT JOIN auctions ON bidding.auction_id = auctions.id
+        LEFT JOIN lots ON auctions.lot_id = lots.id
+        WHERE bills.type = 'registration'
+        ");
+        $result = $sql->queryScalar();
+
+        return $result;
+    }
+
+    public function getBillPayGuarantee() {
+        $sql = Yii::$app->db->createCommand("
+        SELECT bills.id FROM bills 
+        LEFT JOIN bidding ON bills.bid_id = bidding.id
+        LEFT JOIN auctions ON bidding.auction_id = auctions.id
+        LEFT JOIN lots ON auctions.lot_id = lots.id
+        WHERE bills.type = 'guarantee'
+        ");
+        $result = $sql->queryScalar();
+
+        return $result;
+    }
+
+    public function getAuction() {
+        return $this->hasOne(Auctions::className(), ['lot_id' => 'id']);
+    }
+
+
+    public function getCategory()
+    {
+        return $this->hasOne(Category::className(), ['id' => 'category_id']);
+    }
+
+    public function getCategoryName()
+    {
+        return $this->category->name;
+    }
+
+    public function getFile()
+    {
+        return $this->hasOne(Files::className(), ['lot_id' => 'id']);
+    }
+
+    public function getImages()
+    {
+        return $this->hasMany(Images::className(), ['related_id' => 'id'])->andOnCondition(['type' => 'image']);
+    }
+
+    public function getThumbnails()
+    {
+        return $this->hasMany(Images::className(), ['related_id' => 'id'])->andOnCondition(['type' => 'thumbnail']);
+    }
+
+    public function getThumbnail()
+    {
+        return $this->hasOne(Images::className(), ['related_id' => 'id'])->andOnCondition(['type' => 'thumbnail']);
+    }
+
+    public function getRarFile()
+    {
+        return Yii::$app->response->sendFile($this->file->path . $this->file->name);
+    }
+
+    public function getUnit()
+    {
+        return $this->hasOne(Units::className(), ['id' => 'unitId']);
+    }
+
+    public function upload()
+    {
+        $files = UploadedFile::getInstances($this, 'files');
+        foreach ($files as $file) {
+            (new Images([
+                'type' => 'image',
+                'related_id' => $this->id,
+                '_file' => $file,
+            ]))->upload();
+        }
+    }
+}

+ 0 - 0
models/Mails.php


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff