Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
e0746356
Commit
e0746356
authored
Jun 28, 2019
by
Ruslan Karimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#3460. Важно (срочно) - внести правки в верстку сайта
parent
8365a906
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
28 deletions
+42
-28
common/modules/bids/controllers/BidController.php
common/modules/bids/controllers/BidController.php
+13
-25
common/modules/bids/models/BidFile.php
common/modules/bids/models/BidFile.php
+23
-0
frontend/web/js/upload-files.js
frontend/web/js/upload-files.js
+6
-3
No files found.
common/modules/bids/controllers/BidController.php
View file @
e0746356
...
@@ -20,10 +20,10 @@ class BidController extends \common\components\BaseController
...
@@ -20,10 +20,10 @@ class BidController extends \common\components\BaseController
public
static
function
actionsTitles
()
public
static
function
actionsTitles
()
{
{
return
[
return
[
'Add'
=>
'Добавление заявки'
,
'Add'
=>
'Добавление заявки'
,
'Blogadd'
=>
'Добавление заявки в блог'
,
'Blogadd'
=>
'Добавление заявки в блог'
,
'Upload-files'
=>
'Загрузка файлов'
,
'Upload-files'
=>
'Загрузка файлов'
,
'Delete-file'
=>
'Удаление файлов'
,
'Delete-file'
=>
'Удаление файлов'
,
];
];
}
}
...
@@ -37,7 +37,7 @@ class BidController extends \common\components\BaseController
...
@@ -37,7 +37,7 @@ class BidController extends \common\components\BaseController
$model
=
new
Bid
;
$model
=
new
Bid
;
$model
->
scenario
=
Yii
::
$app
->
request
->
post
(
'scenario'
);
$model
->
scenario
=
Yii
::
$app
->
request
->
post
(
'scenario'
);
if
(
Yii
::
$app
->
request
->
isAjax
&&
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
if
(
Yii
::
$app
->
request
->
isAjax
&&
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
try
{
if
(
$model
->
save
())
{
if
(
$model
->
save
())
{
...
@@ -80,7 +80,7 @@ class BidController extends \common\components\BaseController
...
@@ -80,7 +80,7 @@ class BidController extends \common\components\BaseController
$model
=
new
Bid
;
$model
=
new
Bid
;
$model
->
blog
=
true
;
$model
->
blog
=
true
;
$model
->
scenario
=
Yii
::
$app
->
request
->
post
(
'scenario'
);
$model
->
scenario
=
Yii
::
$app
->
request
->
post
(
'scenario'
);
if
(
Yii
::
$app
->
request
->
isAjax
&&
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
if
(
Yii
::
$app
->
request
->
isAjax
&&
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
try
{
if
(
$model
->
save
())
{
if
(
$model
->
save
())
{
...
@@ -110,27 +110,15 @@ class BidController extends \common\components\BaseController
...
@@ -110,27 +110,15 @@ class BidController extends \common\components\BaseController
}
}
}
}
public
function
actionUploadFiles
()
public
function
actionUploadFiles
()
{
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$fileNames
=
BidFile
::
uploadFiles
();
$model
=
new
BidFile
;
return
[
$model
->
file
=
UploadedFile
::
getInstanceByName
(
'file'
);
'files'
=>
$fileNames
];
if
(
$model
->
file
)
{
if
(
!
file_exists
(
BidFile
::
path
()))
{
mkdir
(
BidFile
::
path
(),
0777
,
true
);
}
$model
->
filename
=
date
(
'dmYHis-'
)
.
uniqid
()
.
'.'
.
$model
->
file
->
extension
;
$model
->
file
->
saveAs
(
BidFile
::
path
()
.
$model
->
filename
);
return
[
'filename'
=>
$model
->
filename
];
}
}
else
{
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
...
@@ -138,7 +126,7 @@ class BidController extends \common\components\BaseController
...
@@ -138,7 +126,7 @@ class BidController extends \common\components\BaseController
public
function
actionDeleteFile
()
public
function
actionDeleteFile
()
{
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$filename
=
Yii
::
$app
->
request
->
post
(
'filename'
);
$filename
=
Yii
::
$app
->
request
->
post
(
'filename'
);
...
...
common/modules/bids/models/BidFile.php
View file @
e0746356
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
common\modules\bids\models
;
namespace
common\modules\bids\models
;
use
Yii
;
use
Yii
;
use
yii\helpers\FileHelper
;
use
yii\web\UploadedFile
;
/**
/**
* This is the model class for table "bids_files".
* This is the model class for table "bids_files".
...
@@ -88,4 +90,25 @@ class BidFile extends \common\components\ActiveRecordModel
...
@@ -88,4 +90,25 @@ class BidFile extends \common\components\ActiveRecordModel
{
{
return
Yii
::
getAlias
(
'@backend'
.
self
::
FILE_FOLDER
);
return
Yii
::
getAlias
(
'@backend'
.
self
::
FILE_FOLDER
);
}
}
/**
* @return array
*/
public
static
function
uploadFiles
()
{
$files
=
UploadedFile
::
getInstancesByName
(
'file'
);
$fileNames
=
[];
if
(
$files
)
{
$path
=
BidFile
::
path
();
if
(
!
is_dir
(
$path
))
{
FileHelper
::
createDirectory
(
BidFile
::
path
(),
0777
,
true
);
}
foreach
(
$files
as
$file
)
{
$fileName
=
Yii
::
$app
->
security
->
generateRandomString
()
.
".
$file->extension
"
;
$fileNames
[]
=
$fileName
;
$file
->
saveAs
(
$path
.
$fileName
);
}
}
return
$fileNames
;
}
}
}
frontend/web/js/upload-files.js
View file @
e0746356
...
@@ -39,9 +39,12 @@ $(document).ready(function() {
...
@@ -39,9 +39,12 @@ $(document).ready(function() {
$form
.
find
(
'
.file-processing
'
).
fadeIn
();
$form
.
find
(
'
.file-processing
'
).
fadeIn
();
});
});
},
},
success
:
function
(
file
,
response
)
{
successmultiple
:
function
(
files
,
response
)
{
file
.
filename
=
response
.
filename
;
$
.
each
(
files
,
function
(
index
,
file
)
{
$
(
'
#files-zone
'
).
append
(
'
<input type="hidden" name="Bid[file][]" value="
'
+
response
.
filename
+
'
" />
'
);
console
.
log
(
file
);
file
.
filename
=
response
.
files
[
index
];
$
(
'
#files-zone
'
).
append
(
'
<input type="hidden" name="Bid[file][]" value="
'
+
response
.
files
[
index
]
+
'
" />
'
);
});
toggleButtons
();
toggleButtons
();
},
},
removedfile
:
function
(
file
)
{
removedfile
:
function
(
file
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment