/
browse.php
269 lines (255 loc) · 16.2 KB
/
browse.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
<?php
// Build the options for additional languages
$aLanguageNames=array();
foreach ($aLanguages as $sCode => $sName)
{
$aLanguageNames[] = $sCode . ":" . str_replace(";", " -", $sName);
}
$aLanguageNames = implode(";", $aLanguageNames);
// Build the column information : columnname=>Description,search(true/false) (type ?)
// Don't add id : because we don't really need it. This different from columnNames (no action).
// TODO: Merge columnNames and aTokenColumns : need more option (name,index,search, type, editable ...)
$aTokenColumns=getTokenFieldsAndNames($surveyid,false);
$aNotQuickFilter=array('tid','emailstatus','sent','remindersent','remindercount','completed','usesleft','validfrom','validuntil');
foreach($aTokenColumns as $aTokenColumn => $aTokenInformation)
{
if($aTokenColumn=="tid"){
$aTokenColumns[$aTokenColumn]['editable']=false;
$aTokenColumns[$aTokenColumn]['search']=false;
$aTokenColumns[$aTokenColumn]['add']=false;
}else{
$aTokenColumns[$aTokenColumn]['editable']=true;
$aTokenColumns[$aTokenColumn]['search']=true;
$aTokenColumns[$aTokenColumn]['add']=true;
}
if(in_array($aTokenColumn,$aNotQuickFilter)){
$aTokenColumns[$aTokenColumn]['quickfilter']=false;
}else{
$aTokenColumns[$aTokenColumn]['quickfilter']=true;
}
}
// Build the columnNames for the extra attributes
// and, build the columnModel
$attributes = getTokenFieldsAndNames($surveyid,true);
$uidNames=$columnNames=$aColumnHeader=array();
if (count($attributes) > 0)
{
foreach ($attributes as $sFieldname=>$aData)
{
$customEdit = '';
if($aData['mandatory'] == 'Y'){
$customEdit = ', editrules:{custom:true, custom_func:checkMandatoryAttr}';
}
$uidNames[] = '{ "name":"' . $sFieldname . '", "index":"' . $sFieldname . '", "sorttype":"string", "sortable": true, "align":"left", "editable":true, "width":100' . $customEdit . '}';
$aColumnHeaders[]=$aData['description'];
}
$columnNames='"'.implode('","',$aColumnHeaders).'"';
}
$sJsonColumnInformation=json_encode($aTokenColumns);
// Build the javasript variables to pass to the jqGrid
?>
<script type="text/javascript">
var sAddParticipantToCPDBText = '<?php eT("Add participants to central database",'js');?>';
var sLoadText = '<?php eT("Loading...",'js');?>';
var sSelectRowMsg = "<?php eT("Please select at least one participant.", 'js') ?>";
var sWarningMsg = "<?php eT("Warning", 'js') ?>";
var sRecordText = '<?php eT("View {0} - {1} of {2}",'js');?>';
var sPageText = '<?php eT("Page {0} of {1}",'js');?>';
var imageurl = "<?php echo Yii::app()->getConfig('adminimageurl'); ?>";
var mapButton = "<?php eT("Next") ?>";
var error = "<?php eT("Error") ?>";
var removecondition = "<?php eT("Remove condition") ?>";
var cancelBtn = "<?php eT("Cancel") ?>";
var exportBtn = "<?php eT("Export") ?>";
var okBtn = "<?php eT("OK") ?>";
var resetBtn = "<?php eT("Reset") ?>";
var noRowSelected = "<?php eT("You have no row selected") ?>";
var searchBtn = "<?php eT("Search") ?>";
var shareMsg = "<?php eT("You can see and edit settings for shared participants in share panel.") ?>"; //PLEASE REVIEW
var jsonSearchUrl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/getSearch_json/surveyid/{$surveyid}/search"); ?>";
var getSearchIDs = "<?php echo Yii::app()->getController()->createUrl("admin/participants/sa/getSearchIDs"); ?>";
var addbutton = "<?php echo Yii::app()->getConfig('adminimageurl')."plus.png" ?>";
var minusbutton = "<?php echo Yii::app()->getConfig('adminimageurl') . "deleteanswer.png" ?>";
var survey_id = "<?php echo $surveyid; ?>";
var delUrl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/delete/surveyid/{$surveyid}"); ?>";
var saveBtn = "<?php eT("Save changes") ?>";
var okBtn = "<?php echo eT("OK") ?>";
var delmsg = "<?php eT("Are you sure you want to delete the selected entries?") ?>";
var surveyID = "<?php echo $surveyid; ?>";
var jsonUrl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/getTokens_json/surveyid/{$surveyid}"); ?>";
var postUrl = "<?php echo Yii::app()->getController()->createUrl("admin/participants/sa/setSession"); ?>";
var editUrl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/editToken/surveyid/{$surveyid}"); ?>";
var sEmptyRecords ='<?php eT("Participant table is empty.",'js');?>';
var sCaption ='';
var sDelTitle = '<?php eT("Delete selected participant(s) from this survey",'js');?>';
var sRefreshTitle ='<?php eT("Reload participant list",'js');?>';
var noSearchResultsTxt = '<?php eT("No survey participants matching the search criteria",'js');?>';
var sFind= '<?php eT("Filter",'js');?>';
var remindurl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/email/action/remind/surveyid/{$surveyid}"); ?>";
var attMapUrl = "<?php echo $this->createUrl("admin/participants/sa/attributeMapToken/sid/");?>";
var invitemsg = "<?php echo eT("Send an invitation email to the selected entries (if they have not yet been sent an invitation email)"); ?>"
var remindmsg = "<?php echo eT("Send a reminder email to the selected entries (if they have already received the invitation email)"); ?>"
var inviteurl = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/email/action/invite/surveyid/{$surveyid}"); ?>";
var sSummary = '<?php eT("Summary",'js');?>';
var showDelButton = <?php echo $showDelButton; ?>;
var showBounceButton = <?php echo $showBounceButton; ?>;
var showInviteButton = <?php echo $showInviteButton; ?>;
var showRemindButton = <?php echo $showRemindButton; ?>;
var sDelete = "<?php eT('Delete this search criteria'); ?>";
var sAdd = "<?php eT("Add another search criteria"); ?>";
<?php if (!Permission::model()->hasGlobalPermission('participantpanel','read')){?>
var bParticipantPanelPermission=false;
<?php
} else {?>
var bParticipantPanelPermission=true;
var viewParticipantsLink = "<?php eT("View participants of this survey in the central participant database panel") ?>";
<?php } ?>
var sBounceProcessing = "<?php eT("Start bounce processing") ?>";
var sBounceProcessingURL = "<?php echo Yii::app()->getController()->createUrl("admin/tokens/sa/bounceprocessing/surveyid/{$surveyid}"); ?>";
var participantlinkUrl="<?php echo Yii::app()->getController()->createUrl("admin/participants/sa/displayParticipants"); ?>";
var andTxt="<?php eT("AND") ?>";
var orTxt="<?php eT("OR") ?>";
var searchtypes = ["<?php eT("Equals") ?>","<?php eT("Contains") ?>","<?php eT("Not equal") ?>","<?php eT("Not contains") ?>","<?php eT("Greater than") ?>","<?php eT("Less than") ?>"];
var colNames = ["ID","<?php eT("Action") ?>","<?php eT("First name") ?>","<?php eT("Last name") ?>","<?php eT("Email address") ?>","<?php eT("Email status") ?>","<?php eT("Token") ?>","<?php eT("Language") ?>","<?php eT("Invitation sent?") ?>","<?php eT("Reminder sent?") ?>","<?php eT("Reminder count") ?>","<?php eT("Completed?") ?>","<?php eT("Uses left") ?>","<?php eT("Valid from") ?>","<?php eT("Valid until") ?>"<?php if (count($columnNames)) echo ','.$columnNames; ?>];
var colModels = [
{ "name":"tid", "index":"tid", "width":30, "align":"center", "sorttype":"int", "sortable": true, "editable":false, "hidden":false},
{ "name":"action", "index":"action", "sorttype":"string", "sortable": false, "width":120, "align":"center", "editable":false},
{ "name":"firstname", "index":"firstname", "sorttype":"string", "sortable": true, "width":100, "align":"left", "editable":true},
{ "name":"lastname", "index":"lastname", "sorttype":"string", "sortable": true,"width":100, "align":"left", "editable":true},
{ "name":"email", "index":"email","align":"left","width":170, "sorttype":"string", "sortable": true, "editable":true},
{ "name":"emailstatus", "index":"emailstatus","align":"left","width": 80,"sorttype":"string", "sortable": true, "editable":true},
{ "name":"token", "index":"token","align":"left", "sorttype":"int", "sortable": true,"width":150,"editable":true},
{ "name":"language", "index":"language","align":"left", "sorttype":"int", "sortable": true,"width":100,"editable":true, "formatter":'select', "edittype":"select", "editoptions":{"value":"<?php echo $aLanguageNames; ?>"}},
{ "name":"sent", "index":"sent","align":"left", "sorttype":"int", "sortable": true,"width":80,"editable":true},
{ "name":"remindersent", "index":"remindersent","align":"left", "sorttype":"int", "sortable": true,"width":80,"editable":true},
{ "name":"remindercount", "index":"remindercount","align":"right", "sorttype":"int", "sortable": true,"width":80,"editable":true, "classes": "jqgrid-tokens-number-padding"},
{ "name":"completed", "index":"completed","align":"left", "sorttype":"int", "sortable": true,"width":80,"editable":true},
{ "name":"usesleft", "index":"usesleft","align":"right", "sorttype":"int", "sortable": true,"width":80,"editable":true, "classes": "jqgrid-tokens-number-padding"},
{ "name":"validfrom", "index":"validfrom","align":"left", "sorttype":"int", "sortable": true,"width":160,"editable":true},
{ "name":"validuntil", "index":"validuntil","align":"left", "sorttype":"int", "sortable": true,"width":160,"editable":true}
<?php if (count($uidNames)) echo ','.implode(",\n", $uidNames); ?>];
var colInformation=<?php echo $sJsonColumnInformation ?>
function checkMandatoryAttr(value, colname) {
if (value == '')
return [false, '<?php eT("Please enter a value for: ") ?>'+colname]; // See http://phpjs.org/functions/sprintf/
else
return [true,''];
}
</script>
<div class='side-body <?php echo getSideBodyClass(false); ?>'>
<?php $this->renderPartial('/admin/survey/breadcrumb', array('oSurvey'=>$oSurvey, 'token'=>true, 'active'=>gT("Survey participants"))); ?>
<h3><?php eT("Survey participants",'js'); ?></h3>
<div class='scrolling-wrapper'>
<div class="row">
<div class="col-lg-12" style="margin-top: 1em;">
<?php
// Add some script for gridsearch
App()->getClientScript()->registerPackage('jquery-bindWithDelay');
App()->getClientScript()->registerPackage('jqgrid.addons');
?>
<table id="displaytokens"></table>
<div id="pager"></div>
<div id="search">
<?php
$aOptionSearch = array('' => gT('Select...','unescaped'));
foreach($aTokenColumns as $sTokenColumn => $aTokenInformation)
{
if($aTokenInformation['search'])
{
$aOptionSearch[$sTokenColumn]=$aTokenInformation['description'];
}
}
$aOptionCondition = array('' => gT('Select...','unescaped'),
'equal' => gT("Equals",'unescaped'),
'contains' => gT("Contains",'unescaped'),
'notequal' => gT("Not equal",'unescaped'),
'notcontains' => gT("Not contains",'unescaped'),
'greaterthan' => gT("Greater than",'unescaped'),
'lessthan' => gT("Less than",'unescaped'));
?>
<table id='searchtable'>
<tr>
<td><?php echo CHtml::dropDownList('field_1', 'id="field_1"', $aOptionSearch, array('class' => 'form-control')); ?></td>
<td><?php echo CHtml::dropDownList('condition_1', 'id="condition_1"', $aOptionCondition, array('class' => 'form-control')); ?></td>
<td><input class='form-control' type="text" id="conditiontext_1" /></td>
<td>
<span data-toggle='tooltip' title='<?php eT("Add another search criteria");?>' class="ui-pg-button addcondition-button icon-add text-success" style="">
</td>
</tr>
</table>
</div>
<?php if (Permission::model()->hasGlobalPermission('participantpanel','read')) { ?>
<div id="addcpdb" title="addsurvey" style="display:none">
<p><?php eT("Please select the attributes that are to be added to the central database"); ?></p>
<p>
<select id="attributeid" name="attributeid" multiple="multiple">
<?php
if(!empty($attrfieldnames))
{
foreach($attrfieldnames as $key=>$value)
{
echo "<option value='".$key."'>".$value."</option>";
}
}
?>
</select>
</p>
</div>
<?php } ?>
<div id="fieldnotselected" title="<?php eT("Error") ?>" style="display:none">
<p>
<?php eT("Please select a field."); ?>
</p>
</div>
<div id="conditionnotselected" title="<?php eT("Error") ?>" style="display:none">
<p>
<?php eT("Please select a condition."); ?>
</p>
</div>
<div id="norowselected" title="<?php eT("Error") ?>" style="display:none">
<p>
<?php eT("Please select at least one participant."); ?>
</p>
</div>
<div class="ui-widget ui-helper-hidden" id="client-script-return-msg" style="display:none"></div>
<div>
<div id ='dialog-modal'></div>
</div>
</div>
</div>
</div>
<!-- CGridView -->
<?php $pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);?>
<!-- Todo : search boxes -->
<!-- Grid -->
<div class="row">
<div class="content-right" style="overflow-x: scroll;">
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider' => $model->search(),
'id' => 'token-grid',
'emptyText'=>gT('No tokens found.'),
'template' => "{items}\n<div class=\"row-fluid\"><div class=\"col-sm-4\" id=\"massive-action-container\">$massiveAction</div><div class=\"col-sm-4 pager-container \">{pager}</div><div class=\"col-sm-4 summary-container\">{summary}</div></div>",
'summaryText'=>gT('Displaying {start}-{end} of {count} result(s).').' '. sprintf(gT('%s rows per page'),
CHtml::dropDownList(
'pageSize',
$pageSize,
Yii::app()->params['pageSizeOptions'],
array('class'=>'changePageSize form-control', 'style'=>'display: inline; width: auto'))),
'itemsCssClass' =>'table-striped',
//'htmlOptions'=>array('style'=>'max-width: none;'),
'columns' => $model->attributesForGrid,
));
?>
</div>
</div>
<!-- To update rows per page via ajax -->
<script type="text/javascript">
jQuery(function($) {
jQuery(document).on("change", '#pageSize', function(){
$.fn.yiiGridView.update('survey-grid',{ data:{ pageSize: $(this).val() }});
});
});
</script>
</div>
</div>