/
dashboard.php
209 lines (196 loc) · 8.25 KB
/
dashboard.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
<!-- Warning if user has a token table created -->
<?php if (isset($hasTokenTable) && $hasTokenTable): ?>
<p class='alert alert-warning'>
<span class='fa fa-exclamation-circle'></span>
<?php echo $plugin->gT('Please delete your token participant table to be able to use Cint Link.'); ?>
</p>
<?php endif; ?>
<!-- Some info -->
<?php if (empty($surveyId)): ?>
<p class='alert alert-info'>
<span class='fa fa-info-circle'></span>
<?php echo $plugin->gT('To order participants, please go to the survey specific CintLink view.'); ?>
</p>
<?php elseif (!empty($survey) && $survey->active != 'Y'): ?>
<p class='alert alert-info'>
<span class='fa fa-info-circle'></span>
<?php echo $plugin->gT('Please make sure the survey is activated before placing a Cint order.'); ?>
</p>
<?php endif; ?>
<!-- Cint widget button (not visible from global dashboard) -->
<?php if (!empty($surveyId)): ?>
<div class='row'>
<!-- Show Cint widget -->
<div id='cintlink-widget-button' class='col-sm-3' style='cursor: pointer;'>
<div
class='panel panel-primary cintlink-shadow'
onclick='<?php if ($additionalLanguages === null): echo 'LS.plugin.cintlink.showWidget();'; else: echo 'LS.plugin.cintlink.showLangWizard();'; endif; ?>'
<?php if ($hasTokenTable): ?> disabled='disabled' <?php endif; ?>
>
<div class='panel-heading'>
<h4 class='panel-title'><?php echo $plugin->gT('Choose target group'); ?></h4>
</div>
<div class='panel-body text-center text-success'>
<span class='fa-stack fa-lg'>
<i class='fa fa-circle fa-stack-2x text-success'></i>
<i class='fa fa-bars fa-stack-1x fa-inverse'></i>
</span>
<p><?php echo $plugin->gT('Add participants to your survey'); ?></p>
</div>
</div>
</div>
<div id='cintlink-login-button' class='col-sm-3' style='<?php if (!$loggedIn) echo 'cursor: pointer;'; ?>'>
<div
class='panel panel-primary cintlink-shadow <?php if ($loggedIn) echo 'disabled'; ?>'
onclick='<?php if (!$loggedIn) echo 'LS.plugin.cintlink.showLoginForm();'; ?>'
>
<div class='panel-heading'>
<h4 class='panel-title'><?php echo $plugin->gT('Login'); ?></h4>
</div>
<div class='panel-body text-center text-success'>
<span class='fa-stack fa-lg'>
<i class='fa fa-circle fa-stack-2x text-success'></i>
<i class='fa fa-sign-in fa-stack-1x fa-inverse'></i>
</span>
<p><?php echo $plugin->gT('Login to limesurvey.org'); ?></p>
</div>
</div>
</div>
<!-- Modal for Cint language wizard -->
<div id="cint-lang-wizard" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <?php // JS add not.type as panel-type, e.g. panel-default, panel-danger ?>
<div class="modal-header panel-heading">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><?php echo $plugin->gT('Choose language'); ?></h4>
</div>
<div class="modal-body">
<p class='modal-body-text'><?php echo $plugin->gT('Pick a language that will be used as default for this order. Make sure your order\'s country have this language as an official language.'); ?></p>
<!-- Radio list with languages -->
<form class='form-horizontal'>
<div class='radio'>
<label><input type='radio' name='lang' checked='checked' value='<?php echo $survey->language; ?>' /><?php echo getLanguageNameFromCode($survey->language)[0]; ?></label>
</div>
<?php foreach ($survey->additionalLanguages as $lang): ?>
<div class='radio'>
<label><input type='radio' name='lang' value='<?php echo $lang; ?>' /><?php echo getLanguageNameFromCode($lang)[0]; ?></label>
</div>
<?php endforeach; ?>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"> <?php eT("Cancel"); ?></button>
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick='LS.plugin.cintlink.langWizardOK();' > <?php eT("OK"); ?></button>
</div>
</div>
</div>
</div>
<!-- Refresh -->
<button id='cintlink-refresh-button' class='btn btn-default pull-right' onclick='LS.plugin.cintlink.showDashboard();'><span class='fa fa-refresh'></span> <?php echo $plugin->gT('Refresh'); ?></button>
</div>
<?php endif; ?>
<h4>Orders</h4>
<div id='cintlink-gridview'>
<?php
$columns = array();
$columns[] = array(
'name' => 'url',
'header' => 'ID',
'value' => '$data->shortId'
);
$columns[] = array(
'name' => 'created',
'header' => $plugin->gT('Created'),
'value' => '$data->formattedCreatedDate'
);
// Only needed on global dashboard
if (empty($surveyId))
{
$columns[] = array(
'name' => 'sid',
'header' => $plugin->gT('Survey ID'),
'value' => '$data->surveyIdLink',
'type' => 'raw'
);
}
$columns[] = array(
'name' => 'ordered_by',
'header' => $plugin->gT('Ordered by'),
'value' => '$data->user->full_name'
);
$columns[] = array(
'name' => 'country',
'header' => $plugin->gT('Country'),
'value' => '$data->country'
);
$columns[] = array(
'name' => 'target-group',
'header' => $plugin->gT('Target group'),
'value' => '(strlen($data->targetGroup) > 50
? CHtml::tag("span", array("title" => $data->targetGroup, "data-toggle" => "tooltip"), ellipsize($data->targetGroup, 50))
: $data->targetGroup)',
'type' => 'raw'
);
$columns[] = array(
'name' => 'age',
'header' => $plugin->gT('Age'),
'value' => '$data->age',
'htmlOptions' => array(
'class' => 'cint-age'
)
);
$columns[] = array(
'name' => 'price',
'header' => $plugin->gT('Price'),
'value' => '$data->price',
'type' => 'raw',
'htmlOptions' => array(
'class' => 'cint-price'
)
);
$columns[] = array(
'name' => 'completes',
'header' => $plugin->gT('Completes'),
'value' => '$data->completes',
);
$columns[] = array(
'name' => '__completedCheck',
'header' => '',
'value' => '$data->completedCheck',
'type' => 'raw'
);
$columns[] = array(
'name' => 'status',
'header' => $plugin->gT('Status'),
'value' => '$data->styledStatus',
'type' => 'raw',
'id' => 'cintlink-status-column',
'htmlOptions' => array(
)
);
$columns[] = array(
'name' => 'buttons',
'header' => '',
'value' => '$data->buttons',
'type' => 'raw',
'htmlOptions' => array(
'class' => 'cint-buttons'
)
);
$widget = $this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $model->search($surveyId),
'id' => 'url',
'itemsCssClass' =>'table-striped',
'emptyText' => $plugin->gT('No order made yet'),
'afterAjaxUpdate' => 'doToolTip',
'ajaxUpdate' => true,
'columns' => $columns
));
?>
</div>
<!-- Hack to not publish jQuery twice -->
<?php $plugin->renderClientScripts(); ?>