-
Notifications
You must be signed in to change notification settings - Fork 987
/
tokenform.php
464 lines (427 loc) · 21.1 KB
/
tokenform.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<?php
/**
* Add token entry
*/
?>
<div class='container-fluid <?php if (!isset($ajax) || $ajax = false):?> col-12 side-body <?php echo getSideBodyClass(false); ?> <?php endif; ?>'>
<?php if (!isset($ajax) || $ajax = false) { ?>
<h3>
<?php
if ($token_subaction == "edit") {
eT("Edit survey participant");
} else {
eT("Add survey participant");
}
?>
</h3>
<?php } ?>
<?php
foreach ($tokendata as $Key => $Value) {
$$Key = $Value;
}
?>
<div class="row">
<div class="col-md-12 content-right">
<?php echo CHtml::form(array("admin/tokens/sa/{$token_subaction}/surveyid/{$surveyid}/tokenid/{$tokenid}"), 'post', array('id'=>'edittoken', 'class'=>'')); ?>
<!-- Tabs -->
<?php if( count($attrfieldnames) > 0 ):?>
<ul class="nav nav-tabs" id="edit-survey-text-element-language-selection">
<!-- Common -->
<li role="presentation" class="active">
<a data-toggle="tab" href="#general" aria-expanded="true">
<?php eT('General'); ?>
</a>
</li>
<!-- Custom attibutes -->
<li role="presentation" class="">
<a data-toggle="tab" href="#custom" aria-expanded="false">
<?php eT('Additional attributes'); ?>
</a>
</li>
</ul>
<?php endif; ?>
<!-- Tabs content-->
<div class="tab-content">
<div id="general" class="tab-pane fade in active">
<div class="ls-flex-column ls-space padding left-5 right-35 col-md-6">
<!-- General -->
<!-- ID,Completed -->
<div class="form-group">
<!-- ID -->
<label class=" control-label">ID:</label>
<div class="">
<p class="form-control-static">
<?php
if ($token_subaction == "edit") {
echo $tokenid;
} else {
eT("Auto");
}
?>
</p>
</div>
</div>
<div class="form-group">
<!--
TODO:
To take in account the anonomyzed survey case (completed field contain no date, but a {Y,N}), the code become more complexe
It will need a refactorisation .
maybe a widget? At least, a lot of variable should be set in the controller (classes etc)
-->
<?php $sCointainerClass = ($oSurvey->anonymized != 'Y') ? 'yes-no-date-container' : 'yes-no-container'; ?>
<!-- Completed -->
<label class=" control-label" for='completed'>
<?php eT("Completed?"); ?>
</label>
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="completed-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="row">
<?php if ($oSurvey->anonymized != 'Y'):?>
<?php
$bCompletedValue = "0";
if (isset($completed) && $completed != 'N')
{
$completedDBFormat = $completed;
$bCompletedValue = "1";
$completed = convertToGlobalSettingFormat($completed, true);
}
?>
<div class="">
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "completed-switch",
'id'=>"completed-switch",
'htmlOptions'=>array('class'=>"YesNoDateSwitch action_toggle_bootstrap_switch"),
'value' => $bCompletedValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
</div>
<?php else: ?>
<div class="">
<?php
$completedDBFormat = $completed;
$bCompletedValue = (isset($completed) && $completed != 'N') ? "1" : "0";
$completed = (isset($completed) && $completed != 'N') ? 'Y' : 'N';
?>
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "completed-switch",
'id'=>"completed-switch",
'htmlOptions'=>array('class'=>"YesNoSwitch action_toggle_bootstrap_switch"),
'value' => $bCompletedValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
</div>
<?php endif; ?>
<?php if ($oSurvey->anonymized != 'Y'):?>
<div class="">
<div id="sent-date-container" class="date-container" <?php if (!$bCompletedValue):?>style="display: none;"<?php endif; ?>>
<div id="completed-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="completed-date" type="text" value="<?php echo isset($completed) ? $completed : ''?>" name="completed-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
<?php endif; ?>
</div>
<input class='form-control hidden YesNoDateHidden' type='text' size='20' id='completed' name='completed' value="<?php if (isset($completed)) {echo $completed; } else {echo " N "; }?>" />
</div>
</div>
<!-- First name, Last name -->
<div class="form-group">
<label class=" control-label" for='firstname'>
<?php eT("First name:"); ?>
</label>
<div class="">
<?=TbHtml::textField('firstname', $firstname, [
'class' => 'form-control',
'size' => '30',
]);?>
</div>
</div>
<div class="form-group">
<label class=" control-label" for='lastname'>
<?php eT("Last name:"); ?>
</label>
<div class="">
<?=TbHtml::textField('lastname', $lastname, [
'class' => 'form-control',
'size' => '30',
]);?>
</div>
</div>
<!-- Token, language -->
<div class="form-group">
<label class=" control-label" for='token'>
<?php eT("Access code:"); ?>
</label>
<div class="">
<?=TbHtml::textField('token',(isset($token) ? $token : ""), [
'class' => 'form-control',
'size' => '20',
'maxlength' => $iTokenLength
]);?>
<?php if ($token_subaction == "addnew"): ?>
<span id="helpBlock" class="help-block"><?php eT("You can leave this blank, and automatically generate access codes using 'Generate access codes'"); ?></span>
<?php endif; ?>
</div>
</div>
<div class="form-group">
<label class=" control-label" for='language'>
<?php eT("Language:"); ?>
</label>
<div class="">
<?php if (isset($language)) {echo languageDropdownClean($surveyid, $language); } else {echo languageDropdownClean($surveyid, Survey::model()->findByPk($surveyid)->language); }?>
</div>
</div>
</div>
<div class="ls-flex-column ls-space padding left-5 right-35 col-md-6">
<!-- Email, Email Status -->
<div class="form-group">
<label class=" control-label" for='email'>
<?php eT("Email:"); ?>
</label>
<div class="">
<?=TbHtml::textField('email', $email, [
'class' => 'form-control',
'size' => '50',
'maxlength' => '320',
]);?>
</div>
</div>
<!-- Email Status -->
<div class="form-group">
<label class=" control-label" for='emailstatus'>
<?php eT("Email status:"); ?>
</label>
<div class="">
<?=TbHtml::textField('emailstatus', $emailstatus, [
'class' => 'form-control',
'size' => '50',
'maxlength' => '320',
'placeholder' => 'OK'
]);?>
</div>
</div>
<!-- Invitation sent, Reminder sent -->
<div class="form-group">
<!-- Invitation sent -->
<label class=" control-label" for='sent'>
<?php eT("Invitation sent?"); ?>
</label>
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="sent-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="row">
<div class="">
<?php if ($oSurvey->anonymized != 'Y'):?>
<?php
// TODO: move to controller
$bSwitchValue = (isset($sent) && $sent != 'N') ? "1" : "0";
$bRemindSwitchValue = (isset($remindersent) && $remindersent != 'N') ? "1" : "0";
$bSwitchValue = "0";
if (isset($sent) && $sent != 'N')
{
$bSwitchValue = "1";
$sentDBValue = $sent;
$sent = convertToGlobalSettingFormat($sent, true);
}
$bRemindSwitchValue = "0";
if (isset($remindersent) && $remindersent != 'N')
{
$bRemindSwitchValue = "1";
$remindersentDBValue = $remindersent;
$remindersent = convertToGlobalSettingFormat($remindersent, true);
}
?>
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "sent-switch",
'id'=>"sent-switch",
'htmlOptions'=>array('class'=>"YesNoDateSwitch action_toggle_bootstrap_switch"),
'value' => $bSwitchValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
<?php else:?>
<?php
$sentDBValue = $sent;
$remindersentDBValue = $remindersent;
$bSwitchValue = (isset($sent) && $sent != 'N') ? "1" : "0";
$bRemindSwitchValue = (isset($remindersent) && $remindersent != 'N') ? "1" : "0";
?>
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "sent-switch",
'id'=>"sent-switch",
'htmlOptions'=>array('class'=>"YesNoSwitch action_toggle_bootstrap_switch"),
'value' => $bSwitchValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
<?php endif; ?>
</div>
<div class="">
<div id="sent-date-container" data-parent="#sent-switch" class="selector__date-container_hidden date-container" <?php if (!$bSwitchValue){ echo "style='display:none;'"; }?> >
<!-- Sent Date -->
<div id="sent-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="sent-date" type="text" value="<?php echo isset($sent) && $sent!='N' ? convertToGlobalSettingFormat($sent,true) : ''?>" name="sent-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
</div>
<input class='form-control hidden YesNoDateHidden' type='text' size='20' id='sent' name='sent' value="<?php if (isset($sent) && $sent!='N') {echo convertToGlobalSettingFormat($sent,true); } else {echo " N "; }?>" />
</div>
</div>
<div class="form-group">
<!-- Reminder sent -->
<label class=" control-label" for='remindersent'>
<?php eT("Reminder sent?"); ?>
</label>
<div class="selector__yesNoContainer <?php echo $sCointainerClass; ?>" id="remind-yes-no-date-container" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<div class="row">
<div class="">
<?php if ($oSurvey->anonymized != 'Y') {
?>
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "remind-switch",
'id'=>"remind-switch",
'htmlOptions'=>array('class'=>"YesNoDateSwitch action_toggle_bootstrap_switch"),
'value' => $bRemindSwitchValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
<?php } else { ?>
<?php
$this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => "remind-switch",
'id'=>"remind-switch",
'htmlOptions'=>array('class'=>"YesNoSwitch action_toggle_bootstrap_switch"),
'value' => $bRemindSwitchValue,
'onLabel'=>gT('Yes'),
'offLabel' => gT('No')));
?>
<?php } ?>
</div>
<div class="">
<div id="remind-date-container" data-parent="#remind-switch" class="selector__date-container_hidden date-container" <?php if (!$bRemindSwitchValue){ echo "style='display:none;'"; }?> >
<div id="remind-date_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="remind-date" type="text" value="<?php echo isset($remindersent) && $remindersent!='N' ? convertToGlobalSettingFormat($remindersent,true) : ''?>" name="remind-date" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
</div>
<input class='form-control hidden YesNoDateHidden' type='text' size='20' id='remindersent' name='remindersent' value="<?php if (isset($remindersent) && $remindersent!='N') {echo convertToGlobalSettingFormat($remindersent,true); } else {echo " N "; }?>" />
</div>
<!-- Reminder count, Uses left -->
<div class="form-group">
<!-- Reminder count -->
<?php if ($token_subaction == "edit"): ?>
<label class=" control-label" for='remindercount'>
<?php eT("Reminder count:"); ?>
</label>
<div class="">
<input class='form-control' type='number' size='6' id='remindercount' name='remindercount' value="<?php echo $remindercount; ?>" />
</div>
<?php endif; ?>
</div>
<!-- Uses left -->
<div class="form-group">
<label class=" control-label" for='usesleft'>
<?php eT("Uses left:"); ?>
</label>
<div class="">
<input class='form-control' type='number' size='20' id='usesleft' name='usesleft' value="<?php if (isset($usesleft)) {echo $usesleft; } else {echo " 1 "; }?>" />
</div>
</div>
</div>
</div>
<div class="ls-flex-column ls-space padding left-5 right-35 col-md-12">
<!-- Valid from to -->
<div class="form-group">
<?php
if (isset($validfrom) && $validfrom != 'N')
{
$validfrom = convertToGlobalSettingFormat($validfrom, true);
}
if (isset($validuntil) && $validuntil != 'N')
{
$validuntil = convertToGlobalSettingFormat($validuntil, true);
}
?>
<!-- From -->
<label class=" control-label" for='validfrom'>
<?php eT("Valid from"); ?>:</label>
<div class=" has-feedback">
<div id="validfrom_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="validfrom" type="text" value="<?php echo isset($validfrom) ? $validfrom : ''?>" name="validfrom" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
<div class="form-group">
<!-- To -->
<label class=" control-label" for='validuntil'>
<?php eT('Until:'); ?>
</label>
<div class=" has-feedback">
<div id="validuntil_datetimepicker" class="input-group date">
<input class="YesNoDatePicker form-control" id="validuntil" type="text" value="<?php echo isset($validuntil) ? $validuntil : ''?>" name="validuntil" data-date-format="<?php echo $dateformatdetails['jsdate']; ?> HH:mm" data-locale="<?php echo convertLStoDateTimePickerLocale(Yii::app()->session['adminlang']); ?>">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
</div>
</div>
</div>
</div>
<!-- Custom attibutes -->
<div id="custom" class="tab-pane fade in">
<!-- Attributes -->
<?php foreach ($attrfieldnames as $attr_name => $attr_description): ?>
<div class="form-group">
<label class=" control-label" for='<?php echo $attr_name; ?>'>
<?php echo $attr_description['description'].($attr_description['mandatory'] == 'Y' ? '*' : '') ?>:
</label>
<div class="">
<input class='form-control' type='text' size='55' id='<?php echo $attr_name; ?>' name='<?php echo $attr_name; ?>' value='<?php if (isset($$attr_name)){echo htmlspecialchars($$attr_name, ENT_QUOTES, 'utf-8');}?>' />
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!-- Buttons -->
<p>
<?php
switch ($token_subaction)
{
case "edit":?>
<input type='submit' class="hidden" value='<?php eT("Update participant entry"); ?>' />
<input type='hidden' name='subaction' value='updatetoken' />
<input type='hidden' name='tid' value='<?php echo $tokenid; ?>' />
<?php break;
case "addnew": ?>
<input type='submit' class='hidden' value='<?php eT("Add participant entry"); ?>' />
<input type='hidden' name='subaction' value='inserttoken' />
<?php break;
} ?>
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
</p>
</form>
</div>
</div>
<div style="display: none;">
<?php
Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => "no",
'id' => "no",
'value' => '',
));
?>
</div>
</div>
<?php
App()->getClientScript()->registerScript('TokenformViewBSSwitcher', "
LS.renderBootstrapSwitch();
", LSYii_ClientScript::POS_POSTSCRIPT);
?>