/
vvimport.php
171 lines (151 loc) · 6.59 KB
/
vvimport.php
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<div class="side-body <?php echo getSideBodyClass(false); ?>">
<?php echo CHtml::form(array('admin/dataentry/sa/vvimport/surveyid/'.$surveyid), 'post', array('enctype'=>'multipart/form-data', 'id'=>'vvexport', 'class'=>''));?>
<?php if($tableExists):?>
<div class="row">
<div class="col-md-12">
<div class="col-md-6 text-left">
<h4>
<?php eT("Import a VV response data file"); ?>
</h4>
</div>
</div>
<h3></h3>
</div>
<?php endif;?>
<div class="row">
<div class="col-lg-12 content-right">
<?php
if ($tableExists) {
?>
<div class="panel panel-primary" id="panel-1">
<div class="panel-heading">
<div class="panel-title h4">
<?php eT("General");?>
</div>
</div>
<div class="panel-body">
<div class="form-group">
<label for="csv_vv_file" class=" control-label">
<?php printf(gT("Response data file (*.csv,*.vv,*.txt) (maximum size: %d MB):"),getMaximumFileUploadSize()/1024/1024); ?>
</label>
<div class="">
<input type="file" value="" name="csv_vv_file" id="csv_vv_file" class="form-control" accept='.csv,.vv,.txt' required>
</div>
</div>
<div class="form-group">
<label for="noid" class=" control-label">
<?php eT("Exclude record IDs?"); ?>
</label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'noid',
'value'=> 'noid',
'onLabel'=>gT('Yes'),
'offLabel'=>gT('No')
));
?>
</div>
</div>
<div class="form-group" id="insertmethod-container">
<label for="insertmethod" class=" control-label">
<?php eT("When an imported record matches an existing record ID:"); ?>
</label>
<div class="">
<?php echo CHtml::dropDownList('insertmethod', 'ignore', array(
'skip' => gT("Report and skip the new record."),
'renumber' => gT("Renumber the new record."),
'replace' => gT("Replace the existing record."),
'replaceanswers' => gT("Replace answers in file in the existing record."),
),array('disabled'=>'disabled','class'=>'form-control'));
?>
</div>
</div>
<div class="form-group">
<label for="notfinalized" class=" control-label">
<?php eT("Import as not finalized answers?"); ?>
</label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'notfinalized',
'value'=> false,
'onLabel'=>gT('Yes'),
'offLabel'=>gT('No')
));
?>
</div>
</div>
<div class="form-group">
<label for="vvcharset" class=" control-label">
<?php eT("Character set of the file:"); ?>
</label>
<div class="">
<?php echo CHtml::dropDownList('vvcharset',false,$aEncodings,array('class'=>'form-control', 'empty' => gT('Automatic (UTF-8)'))); ?>
</div>
</div>
<div class="form-group">
<label for="dontdeletefirstline" class=" control-label" title='<?php eT("With real vv file : questions code are in second line"); ?>' data-toggle="tooltip" data-placement="right">
<?php eT("First line contains the code of questions:"); ?>
</label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'dontdeletefirstline',
'value'=> false,
'onLabel'=>gT('Yes'),
'offLabel'=>gT('No')
));
?>
</div>
</div>
<div class="form-group">
<label for="forceimport" class=" control-label" title='<?php eT("Try to import even if question codes don't match"); ?>' data-toggle="tooltip" data-placement="right">
<?php eT("Force import:"); ?>
</label>
<div class="">
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'forceimport',
'value'=> false,
'onLabel'=>gT('Yes'),
'offLabel'=>gT('No')
));
?>
</div>
</div>
</div>
</div>
<p>
<input type='submit' class="hidden" value='<?php eT("Import"); ?>' />
<input type='hidden' name='action' value='vvimport' />
<input type='hidden' name='subaction' value='upload' />
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
</p>
</form>
<br />
<?php } else { ?>
<div class="jumbotron message-box message-box-error">
<h2 class="danger"><?php eT("Import a VV response data file"); ?>:</h2>
<p class="lead text-danger">
<?php eT("Cannot import the VVExport file."); ?>
</p>
<p>
<?php eT("This survey is not active. You must activate the survey before attempting to import a VVexport file."); ?>
</p>
<p>
<a class="btn btn-lg btn-default" href='<?php echo $this->createUrl('surveyAdministration/view/'.$surveyid); ?>'><?php eT("Return to survey administration"); ?></a>
</p>
</div>
<?php } ?>
</div></div></div>
<?php
App()->getClientScript()->registerScript('VVImportBSSwitcher', "
LS.renderBootstrapSwitch();
$('#noid').on('switchChange.bootstrapSwitch', function(event, state) {
if (!state){
$('#insertmethod').removeAttr('disabled');
$('#insertmethod-container').show('slow');
}else{
$('#insertmethod').attr('disabled','disabled');
$('#insertmethod-container').hide('slow');
}
});
", LSYii_ClientScript::POS_POSTSCRIPT);
?>