-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcivimobile.survey_contacts.html
75 lines (72 loc) · 3.2 KB
/
civimobile.survey_contacts.html
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
<?php require_once 'civimobile.header.php'; ?>
<div data-role="page" id="cm-survey-contacts">
<div data-role="header">
<h3>Survey Respondants</h3>
<a href="#cm-surveys" class="ui-btn-left" data-icon="arrow-l" data-transition="slideup">Back</a>
</div>
<div data-role="content" id="survey-respondant-content">
<!--div class="ui-listview-filter ui-bar-c">
<input type="search" name="sc_name" id="sc_name" value=""/>
</div-->
<ul id="survey-contacts" data-role="listview" data-split-icon="info" data-split-theme="c" data-inset="false" data-filter="true">
</ul>
</div>
<script>
function surveyRespondantSearch(q) {
var surveyId = "<?php echo $_GET['sid']; ?>";
var resId = "<?php echo $_GET['resid']; ?>";
if ( isNaN(surveyId) || isNaN(resId) ) {
return;
}
CRM.api('OptionValue', 'get',
{ "option_group_id": "activity_type",
"component_id": "CiviCampaign",
"api.Activity.get": {"activity_type_id":"$value.value"}
},
{
success:function(data) {
$.each(data.values, function(key, value) {
$count = value['api.Activity.get'].count;
var activityIds = [];
if ($count > 0) {
$.each(value['api.Activity.get'].values, function(key, value) {
if (value.source_record_id == surveyId && value.status_id == 1) {
activityIds.push(value.id);
}
});
CRM.api3('ActivityContact', 'get',
{ "activity_id": {"IN":activityIds},
"record_type_id": "Activity Targets",
"api.Contact.get": {"id":"$value.contact_id"}
}).success(function(result) {
var surveyContactSelector = $('#survey-contacts');
if (result.count == 0) {
cmd = null;
}
else {
cmd = "refresh";
surveyContactSelector.show();
}
$.each(result.values, function(key, value){
var act_id = value.activity_id;
$.each(value['api.Contact.get'].values, function(key, value) {
var content = '<li role="option" tabindex="-1" data-ajax="false" data-theme="c" id="survey-res-'+value.id+'" >' +
'<a href="<?php echo CRM_Utils_System::url('civicrm/mobile/survey/interview', 'sid='); ?>'+ surveyId +'&resid='+ resId +'&aid='+ act_id +'&cid='+value.contact_id+'" data-transition="slideup">'+value.sort_name+'</a>' +
'<a href="<?php echo CRM_Utils_System::url('civicrm/mobile/contact', 'action=view&cid='); ?>'+ value.contact_id + '&context=cm-surveys" data-icon="info"></a>' +
'</li>';
surveyContactSelector.append(content);
setTimeout(function() {
$.mobile.loading('hide');
},1);
surveyContactSelector.listview(cmd);
});
});
});
}
});
}});
}
</script>
</div>
<!-- end of page -->
<?php require_once 'civimobile.footer.php'; ?>