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
341ee21a
Commit
341ee21a
authored
Feb 21, 2016
by
Виталий Мурашко
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drag and Drop
parent
33d72d12
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2253 additions
and
16 deletions
+2253
-16
common/modules/bids/controllers/BidController.php
common/modules/bids/controllers/BidController.php
+19
-4
common/modules/bids/models/Bid.php
common/modules/bids/models/Bid.php
+1
-1
common/modules/content/controllers/PageController.php
common/modules/content/controllers/PageController.php
+4
-1
frontend/assets/FileUploadBundle.php
frontend/assets/FileUploadBundle.php
+27
-0
frontend/views/layouts/footer-index.php
frontend/views/layouts/footer-index.php
+11
-5
frontend/views/site/contacts.php
frontend/views/site/contacts.php
+10
-5
frontend/web/css/dropzone.css
frontend/web/css/dropzone.css
+397
-0
frontend/web/js/dropzone.js
frontend/web/js/dropzone.js
+1767
-0
frontend/web/js/upload-files.js
frontend/web/js/upload-files.js
+17
-0
No files found.
common/modules/bids/controllers/BidController.php
View file @
341ee21a
...
@@ -20,6 +20,7 @@ class BidController extends \common\components\BaseController
...
@@ -20,6 +20,7 @@ class BidController extends \common\components\BaseController
{
{
return
[
return
[
'Add'
=>
'Добавление заявки'
,
'Add'
=>
'Добавление заявки'
,
'Upload-files'
=>
'Загрузка файлов'
,
];
];
}
}
...
@@ -31,21 +32,20 @@ class BidController extends \common\components\BaseController
...
@@ -31,21 +32,20 @@ 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
)
if
(
Yii
::
$app
->
request
->
isAjax
)
{
{
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
file
=
UploadedFile
::
getInstance
(
$model
,
'file'
);
$model
->
file
=
UploadedFile
::
getInstance
(
$model
,
'file'
);
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$model
->
filename
=
$_POST
[
'file_name'
];
if
(
$model
->
validate
())
if
(
$model
->
validate
())
{
{
if
(
$model
->
file
)
/*
if($model->file)
{
{
$model->upload();
$model->upload();
$model->file = null;
$model->file = null;
}
}
*/
$model
->
save
();
$model
->
save
();
$model
->
send
();
$model
->
send
();
...
@@ -63,4 +63,19 @@ class BidController extends \common\components\BaseController
...
@@ -63,4 +63,19 @@ class BidController extends \common\components\BaseController
}
}
}
}
public
function
actionUploadFiles
()
{
$model
=
new
Bid
();
if
(
!
empty
(
$_FILES
))
{
$tempFile
=
$_FILES
[
'file'
][
'tmp_name'
];
$targetPath
=
$model
->
getPath
();
$targetFile
=
$targetPath
.
$_FILES
[
'file'
][
'name'
];
move_uploaded_file
(
$tempFile
,
$targetFile
);
return
$_FILES
[
'file'
][
'name'
];
}
}
}
}
common/modules/bids/models/Bid.php
View file @
341ee21a
...
@@ -114,7 +114,7 @@ class Bid extends \common\components\ActiveRecordModel
...
@@ -114,7 +114,7 @@ class Bid extends \common\components\ActiveRecordModel
return
Yii
::
$app
->
params
[
'frontUrl'
]
.
self
::
FILE_FOLDER
.
$this
->
filename
;
return
Yii
::
$app
->
params
[
'frontUrl'
]
.
self
::
FILE_FOLDER
.
$this
->
filename
;
}
}
p
rivate
function
getPath
()
p
ublic
function
getPath
()
{
{
return
Yii
::
getAlias
(
'@frontend/web'
)
.
self
::
FILE_FOLDER
;
return
Yii
::
getAlias
(
'@frontend/web'
)
.
self
::
FILE_FOLDER
;
}
}
...
...
common/modules/content/controllers/PageController.php
View file @
341ee21a
<?php
<?php
namespace
common\modules\content\controllers
;
namespace
common\modules\content\controllers
;
use
Yii
;
use
yii\web\BadRequestHttpException
;
use
yii\web\BadRequestHttpException
;
use
common\modules\content\models\CoContent
;
use
common\modules\content\models\CoContent
;
use
common\modules\school\models\Lessons
;
class
PageController
extends
\common\components\BaseController
class
PageController
extends
\common\components\BaseController
{
{
...
...
frontend/assets/FileUploadBundle.php
0 → 100644
View file @
341ee21a
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
frontend\assets
;
use
yii\web\AssetBundle
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
FileUploadBundle
extends
AssetBundle
{
public
$basePath
=
'@webroot'
;
public
$baseUrl
=
'@web'
;
public
$css
=
[
'css/dropzone.css'
,
];
public
$js
=
[
'js/dropzone.js'
,
'js/upload-files.js'
];
}
frontend/views/layouts/footer-index.php
View file @
341ee21a
...
@@ -4,6 +4,10 @@ use yii\helpers\Html;
...
@@ -4,6 +4,10 @@ use yii\helpers\Html;
use
yii\helpers\Url
;
use
yii\helpers\Url
;
use
common\modules\bids\models\Bid
;
use
common\modules\bids\models\Bid
;
use
frontend\assets\FileUploadBundle
;
FileUploadBundle
::
register
(
$this
);
?>
?>
<footer>
<footer>
...
@@ -23,11 +27,13 @@ use common\modules\bids\models\Bid;
...
@@ -23,11 +27,13 @@ use common\modules\bids\models\Bid;
$form
=
ActiveForm
::
begin
([
$form
=
ActiveForm
::
begin
([
'id'
=>
'form_foot'
,
'id'
=>
'form_foot'
,
'action'
=>
'/'
,
'action'
=>
'/'
,
'enableClientValidation'
=>
false
,
'enableClientValidation'
=>
false
,
'options'
=>
[
'options'
=>
[
'class'
=>
'footer_form bids-form'
,
'class'
=>
'footer_form bids-form'
,
'data-title'
=>
'Рассчитать проект'
,
'data-title'
=>
'Рассчитать проект'
,
'data-form'
=>
'Рассчитать проект'
,
'data-form'
=>
'Рассчитать проект'
,
'enctype'
=>
'multipart/form-data'
,
'data-tag'
=>
Bid
::
TAG_TREATMENT
'data-tag'
=>
Bid
::
TAG_TREATMENT
],
],
]);
?>
]);
?>
...
@@ -65,21 +71,21 @@ use common\modules\bids\models\Bid;
...
@@ -65,21 +71,21 @@ use common\modules\bids\models\Bid;
'class'
=>
'footer_form__textarea'
'class'
=>
'footer_form__textarea'
])
->
label
(
false
);
?>
])
->
label
(
false
);
?>
<div
class=
"file-upload_block"
>
<div
class=
"file-upload_block
dropzone"
id=
"block_upload
"
>
<div
class=
"file_upload_bt"
>
<div
class=
"file_upload_bt"
>
<div
class=
"file-upload"
>
<div
class=
"file-upload"
>
<label>
<label>
<?php
echo
$form
->
field
(
$model
,
'file'
,
[
<?php
/*
echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])
->
fileInput
();
?>
])->fileInput();
*/
?>
<span>
Выбрать файл
</span>
<span>
Выбрать файл
</span>
</label>
</label>
</div>
</div>
<
input
type=
"text"
id=
"filename"
class=
"filename"
disabled
>
<
!--<input type="text" id="filename" class="filename" disabled>--
>
<div
class=
"file_drop"
>
Перетащите файл в данную область
<br/>
или выберите файл с компьютера
</div>
<div
class=
"file_drop"
>
Перетащите файл в данную область
<br/>
или выберите файл с компьютера
</div>
</div>
</div>
</div>
</div>
<input
type=
"hidden"
name=
"file_name"
id=
'file_name'
value=
""
/>
<?php
echo
Html
::
submitButton
(
'Рассчитать проект'
,
[
'class'
=>
'btn-default save-button'
]);
?>
<?php
echo
Html
::
submitButton
(
'Рассчитать проект'
,
[
'class'
=>
'btn-default save-button'
]);
?>
<?php
ActiveForm
::
end
();
?>
<?php
ActiveForm
::
end
();
?>
...
...
frontend/views/site/contacts.php
View file @
341ee21a
...
@@ -4,6 +4,10 @@ use yii\helpers\Html;
...
@@ -4,6 +4,10 @@ use yii\helpers\Html;
use
\common\models\Settings
;
use
\common\models\Settings
;
use
\common\modules\bids\models\Bid
;
use
\common\modules\bids\models\Bid
;
use
frontend\assets\FileUploadBundle
;
FileUploadBundle
::
register
(
$this
);
?>
?>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
...
@@ -121,20 +125,21 @@ use \common\modules\bids\models\Bid;
...
@@ -121,20 +125,21 @@ use \common\modules\bids\models\Bid;
'class'
=>
'sect_cont_form__textarea'
'class'
=>
'sect_cont_form__textarea'
])
->
label
(
false
);
?>
])
->
label
(
false
);
?>
<div
class=
"file-upload_block_cs"
>
<div
class=
"file-upload_block_cs
dropzone"
id=
"block_upload
"
>
<div
class=
"file_upload_bt_cs"
>
<div
class=
"file_upload_bt_cs"
>
<div
class=
"file-upload_cs"
>
<div
class=
"file-upload_cs"
>
<label>
<label>
<?php
echo
$form
->
field
(
$model
,
'file'
,
[
<?php
/*
echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])
->
fileInput
();
?>
])->fileInput();
*/
?>
<span>
Выбрать файл
</span>
<span>
Выбрать файл
</span>
</label>
</label>
</div>
</div>
<
input
type=
"text"
id=
"filename"
class=
"filename_cs"
disabled
>
<
!--<input type="text" id="filename" class="filename_cs" disabled>--
>
<div
class=
"file_drop_cs"
>
Перетащите файл в данную область
<br/>
или выберите файл с компьютера
</div>
<div
class=
"file_drop_cs"
>
Перетащите файл в данную область
<br/>
или выберите файл с компьютера
</div>
</div>
</div>
</div>
</div>
<input
type=
"hidden"
name=
"file_name"
id=
'file_name'
value=
""
/>
<?php
echo
Html
::
submitButton
(
'Отправить'
,
[
'class'
=>
'btn-default save-button'
]);
?>
<?php
echo
Html
::
submitButton
(
'Отправить'
,
[
'class'
=>
'btn-default save-button'
]);
?>
...
...
frontend/web/css/dropzone.css
0 → 100644
View file @
341ee21a
This diff is collapsed.
Click to expand it.
frontend/web/js/dropzone.js
0 → 100644
View file @
341ee21a
This diff is collapsed.
Click to expand it.
frontend/web/js/upload-files.js
0 → 100644
View file @
341ee21a
$
(
document
).
ready
(
function
()
{
// Dropzone class:
// var myDropzone = new Dropzone("div#block_upload", {url: "/bids/bid/upload-files", maxFiles: 1});
Dropzone
.
options
.
blockUpload
=
{
url
:
"
/bids/bid/upload-files
"
,
maxFiles
:
1
,
addRemoveLinks
:
true
,
dictRemoveFile
:
'
Удалить
'
,
/*accept: function(file, done) {
$('#file_name').val(file.name);
done();
},*/
success
:
function
(
first
,
response
)
{
$
(
'
#file_name
'
).
val
(
response
);
}
};
});
\ No newline at end of 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