-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcivimobile.survey_interview.html
94 lines (81 loc) · 3.62 KB
/
civimobile.survey_interview.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php require_once 'civimobile.header.php'; ?>
<div data-role="page" id="cm-survey-interview">
<div data-role="header">
<h3>Interview Respondant</h3>
<a href="#" data-role="button" class="ui-btn-left" data-icon="arrow-l" data-transition="slideup" id="survey-contact-listing">Back</a>
<a href="#" id="save-survey-button" data-role="button" data-icon="check" class="ui-btn-right jqm-save">Save</a>
</div>
<div data-role="content" id="survey-interview-content">
<div id="crm-profile-content"></div>
<div id="question-list"></div>
</div>
<script>
var surveyId = "<?php echo $_GET['sid']; ?>";
var resId = "<?php echo $_GET['resid']; ?>";
var aid = "<?php echo $_GET['aid']; ?>";
var contactId = "<?php echo $_GET['cid']; ?>";
var surveyProfileId;
function surveyInterview() {
if ( isNaN(surveyId) || isNaN(resId) || isNaN(contactId) ) {
return;
}
$('#crm-profile-content').empty();
setTimeout(function() {
$.mobile.loading('show', {theme:"e", text:"Loading...", textonly:true, textVisible: true});
},1);
// get the profile related to survey
CRM.api('UFJoin','get',{ 'sequential' :'1', 'module' :'CiviCampaign', 'entity_id' : surveyId, 'api.Entity.get': {'entity_table':'civicrm_survey'}}
,{
success:function (data) {
surveyProfileId = data.values[0].uf_group_id;
var dataUrl = "<?php echo CRM_Utils_System::url('civicrm/profile/edit','reset=1&json=1', false, null, false);?>";
buildProfile( surveyProfileId, 'crm-profile-content', contactId, dataUrl + '&aid=' + aid );
}
}
);
// get the result for the survey
CRM.api('OptionValue','get',
{ 'version' :'3', 'option_group_id': resId }, {
success:function (data){
setTimeout(function() {
$.mobile.loading('hide');
},1);
$('#question-list').append('<div data-role="fieldcontain" class="ui-field-contain ui-body ui-br"><div class="ui-select"><label for="select-choice-0" class="select"></label> <select name="select-choice-0" id="select-choice-1"> </select></div></div>');
$.each(data.values, function(index, value) {
$('#select-choice-1').append('<option value="'+value.value+'">'+value.label+'</option>');
});
$('#select-choice-1').selectmenu();
}
}
);
setTimeout(function() {
$.mobile.loading('show');
},1);
}
// save action to save the result for the activity
function saveSurvey(){
if ( isNaN(aid) ) {
return;
}
var selectValue = $('#select-choice-1 option:selected').text();
CRM.api('Activity','create', {'version' :'3', 'id' : aid, 'result': selectValue, 'status_id': '2'}, {
success:function (data) {
saveProfile(surveyProfileId, contactId, null, aid);
// show success message
$( "#popup-success" ).popup( "open" );
gotoSurveyContactListing();
}
});
}
function gotoSurveyContactListing() {
var surveyContactUrl = "<?php echo CRM_Utils_System::url('civicrm/mobile/survey/contacts','sid=', false, null, false);?>";
$.mobile.changePage( surveyContactUrl + surveyId + '&resid=' + resId );
}
</script>
<div data-role="popup" id="popup-success" data-theme="c" data-overlay-theme="a" class="ui-content">
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>
<p>Your changes are saved</p>
</div>
</div>
<!-- end of page -->
<?php require_once 'civimobile.footer.php'; ?>