This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/admin/email_users.cfm
John Mizerek 1210249f54 Normalize database column and table names across entire codebase
Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).

Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
  Addresses, Hours, Menus, Categories, Items, Stations, Orders,
  OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
  ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
  VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
  tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
  dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
  Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
  UserIsActive→IsActive, UserBalance→Balance, etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:39:12 -08:00

138 lines
No EOL
3.8 KiB
Text

<cfif session.UserID NEQ 0>
<cfif form.mode eq "start">
<h3>Send an email!</h3>
<cfparam name="users_to_email" default="">
<cfquery name="select_users_to_email" datasource="#application.datasource#">
SELECT U.EmailAddress
FROM Users U
WHERE UserID in (0,1,2)
</cfquery>
<cfoutput query="select_users_to_email">
#EmailAddress#,
<cfset users_to_email=listappend(users_to_email, #EmailAddress#)>
</cfoutput><br><br>
<script language="JavaScript">
function submitforminputemail()
{
document.myforminputemail.submit();
}
</script>
<cfoutput><form action="#request.cgipath#" method="post" name="myforminputemail" id="myforminputemail" style="display:inline;">
Email subject:<br><input type="text" name="email_subject" size="30" maxlength="50"><br><br>
Email Body:<br>
<textarea name="email_body" rows="4" cols="30" placeholder="type email body here"></textarea><br><br>
<a href="javascript: submitforminputemail()">Submit</a><br>
<input type="hidden" name="mode" value="confirm_email_contents">
<input type="hidden" name="users_to_email" value="#users_to_email#">
</form></cfoutput>
<cfelseif form.mode eq "confirm_email_contents">
does this look correct?<br><br>
Subject:<br><cfoutput>#form.email_subject#</cfoutput><br><br>
Body:<br><cfoutput>#HTMLCodeFormat(form.email_body)#</cfoutput>
<script language="JavaScript">
function submitformsendtest()
{
document.myformsendtest.submit();
}
</script>
<cfoutput><form action="#request.cgipath#" method="post" name="myformsendtest" id="myformsendtest" style="display:inline;">
<a href="javascript: submitformsendtest()">Yes, send the test email!</a><br>
<input type="hidden" name="mode" value="send_test_email">
<input type="hidden" name="email_subject" value="#form.email_subject#">
<input type="hidden" name="email_body" value="#form.email_body#">
<input type="hidden" name="users_to_email" value="#users_to_email#">
</form></cfoutput>
<cfelseif form.mode eq "send_test_email">
<cfmail to="admin@payfrit.com" from="admin@payfrit.com" subject="#form.email_subject#" type="HTML">#HTMLCodeFormat(form.email_body)#</cfmail>
<script language="JavaScript">
function submitformsendtest()
{
document.myformsendtest.submit();
}
</script>
<cfoutput><form action="#request.cgipath#" method="post" name="myformsendtest" id="myformsendtest" style="display:inline;">
<a href="javascript: submitformsendtest()">Looks good, send the real email!</a><br>
<input type="hidden" name="mode" value="send_email">
<input type="hidden" name="email_subject" value="#form.email_subject#">
<input type="hidden" name="email_body" value="#form.email_body#">
<input type="hidden" name="users_to_email" value="#users_to_email#">
</form></cfoutput>
<cfelseif form.mode eq "send_email">
<cfloop index="the_email_address" list="#users_to_email#">
<cfquery name="get_user_email" datasource="#application.datasource#">
SELECT UUID
FROM Users
WHERE EmailAddress = '#the_email_address#'
AND
UserIsEmailverified = 1
AND
IsContactVerified > 0
</cfquery>
<cfset form.this_email_body = form.email_body & "
instant unsubscribe link: https://www.payfrit.com/remove_me.cfm?UUID="&#get_user_email.UUID#>
<cfmail to="#the_email_address#" from="admin@payfrit.com" subject="#form.email_subject#" type="HTML">
#HTMLCodeFormat(form.this_email_body)#</cfmail>
</cfloop>
<cfquery name="insert_email" datasource="#application.datasource#">
INSERT INTO MarketingEmails
(
MarketingEmailSubject,
MarketingEmailBody,
MarketingEmailUsersEmailed
)
VALUES (
'#form.email_subject#',
'#form.email_body#',
'#users_to_email#'
)
</cfquery>
Email sent!<br>
</cfif>
<cfelse>
Please Login!
</cfif>