OSDN Git Service

Добавлена возможность испорта данных из .csv файла. Файл выгружается из 1С в .xls...
[invent/invent.git] / config / web.php
1 <?php
2
3 use yii\helpers\Html;
4 use kartik\mpdf\Pdf;
5
6 $params = require __DIR__ . '/params.php';
7 $db = require __DIR__ . '/db.php';
8
9 function showUrlUpdate($name, $data)
10 {
11     return Html::a(Html::encode($name), 
12         ['update',
13             'id' => $data->id,
14         ]);
15 }
16
17 function writeLog($logline)
18 {
19     $fp = fopen('data.log', 'a');
20     fwrite($fp, $logline . "\n");
21     fclose($fp);
22 }
23
24 $config = [
25     'version' => '1.27',
26     'name' => 'Inventory',
27     'id' => 'basic',
28     'basePath' => dirname(__DIR__),
29     'language' => 'ru-RU',
30     'bootstrap' => ['log'],
31     'aliases' => [
32         '@bower' => '@vendor/bower-asset',
33         '@npm'   => '@vendor/npm-asset',
34     ],
35     'components' => [
36         'request' => [
37             // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
38             'cookieValidationKey' => '4u6WczdipA-FIzbuf8PYgjoiid_6zdNy',
39         ],
40         'pdf' => [                                 // Формирование PDF по умолчанию
41             'mode' => Pdf::MODE_UTF8,              // Кодировка
42             'class' => Pdf::className(),
43             'format' => Pdf::FORMAT_A4,            // Лист А4
44             'orientation' => Pdf::ORIENT_PORTRAIT, // Напраление - по вертикали большая сторона
45             'destination' => Pdf::DEST_BROWSER,    // Результат показать в браузере
46             'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
47             'cssInline' => '.kv-heading-1{font-size:18px}',
48             'methods' => [
49                 'SetHeader' => [Yii::t('app', Yii::$app->name)], // Верхний колонтитул
50                 'SetFooter' => ['{PAGENO}'],                     // Нижний колонтитул
51             ],
52             // refer settings section for all configuration options
53         ],
54
55         'cache' => [
56             'class' => 'yii\caching\FileCache',
57         ],
58
59         'user' => [
60             'identityClass' => 'app\models\User',
61             'enableAutoLogin' => true,
62         ],
63
64         'errorHandler' => [
65             'errorAction' => 'site/error',
66         ],
67
68         'mailer' => [
69             'class' => 'yii\swiftmailer\Mailer',
70             // send all mails to a file by default. You have to set
71             // 'useFileTransport' to false and configure a transport
72             // for the mailer to send real emails.
73             'useFileTransport' => false,
74         ],
75
76         'log' => [
77             'traceLevel' => YII_DEBUG ? 3 : 0,
78             'targets' => [
79                 [
80                     'class' => 'yii\log\FileTarget',
81                     'levels' => ['error', 'warning'],
82                 ],
83             ],
84         ],
85
86         'i18n' => [ // Переводы сообщений
87             'translations' => [
88                 'app*' => [                                 // Для приложения
89                     'class' => 'yii\i18n\PhpMessageSource',
90                     'sourceLanguage' => 'en-US',            // Исходный текст на английском
91                     'basePath' => '@app/messages',
92                     'fileMap' => [
93                         'app'       => 'app.php',
94                         'app/error' => 'error.php',
95                     ],
96                 ],
97                 'contact*' => [                             // Для формы обратой связи
98                     'class' => 'yii\i18n\PhpMessageSource',
99                     'sourceLanguage' => 'en-US',
100                     'basePath' => '@app/messages',
101                     'fileMap' => [
102                         'app'   => 'contact.app',
103                     ],
104                 ],
105                 'items*' => [                               // Для предметов/оборудования
106                     'class' => 'yii\i18n\PhpMessageSource',
107                     'sourceLanguage' => 'en-US',
108                     'basePath' => '@app/messages',
109                     'fileMap' => [
110                         'app' => 'items.app',
111                     ],
112                 ],
113                 'locations*' => [                           // Для мест размещения
114                     'class' => 'yii\i18n\PhpMessageSource',
115                     'sourceLanguage' => 'en-US',
116                     'basePath' => '@app/messages',
117                     'fileMap' => [
118                         'app' => 'locations.app',
119                     ],
120                 ],
121                 'moving*' => [                              // Для перемещений
122                     'class' => 'yii\i18n\PhpMessageSource',
123                     'sourceLanguage' => 'en-US',
124                     'basePath' => '@app/messages',
125                     'fileMap' => [
126                         'app'   => 'moving.app',
127                     ],
128                 ],
129                 'regions*' => [                             // Для регионов/подразделений
130                     'class' => 'yii\i18n\PhpMessageSource',
131                     'sourceLanguage' => 'en-US',
132                     'basePath' => '@app/messages',
133                     'fileMap' => [
134                         'app' => 'regions.app',
135                     ],
136                 ],
137                 'status*' => [                              // Для состояний предметов/оборудования
138                     'class' => 'yii\i18n\PhpMessageSource',
139                     'sourceLanguage' => 'en-US',
140                     'basePath' => '@app/messages',
141                     'fileMap' => [
142                         'app' => 'status.app',
143                     ],
144                 ],
145                 'types*' => [                               // Для типов оборудования
146                     'class' => 'yii\i18n\PhpMessageSource',
147                     'sourceLanguage' => 'en-US',
148                     'basePath' => '@app/messages',
149                     'fileMap' => [
150                         'app' => 'types.app',
151                     ],
152                 ],
153             ],
154         ],
155         'db' => $db,
156         /*
157         'urlManager' => [
158             'enablePrettyUrl' => true,
159             'showScriptName' => false,
160             'rules' => [
161             ],
162         ],
163         */
164     ],
165     'params' => $params,
166 ];
167
168 if (YII_ENV_DEV) {
169     // configuration adjustments for 'dev' environment
170     $config['bootstrap'][] = 'debug';
171     $config['modules']['debug'] = [
172         'class' => 'yii\debug\Module',
173         // uncomment the following to add your IP if you are not connecting from localhost.
174         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68'],
175     ];
176
177     $config['bootstrap'][] = 'gii';
178     $config['modules']['gii'] = [
179         'class' => 'yii\gii\Module',
180         // uncomment the following to add your IP if you are not connecting from localhost.
181         'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.68'],
182     ];
183 }
184
185 return $config;