Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Certificates
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edselopez
Certificates
Commits
68cf3380
Commit
68cf3380
authored
2 weeks ago
by
Edselopez
Browse files
Options
Downloads
Plain Diff
Merge branch 'template_support' into 'main'
Changes from Edsel See merge request
!2
parents
9db3a5bc
5ff2b4e2
No related branches found
No related tags found
1 merge request
!2
Changes from Edsel
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Certificates/Form/Task.php
+10
-0
10 additions, 0 deletions
CRM/Certificates/Form/Task.php
certificates.php
+14
-3
14 additions, 3 deletions
certificates.php
with
24 additions
and
3 deletions
CRM/Certificates/Form/Task.php
+
10
−
0
View file @
68cf3380
...
...
@@ -36,8 +36,18 @@ class CRM_Certificates_Form_Task extends CRM_Contact_Form_Task {
$downloadPDF
=
new
PDFCertificate
();
$filename
=
$participant
[
'contact_id.display_name'
]
.
'_'
.
$participant
[
'event_id'
]
.
'_attendance_certificate_'
.
$participant
[
'event_id.title'
];
}
\Civi\Api4\Activity
::
create
(
FALSE
)
->
addValue
(
'source_record_id'
,
$context
[
'participantId'
])
->
addValue
(
'source_contact_id'
,
$context
[
'contactId'
])
->
addValue
(
'subject'
,
'Attendance Certificate Issued'
)
->
addValue
(
'activity_date_time'
,
date
(
'Y-m-d H:i:s'
))
->
addValue
(
'status_id'
,
2
)
->
addValue
(
'activity_type_id:name'
,
'Certificate Issued'
)
->
execute
();
$downloadPDF
->
download
(
$messageTemplateID
,
$context
,
$filename
);
}
}
This diff is collapsed.
Click to expand it.
certificates.php
+
14
−
3
View file @
68cf3380
...
...
@@ -78,16 +78,16 @@ function certificates_civicrm_permission(array &$permissions): void {
function
certificates_civicrm_pre
(
$op
,
$objectName
,
$id
,
&
$params
)
{
if
(
$op
==
'edit'
&&
$objectName
==
'Participant'
)
{
$contactID
=
$params
[
'contact_id'
];
try
{
$statusId
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Event_BAO_Participant'
,
'status_id'
,
'Attended'
);
//get current participant status before data is changed
$participant
=
\Civi\Api4\Participant
::
get
(
FALSE
)
->
addSelect
(
'status_id'
,
'id'
,
'event.Event_Certificate.event_certificate'
,
'event.id'
,
'event.title'
)
->
addSelect
(
'contact_id'
,
'status_id'
,
'id'
,
'event.Event_Certificate.event_certificate'
,
'event.id'
,
'event.title'
)
->
addJoin
(
'Event AS event'
,
'LEFT'
,
[
'event_id'
,
'='
,
'event.id'
])
->
addWhere
(
'
contact_
id'
,
'='
,
$
contactID
)
->
addWhere
(
'id'
,
'='
,
$
id
)
->
execute
()
->
first
();
$contactID
=
$participant
[
'contact_id'
];
// checks if participant status_id is now status id for Attended --> then send email
if
(
$participant
[
'status_id'
]
!==
$statusId
&&
$params
[
'status_id'
]
==
$statusId
)
{
...
...
@@ -219,7 +219,18 @@ function getEmailContent($participant) {
];
$certificateEmail
[
'attachments'
]
=
$mailAttachments
;
$act
=
\Civi\Api4\Activity
::
create
(
FALSE
)
->
addValue
(
'source_record_id'
,
$participant
[
'id'
])
->
addValue
(
'source_contact_id'
,
$participant
[
'contact_id'
])
->
addValue
(
'subject'
,
'Attendance Certificate Issued'
)
->
addValue
(
'activity_date_time'
,
date
(
'Y-m-d H:i:s'
))
->
addValue
(
'status_id'
,
2
)
->
addValue
(
'activity_type_id:name'
,
'Certificate Issued'
)
->
execute
();
CRM_Utils_Mail
::
send
(
$certificateEmail
);
}
catch
(
Exception
$e
)
{
echo
'Message: '
.
$e
->
getMessage
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment