-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchurchassessment.php
194 lines (151 loc) · 5.09 KB
/
churchassessment.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
<?php
error_reporting(0);
class churchassessment extends CI_Controller
{
public function add_churchassessment()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('first_name', 'First Name', 'required');
$this->form_validation->set_rules('last_name', 'Last Name', 'required');
$this->form_validation->set_rules('email', 'email', 'required');
$this->form_validation->set_error_delimiters('<div style="color: red;">', '</div>');
if ($this->form_validation->run() == FALSE)
{
$data['content'] = 'churchassessment_insert';
$this->load->view('layout/layoutassesment',$data);
}
else
{
$verify_reg_code=uniqid();
$config['mailtype'] = 'html';
$this->load->library('email',$config);
$this->load->library('table');
$this->email->from('[email protected]', 'GPI');
$first_name=$this->input->post('first_name');
$last_name=$this->input->post('last_name');
$zip_code=$this->input->post('zip_code');
$organization=$this->input->post('organization');
$senior_name=$this->input->post('senior_name');
$email=$this->input->post('email');
$totalscore=$this->input->post('postscore');
$password=mt_rand(1000, 9999);
if($totalscore>=0 && $totalscore<=10)
{
$level_id=1;
$level="1-2";
}
else if($totalscore>=11 && $totalscore<=20)
{
$level_id=2;
$level="3-4";
}
else if($totalscore>=21 && $totalscore<=30)
{
$level_id=3;
$level="4-5";
}
else
{
$level_id=4;
$level="5-6";
}
$data=array(
'first_name'=>$first_name,
'last_name'=>$last_name,
'email'=>$email,
'zip_code'=>$zip_code,
'organization'=>$organization,
'senior_name'=>$senior_name,
'password'=>$password,
'score'=>$totalscore,
'level_id'=>$level_id,
'verify_reg_code'=>$verify_reg_code,
'flag'=>2,
);
$this->gpi_model->insert($data,'users');
//$this->email->to($this->input->post('email').', [email protected]');
$this->email->to($this->input->post('email'));
$qa="";
$i=0;
$answer=$this->input->post('answer_id');
$question=$this->input->post('question');
$start = '
<html>
<head>
<title>GPI</title>
</head>
<body>
<p align="center"><h1><b>Church Profile Assessment</b></h1></p><br/>
<table align="center"><h1><b>Score:'.$totalscore.'</b></h1><br/>
<h1><b>Level:'.$level.'</b></h1></table><br/>
<table>
<tr>
<td><b>First Name : </b></td>
<td>'.$first_name.'</td>
</tr>
<tr>
<td><b>Last Name : </b></td>
<td>'.$last_name.'</td>
</tr>
<tr>
<td><b>Email : </b></td>
<td>'.$email.'</td>
</tr>
<tr>
<td><b>Password : </b></td>
<td>'.$password.'</td>
</tr>
<tr>
<td><b>Church Name : </b></td>
<td>'.$organization.'</td>
</tr>
<tr>
<td><b>Zip Code : </b></td>
<td>'.$zip_code.'</td>
</tr>
<tr>
<td><b>Senior pastor name : </b></td>
<td>'.$senior_name.'</td>
</tr><br />';
$userid = $this->db->insert_id();
$mid="";
foreach($answer as $answer)
{
$question_name=$this->gpi_model->get_questions("church_questions",$question[$i]);
//$qa.= $question_name->questions_name.":".$answer."\n";
//$qa.= $question_name->questions_name."\n";
//$qa.= $answer."\n";
$mid.='<b>Que#'.$question_name->questions_id.':'.$question_name->questions_name.'</b><br />
Ans)'.$answer.'<br/><br/>';
$data2=array(
'user_id'=>$userid,
'questions' =>$question_name->questions_name,
'answers' =>$answer,
);
$this->gpi_model->insert($data2,'user_answer_church');
$i++;
}
$this->email->subject('Score');
$last='</table><br /><br />'.$mid.'
<p><b>Thanks</b></p>
<p><b>FURQAN SHAFIQUE</b></p>
<p><b>Founder & CEO</b></p>
<p><b>Appexos Software Inc.</b></p>
<p><b>https://www.appexos.com</b><p>
</body>
</html>';
$message=$start.$last;
//print_r($message);
//exit;
$this->email->message($message);
$this->email->send();
//echo $this->email->print_debugger();
$this->session->set_flashdata('msg', "Email Successfully Sent. Your Current Level is : ".$level);
redirect(base_url()."churchassessment/add_churchassessment/church-profile-assessment.html");
}
}
function readinessquestions_view()
{
$this->load->view('readinessassment_total');
}
}