Version 1.19 by SuperUwe Trueggelmann on 2022-10-13

Show last authors
1 {{groovy}}
2
3 import groovy.sql.Sql
4
5 String strDBTable = "\"regUser\".\"newUser\""
6 def sqlConnection = new Sql(services.cmpConnectRegDB.connectRegDB())
7
8 String strCurRecCol = "firstname"
9 int intRecCount=0
10
11 String strContactID = ""
12 String strCompanyName = ""
13 String strTitle = ""
14 String strFirstname = ""
15 String strLastname = ""
16 String strPrefname = ""
17 String strRole = ""
18 String strLphone = ""
19 String strMphone = ""
20 String strEmail = ""
21 String strEmail2 = ""
22 String strCreateTime = java.time.ZonedDateTime.now()
23 String strCreateIP = request.remoteAddr
24 String strConfCode = ""
25 String strEmailBody = ""
26
27 String strFormStatus = "DataEntry"
28
29 String strEditCommand = request.get("butAction")
30 if (strEditCommand == null){
31 strEditCommand = "none"
32 xcontext.put("strEditCommand", strEditCommand)
33 }
34 // println "strEditCommand:" + strEditCommand
35
36 //Process Commands
37
38 if ((strEditCommand == "Correct") || (strEditCommand == "Register") || (strEditCommand == "Proceed")){
39
40 strCompanyName = services.cleanStr.alphanum(request.companyname)
41 // println "Received Company name: " + strCompanyName
42 strTitle = services.cleanStr.alphanum(request.title)
43 strFirstname = services.cleanStr.alphanum(request.firstname)
44 strLastname = services.cleanStr.alphanum(request.lastname)
45 strPrefname = services.cleanStr.alphanum(request.prefname)
46 strRole = services.cleanStr.alphanum(request.role)
47 strLphone = services.cleanStr.numphone(request.lphone)
48 strMphone = services.cleanStr.numphone(request.mphone)
49 strEmail = services.cleanStr.alphanum(request.email)
50 // println "Received E-mail: " + strEmail
51 strEmail2 = services.cleanStr.alphanum(request.email2)
52 strCreateTime = java.time.ZonedDateTime.now()
53 strCreateIP = request.remoteAddr
54 strConfCode = services.genRandom.randStr(16)
55 if (strEditCommand == "Register"){
56 String sqlHowManyRecords = "SELECT count(createtime) as reccount FROM " + strDBTable + " where email='" + strEmail + "'"
57 intRecCount = sqlConnection.rows(sqlHowManyRecords).reccount[0] ?:0
58 if (intRecCount == 0){ //insert a new record
59 sqlQueryInsertRec = "INSERT INTO " + strDBTable +
60 """(
61 companyname,
62 title,
63 firstname,
64 lastname,
65 prefname,
66 role,
67 lphone,
68 mphone,
69 email,
70 email2,
71 createtime,
72 createip,
73 confemailsenttime,
74 confemailsentcode)
75 VALUES(
76 '$strCompanyName',
77 '$strTitle',
78 '$strFirstname',
79 '$strLastname',
80 '$strPrefname',
81 '$strRole',
82 '$strLphone',
83 '$strMphone',
84 '$strEmail',
85 '$strEmail2',
86 now(),
87 '$strCreateIP',
88 now(),
89 '$strConfCode')
90 ;"""
91 sqlConnection.execute(sqlQueryInsertRec)
92 }
93 else{ // update the existing record
94 sqlQueryInsertRec = "UPDATE " + strDBTable +
95 """
96 SET
97 companyname = '$strCompanyName',
98 title = '$strTitle',
99 firstname = '$strFirstname',
100 lastname = '$strLastname',
101 prefname = '$strPrefname',
102 role = '$strRole',
103 lphone = '$strLphone',
104 mphone = '$strMphone',
105 email = '$strEmail',
106 email2 = '$strEmail2',
107 createtime = now(),
108 createip = '$strCreateIP',
109 confemailsenttime = now(),
110 confemailsentcode = '$strConfCode',
111 confreceivetime = null,
112 confreceivecode = '',
113 status = 'new'
114 WHERE email = '$strEmail';"""
115 sqlConnection.execute(sqlQueryInsertRec)
116 }
117 strEmailBody = "Dear " + strPrefname + ","
118 strEmailBody = strEmailBody + "\r\n" + "\r\n" + "A request was made to register you to the CEC website (https://cecocert.com) with the following information:" + "\r\n" + "\r\n"
119 strEmailBody = strEmailBody + "Name: " + strTitle + " " + strFirstname + " " + strLastname + "\r\n"
120 strEmailBody = strEmailBody + "Company: " + strCompanyName + "\r\n"
121 strEmailBody = strEmailBody + "Role: " + strRole + "\r\n"
122 strEmailBody = strEmailBody + "Landline phone: " + strLphone + "\r\n"
123 strEmailBody = strEmailBody + "Mobile phone:" + strMphone + "\r\n" + "\r\n"
124 strEmailBody = strEmailBody + "The request was made from IP address: " + strCreateIP
125 strEmailBody = strEmailBody + "\r\n" + "\r\n" + "Please click the below link to confirm your e-mail address:" + "\r\n"
126 strEmailBody = strEmailBody + "https://cecocert.com/bin/view/StartPage/X1100%20-%20Process%20e-mail%20confirmation/WebHome"
127 strEmailBody = strEmailBody + "?em=" + strEmail + "&cc=" + strConfCode
128 strEmailBody = strEmailBody + "\r\n" + "\r\n" + "If you do not confirm your e-mail address within 24 hours, the information you entered will be deleted!"
129
130 // println strEmailBody
131 xcontext.put("strEmailBody",strEmailBody)
132 // services.writeLog.writeLogEntry(xcontext.getUser(), request.remoteAddr, doc.space, "INSERT AS NEW", intCurUID)
133 xcontext.put("strCompanyName",strCompanyName)
134 xcontext.put("strTitle",strTitle)
135 xcontext.put("strFirstname",strFirstname)
136 xcontext.put("strLastname",strLastname)
137 xcontext.put("strPrefname",strPrefname)
138 xcontext.put("strRole",strRole)
139 xcontext.put("strLphone",strLphone)
140 xcontext.put("strMphone",strMphone)
141 xcontext.put("strEmail",strEmail)
142 xcontext.put("strEmail2",strEmail2)
143 xcontext.put("strCreateIP",strCreateIP)
144 strFormStatus = "SendEmail"
145 }
146 if (strEditCommand == "Proceed"){
147 xcontext.put("strCompanyName",strCompanyName)
148 xcontext.put("strTitle",strTitle)
149 xcontext.put("strFirstname",strFirstname)
150 xcontext.put("strLastname",strLastname)
151 xcontext.put("strPrefname",strPrefname)
152 xcontext.put("strRole",strRole)
153 xcontext.put("strLphone",strLphone)
154 xcontext.put("strMphone",strMphone)
155 xcontext.put("strEmail",strEmail)
156 xcontext.put("strEmail2",strEmail2)
157 xcontext.put("strCreateIP",strCreateIP)
158 strFormStatus = "DataVerify"
159 }
160 if (strEditCommand == "Correct"){
161 xcontext.put("strCompanyName",strCompanyName)
162 xcontext.put("strTitle",strTitle)
163 xcontext.put("strFirstname",strFirstname)
164 xcontext.put("strLastname",strLastname)
165 xcontext.put("strPrefname",strPrefname)
166 xcontext.put("strRole",strRole)
167 xcontext.put("strLphone",strLphone)
168 xcontext.put("strMphone",strMphone)
169 xcontext.put("strEmail",strEmail)
170 xcontext.put("strEmail2",strEmail2)
171 xcontext.put("strCreateIP",strCreateIP)
172 strFormStatus = "DataCorrection"
173 }
174 }
175 sqlConnection.close()
176 xcontext.put("strFormStatus", strFormStatus)
177
178 {{/groovy}}
179
180 {{velocity}}
181 ##$xcontext.strFormStatus
182 #if( $xcontext.strFormStatus == "DataEntry" )
183 {{html wiki=false clean=false}}
184 <head>
185 <style>
186 #cecTable {
187 font-family: Arial, Helvetica, sans-serif;
188 border-collapse: collapse;
189 border-color: #007d84
190 width: 100%;
191 }
192
193 #cecTable td, #cecTable th {
194 border: 1px solid #007d84;
195 padding: 8px;
196 }
197
198 #cecTable tr:nth-child(even){background-color: #d0d3d4;}
199
200 #cecTable tr:hover {background-color: #ddd;}
201
202 #cecTable th {
203 padding-top: 12px;
204 padding-bottom: 12px;
205 text-align: left;
206 background-color: #007d84;
207 color: white;
208 }
209 </style>
210 </head>
211 <form action="" class="xformInline" method="post" name="User Registration Form">
212 <table id="table1"; cellspacing="5px" cellpadding="5%" border="1" width="100%"; align="left">
213 <col style="width:30%">
214 <col style="width:70%">
215 <th colspan = "2">
216 <b>Company Information</b>
217 </th>
218 <tr>
219 <td align="left" class="style1">Company name:</td>
220 <td class="style1">
221 <input type="text" id="companyname" name="companyname" placeholder="Enter the legal name of your company" size="50">
222 </select>
223 </td>
224 </tr>
225 <tr>
226 <td align="left" class="style1">Registered Business Address - House Number, Street:</td>
227 <td class="style1">
228 <input type="text" id="companyaddress" name="companyaddress" placeholder="Enter the House Number, Street, Floor, etc part of your company's registered business address" size="100">
229 </select>
230 </td>
231 </tr>
232 <tr>
233 <td align="left" class="style1">Registered Business Address - City:</td>
234 <td class="style1">
235 <input type="text" id="companycity" name="companycity" placeholder="Enter the City part of your company's registered business address" size="100">
236 </select>
237 </td>
238 </tr>
239 <tr>
240 <td align="left" class="style1">Registered Business Address - Postal Code:</td>
241 <td class="style1">
242 <input type="text" id="companypostcode" name="companypostcode" placeholder="Enter the Postal Code part of your company's registered business address" size="100">
243 </select>
244 </td>
245 </tr>
246 <tr>
247 <td align="left" class="style1">Registered Business Address - Province or State:</td>
248 <td class="style1">
249 <input type="text" id="companyprovince" name="companyprovince" placeholder="Enter the Province or State part of your company's registered business address, leave empty if n/a" size="100">
250 </select>
251 </td>
252 </tr>
253 <tr>
254 <td align="left" class="style1">Registered Business Address - Country:</td>
255 <td class="style1">
256 <input type="text" id="companycountry" name="companycountry" placeholder="Enter the Country part of your company's registered business address" size="50">
257 </select>
258 </td>
259 </tr>
260 <th colspan = "2">
261 <b>Your Contact Information</b>
262 </th>
263 <tr>
264 <td align="left" class="style1">Title:</td>
265 <td class="style1">
266 <input type="text" id="title" name="title" placeholder="Enter your title (Ms, Mr, Dr, etc)" size="30">
267 </td>
268 </tr>
269 <tr>
270 <td align="left" class="style1">First name:</td>
271 <td class="style1">
272 <input type="text" id="firstname" name="firstname" placeholder="Enter your first name" size="50">
273 </td>
274 </tr>
275 <tr>
276 <td align="left" class="style1">Last name:</td>
277 <td class="style1">
278 <input type="text" id="lastname" name="lastname" placeholder="Enter your surname/family name" size="50">
279 </td>
280 </tr>
281 <tr>
282 <td align="left" class="style1">Preferred name to address you:</td>
283 <td class="style1">
284 <input type="text" id="prefname" name="prefname" placeholder="Enter the name you want to be addressed by" size="50">
285 </td>
286 </tr>
287 <tr>
288 <td align="left" class="style1">Your Role within the company:</td>
289 <td class="style1">
290 <input type="text" id="role" name="role" placeholder="Enter the Role you have within the company" size="70">
291 </td>
292 </tr>
293 <tr>
294 <td align="left" class="style1">Phone number (Landline):</td>
295 <td class="style1">
296 <input type="text" id="lphone" name="lphone" placeholder="Enter your landline phone number, with country code, without symbols" size="70">
297 </td>
298 </tr>
299 <tr>
300 <td align="left" class="style1">Phone number (Mobile):</td>
301 <td class="style1">
302 <input type="text" id="mphone" name="mphone" placeholder="Enter your mobile phone number, with country code, without symbols" size="70">
303 </td>
304 </tr>
305 <tr>
306 <td align="left" class="style1">E-Mail address (primary):</td>
307 <td class="style1">
308 <input type="email" id="email" name="email" placeholder="Enter your primary e-mail address, usually the company e-mail address" size="70">
309 </td>
310 </tr>
311 <tr>
312 <td align="left" class="style1">E-Mail address (secondary):</td>
313 <td class="style1">
314 <input type="email" id="email2" name="email2" placeholder="Enter a secondary e-mail address, in case the primary one becomes unavailable" size="80">
315 </td>
316 </tr>
317 <tr>
318 <td></td>
319 <td align="left" class="style1">
320 <input class="btn btn-primary" type="submit" name="butAction" value="Proceed">
321 </td>
322 </tr>
323 </table>
324 </form>
325 {{/html}}
326 #end
327 #if( $xcontext.strFormStatus == "DataCorrection" )
328 {{html wiki=false clean=false}}
329 <form action="" class="xformInline" method="post" name="User Registration Form">
330 <table id="table1"; cellspacing="5px" cellpadding="5%" border="1" width="100%"; align="left">
331 <col style="width:30%">
332 <col style="width:70%">
333 <tr>
334 <td align="left" class="style1">Company name:</td>
335 <td class="style1">
336 <input type="text" id="companyname" name="companyname" placeholder="Enter the legal name of your company" value="${xcontext.strCompanyName}" size="50">
337 </select>
338 </td>
339 </tr>
340 <tr>
341 <td align="left" class="style1">Title:</td>
342 <td class="style1">
343 <input type="text" id="title" name="title" placeholder="Enter your title" value="${xcontext.strTitle}" size="20">
344 </td>
345 </tr>
346 <tr>
347 <td align="left" class="style1">First name:</td>
348 <td class="style1">
349 <input type="text" id="firstname" name="firstname" placeholder="Enter your first name" value="${xcontext.strFirstname}" size="50">
350 </td>
351 </tr>
352 <tr>
353 <td align="left" class="style1">Last name:</td>
354 <td class="style1">
355 <input type="text" id="lastname" name="lastname" placeholder="Enter your surname/family name" value="${xcontext.strLastname}" size="50">
356 </td>
357 </tr>
358 <tr>
359 <td align="left" class="style1">Preferred name to address you:</td>
360 <td class="style1">
361 <input type="text" id="prefname" name="prefname" placeholder="Enter the name you want to be addressed by" value="${xcontext.strPrefname}" size="50">
362 </td>
363 </tr>
364 <tr>
365 <td align="left" class="style1">Phone number (Landline):</td>
366 <td class="style1">
367 <input type="text" id="lphone" name="lphone" placeholder="Enter your landline phone number, with country code, without symbols" value="${xcontext.strLphone}" size="70">
368 </td>
369 </tr>
370 <tr>
371 <td align="left" class="style1">Phone number (Mobile):</td>
372 <td class="style1">
373 <input type="text" id="mphone" name="mphone" placeholder="Enter your mobile phone number, with country code, without symbols" value="${xcontext.strMphone}" size="70">
374 </td>
375 </tr>
376 <tr>
377 <td align="left" class="style1">E-Mail address (primary):</td>
378 <td class="style1">
379 <input type="email" id="email" name="email" placeholder="Enter your primary e-mail address, usually the company e-mail address" value="${xcontext.strEmail}" size="70">
380 </td>
381 </tr>
382 <tr>
383 <td align="left" class="style1">E-Mail address (secondary):</td>
384 <td class="style1">
385 <input type="email" id="email2" name="email2" placeholder="Enter a secondary e-mail address, in case the primary one becomes unavailable" value="${xcontext.strEmail2}" size="70">
386 </td>
387 </tr>
388 <tr>
389 <td></td>
390 <td align="left" class="style1">
391 <input class="btn btn-primary" type="submit" name="butAction" value="Proceed">
392 </td>
393 </tr>
394 </table>
395 </form>
396 {{/html}}
397 #end
398
399 #if( $xcontext.strFormStatus == "DataVerify" )
400 You have entered the following information to register to the CEC Scheme:
401 {{html wiki=false clean=false}}
402 <form action="" class="xformInline" method="post" name="User Registration Form">
403 <table id="table1"; cellspacing="5px" cellpadding="5%" border="1" width="100%"; align="left">
404 <col style="width:30%">
405 <col style="width:70%">
406 <tr>
407 <td align="left" class="style1">Company name:</td>
408 <td class="style1">
409 <input type="hidden" id="companyname" name="companyname" readonly value="${xcontext.strCompanyName}" size="50">
410 ${xcontext.strCompanyName}
411 </td>
412 </tr>
413 <tr>
414 <td align="hidden" class="style1">Title:</td>
415 <td class="style1">
416 <input type="hidden" id="title" name="title" readonly value="${xcontext.strTitle}" size="10">
417 ${xcontext.strTitle}
418 </td>
419 </tr>
420 <tr>
421 <td align="hidden" class="style1">First name:</td>
422 <td class="style1">
423 <input type="hidden" id="firstname" name="firstname" readonly value="${xcontext.strFirstname}" size="50">
424 ${xcontext.strFirstname}
425 </td>
426 </tr>
427 <tr>
428 <td align="hidden" class="style1">Last name:</td>
429 <td class="style1">
430 <input type="hidden" id="lastname" name="lastname" readonly value="${xcontext.strLastname}" size="50">
431 ${xcontext.strLastname}
432 </td>
433 </tr>
434 <tr>
435 <td align="hidden" class="style1">Preferred name to address you:</td>
436 <td class="style1">
437 <input type="hidden" id="prefname" name="prefname" readonly value="${xcontext.strPrefname}" size="50">
438 ${xcontext.strPrefname}
439 </td>
440 </tr>
441 <tr>
442 <td align="left" class="style1">Phone number (Landline):</td>
443 <td class="style1">
444 <input type="hidden" id="lphone" name="lphone" readonly value="${xcontext.strLphone}" size="20">
445 ${xcontext.strLphone}
446 </td>
447 </tr>
448 <tr>
449 <td align="left" class="style1">Phone number (Mobile):</td>
450 <td class="style1">
451 <input type="hidden" id="mphone" name="mphone" readonly value="${xcontext.strMphone}" size="20">
452 ${xcontext.strMphone}
453 </td>
454 </tr>
455 <tr>
456 <td align="left" class="style1">E-Mail address (primary):</td>
457 <td class="style1">
458 <input type="hidden" id="email" name="email" readonly value="${xcontext.strEmail}" size="40">
459 ${xcontext.strEmail}
460 </td>
461 </tr>
462 <tr>
463 <td align="left" class="style1">E-Mail address (secondary):</td>
464 <td class="style1">
465 <input type="hidden" id="email2" name="email2" readonly value="${xcontext.strEmail2}" size="40">
466 ${xcontext.strEmail2}
467 </td>
468 </tr>
469 <tr>
470 <td>Click the button to the right to correct the above information</td>
471 <td align="left" class="style1">
472 <input class="btn btn-default" type="submit" name="butAction" value="Correct">
473 </td>
474 </tr>
475 </table>
476
477 <p>Please check the above information, and if correct, then read the terms and conditions below. If the above information is correct and you accept the terms and conditions, then please click the Register button at the bottom of this page.</p>
478 <p>If the information shown in the above table is incorrect, then please click the "Correct" button at the bottom of the above table to return to the editing page.</p>
479 <p><b>By clicking on the Register button, you agree to the following:</b>
480 <ul>
481 <li>The CEC Scheme, the CEC Website (cecocert.com), and the underlying computer systems are owned and operated by TruCert Assessment Services Inc. ("TruCert"), a company incorporated in Canada.</li>
482 <li>The information you enter into any form on the CEC Website may be stored and retained by TruCert and used for the purposes of the CEC Scheme.</li>
483 <li>Your IP address and time and date of you accessing the CEC Website may be stored and retained by TruCert and used for purposes of the CEC Scheme.</li>
484 <li>The primary computer systems used to store your information are located in Canada. TruCert may operate additional computer systems in the USA, the UK, or the EU that may store copies of your information.</li>
485 <li>By providing your contact information, you agree to TruCert contacting you, and communicating with you for the purposes of the CEC Scheme.</li>
486 <li>By providing your contact information, you agree to TruCert sharing your contact information and the fact that you intend in participating in the CEC Scheme to Mastercard International.</li>
487 <li>By providing your contact information, you agree to TruCert informing 3rd parties participating in the CEC Scheme of the fact that you are also participating in the CEC Scheme, for example by listing your contact information in a register of companies participating in the CEC Scheme.</li>
488 <li>TruCert will not sell, nor make available for free, your contact information for marketing or sales purposes of thirdy parties.</li>
489 <li>TruCert may change the terms and conditons of storing and sharing your contact information, but in such case will inform you of the modified terms and conditions by e-mail and will give you the option to have your contact information deleted before the modified terms and conditions come into force.</li>
490 </ul>
491 <p>After you click the below <b>Register</b> button, you should receive an automatically generated e-mail to the primary e-mail address you provide in the form above, containing a verification link. You must verify your e-mail address by clicking this verification link contained in the e-mail within 24 hours, otherwise your data may be deleted and you will have to restart the registration process.</p>
492
493 <input type="hidden" id="companyname" name="companyname" readonly value="${xcontext.strCompanyName}" size="50">
494 <input type="hidden" id="title" name="title" readonly value="${xcontext.strTitle}" size="10">
495 <input type="hidden" id="firstname" name="firstname" readonly value="${xcontext.strFirstname}" size="50">
496 <input type="hidden" id="lastname" name="lastname" readonly value="${xcontext.strLastname}" size="50">
497 <input type="hidden" id="prefname" name="prefname" readonly value="${xcontext.strPrefname}" size="50">
498 <input type="hidden" id="lphone" name="lphone" readonly value="${xcontext.strLphone}" size="20">
499 <input type="hidden" id="mphone" name="mphone" readonly value="${xcontext.strMphone}" size="20">
500 <input type="hidden" id="email" name="email" readonly value="${xcontext.strEmail}" size="40">
501 <input type="hidden" id="email2" name="email2" readonly value="${xcontext.strEmail2}" size="40">
502 <input class="btn btn-primary" type="submit" name="butAction" value="Register">
503 </form>
504 {{/html}}
505
506 #end
507 #if( $xcontext.strFormStatus == "SendEmail" )
508 #set($email_to = "${xcontext.strEmail}")
509 #set($email_subject = "CEC Registration - confirmation required to proceed")
510 #set($email_from = "cec_noreply@cecocert.com")
511 #set($email_text = "$xcontext.strEmailBody")
512 #set ($message = $services.mail.sender.createMessage($email_from, $email_to, $email_subject))
513 #set ($discard = $message.addPart("text/plain", ${xcontext.strEmailBody}))
514 #set ($mailResult = $services.mail.sender.send($message))
515 ## Check if the message was created properly and if we have permissions to send emails
516 #if ($services.mail.sender.lastError)
517 {{error}}$exceptiontool.getStackTrace($services.mail.sender.lastError){{/error}}
518 #end
519 ## Check if the mail we tried to send has failed to be sent
520 #set ($statuses = $mailResult.statusResult.getAllErrors())
521 #if ($statuses.hasNext())
522 #set ($status = $statuses.next())
523 {{error}}
524 Error: $status.errorSummary ($status.state)
525 $status.errorDescription
526 {{/error}}
527 #end
528 An e-mail asking you to confirm your e-mail address was sent to ${xcontext.strEmail}.
529 Please check your inbox and click on the link to confirm your e-mail address!
530 The process will only continue after you have confirmed your e-mail address.
531 #end
532
533 {{/velocity}}
534
© 2022 TruCert Assessment Services Inc.
V01-00