price.php
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @var $sheet PHPExcel_Worksheet
* @var $this View
*/
use kartik\file\FileInput;
use yii\helpers\Html;
use yii\web\View;
use yii\widgets\ActiveForm;
use yiister\gentelella\widgets\Panel;
$js = <<< JS
$(document).on('submit', '#my-form', function(e) {
var formData = new FormData(this);
$(document.body).append('<div class="animated yt-loader"></div>');
$.ajax({
url: "/admin/import/price-upload",
data: formData,
type: "POST",
success: function(data) {
console.log(data);
$('.yt-loader').remove();
new PNotify({
title: "Success",
text: "File updated",
type: "success",
styling: "bootstrap3",
icon: "glyphicon glyphicon-exclamation-sign"
});
},
cache: false,
contentType: false,
processData: false
});
e.preventDefault();
});
JS;
$this->registerJs($js, View::POS_READY);
$this->params[ 'breadcrumbs' ][] = \Yii::t('catalog', 'Price update');
?>
<?php $panel = Panel::begin() ?>
<?php $form = ActiveForm::begin(
[
'options' => [
'enctype' => 'multipart/form-data',
],
'id' => 'my-form',
'action' => 'import/upload',
]
) ?>
<?php
echo '<label class="control-label">' . \Yii::t('catalog', 'Upload Document') . '</label>';
echo FileInput::widget(
[
'name' => 'attachment_3',
]
);
?>
<?= Html::submitButton(
\Yii::t('catalog', 'Send'),
[
'class' => 'btn btn-success',
]
) ?>
<div id="progress-container">
</div>
<?php $form::end() ?>
<?php $panel::end() ?>