entries-report.php
334 lines
| 1 | <?php |
| 2 | defined( 'ABSPATH' ) || exit; |
| 3 | |
| 4 | $site_name = isset( $footer['site_name'] ) ? $footer['site_name'] : get_bloginfo( 'name' ); |
| 5 | $frequency = get_option( 'everest_forms_entries_reporting_frequency', 'Weekly' ); |
| 6 | $show_total_forms = count( $entries_data ) > 1; |
| 7 | |
| 8 | if ( ! function_exists( 'evf_report_change_inline' ) ) : |
| 9 | function evf_report_change_inline( $change ) { |
| 10 | if ( is_null( $change ) ) { |
| 11 | return ''; |
| 12 | } |
| 13 | $base = 'font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;'; |
| 14 | if ( $change > 0 ) { |
| 15 | return '<span style="' . $base . 'color:#16a34a;">▲ +' . esc_html( $change ) . '%</span>'; |
| 16 | } |
| 17 | if ( $change < 0 ) { |
| 18 | return '<span style="' . $base . 'color:#dc2626;">▼ ' . esc_html( $change ) . '%</span>'; |
| 19 | } |
| 20 | return '<span style="' . $base . 'color:#9ca3af;">— 0%</span>'; |
| 21 | } |
| 22 | endif; |
| 23 | |
| 24 | if ( 'Daily' === $frequency ) { |
| 25 | $period_subtitle = __( 'Daily performance', 'everest-forms' ); |
| 26 | $vs_label = __( 'vs yesterday', 'everest-forms' ); |
| 27 | } elseif ( 'Monthly' === $frequency ) { |
| 28 | $period_subtitle = __( 'Monthly performance', 'everest-forms' ); |
| 29 | $vs_label = __( 'vs last month', 'everest-forms' ); |
| 30 | } else { |
| 31 | $period_subtitle = __( 'Weekly performance', 'everest-forms' ); |
| 32 | $vs_label = __( 'vs last week', 'everest-forms' ); |
| 33 | } |
| 34 | ?> |
| 35 | <!DOCTYPE html> |
| 36 | <html lang="<?php echo esc_attr( get_bloginfo( 'language' ) ); ?>"> |
| 37 | <head> |
| 38 | <meta charset="UTF-8"> |
| 39 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 40 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 41 | <title><?php echo esc_html( $period_label ); ?></title> |
| 42 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
| 43 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 44 | <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet"> |
| 45 | <style type="text/css"> |
| 46 | body,table,td,a{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%} |
| 47 | table,td{mso-table-lspace:0pt;mso-table-rspace:0pt} |
| 48 | img{-ms-interpolation-mode:bicubic;border:0;height:auto;line-height:100%;outline:none;text-decoration:none} |
| 49 | body{margin:0!important;padding:0!important;width:100%!important;background-color:#f9fafb;font-family:Inter,Arial,sans-serif} |
| 50 | @media screen and (max-width:600px){ |
| 51 | .stat-cards-table{width:100%!important} |
| 52 | .stat-card-wrapper{display:block!important;width:100%!important;padding-bottom:12px!important} |
| 53 | .stat-icon-cell{width:52px!important;max-width:52px!important;min-width:52px!important} |
| 54 | .spacer-col{display:none!important;width:0!important;max-width:0!important;overflow:hidden!important;font-size:0!important;line-height:0!important} |
| 55 | } |
| 56 | </style> |
| 57 | </head> |
| 58 | <body style="margin:0;padding:0;background-color:#f9fafb;font-family:Inter,Arial,sans-serif;"> |
| 59 | |
| 60 | <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#f9fafb;"> |
| 61 | <tr> |
| 62 | <td align="center" style="padding:40px 16px 56px;"> |
| 63 | |
| 64 | <table border="0" cellpadding="0" cellspacing="0" width="600" style="max-width:600px;width:100%;background-color:#ffffff;border-radius:16px;border:1px solid #e5e7eb;"> |
| 65 | <tr> |
| 66 | <td style="padding:32px 32px 28px;"> |
| 67 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 68 | |
| 69 | <?php if ( $is_test ) : ?> |
| 70 | <tr> |
| 71 | <td style="background-color:#fffbeb;border:1px solid #fcd34d;border-radius:8px;padding:10px 20px;text-align:center;"> |
| 72 | <p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:11px;font-weight:bold;color:#92400e;letter-spacing:0.06em;text-transform:uppercase;"> |
| 73 | <span style="display:inline-block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:9px solid #b45309;vertical-align:middle;margin-right:6px;line-height:0;font-size:0;"></span> |
| 74 | <?php esc_html_e( 'Test Send — live data, triggered manually', 'everest-forms' ); ?> |
| 75 | </p> |
| 76 | </td> |
| 77 | </tr> |
| 78 | <tr><td style="height:16px;font-size:0;line-height:0;"> </td></tr> |
| 79 | <?php endif; ?> |
| 80 | |
| 81 | <tr> |
| 82 | <td style="padding-bottom:6px;"> |
| 83 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 84 | <tr> |
| 85 | <td valign="middle" style="font-family:Inter,Arial,serif;font-size:24px;font-weight:bold;color:#111827;"> |
| 86 | <?php esc_html_e( 'Entries Summary Report', 'everest-forms' ); ?> |
| 87 | </td> |
| 88 | <td valign="middle" align="right" width="80" style="white-space:nowrap;"> |
| 89 | <span style="display:inline-block;background-color:#dcfce7;color:#15803d;font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;padding:4px 12px;border-radius:20px;border:1px solid #bbf7d0;"> |
| 90 | <?php echo esc_html( $frequency ); ?> |
| 91 | </span> |
| 92 | </td> |
| 93 | </tr> |
| 94 | </table> |
| 95 | </td> |
| 96 | </tr> |
| 97 | |
| 98 | <tr> |
| 99 | <td style="font-family:Inter,Arial,sans-serif;font-size:13px;color:#6b7280;padding-bottom:6px;"> |
| 100 | <?php echo esc_html( $period_subtitle ); ?> |
| 101 | </td> |
| 102 | </tr> |
| 103 | |
| 104 | <tr> |
| 105 | <td style="padding-bottom:20px;"> |
| 106 | <table border="0" cellpadding="0" cellspacing="0"> |
| 107 | <tr> |
| 108 | <td valign="middle" width="18" style="padding-right:6px;"> |
| 109 | <!-- |
| 110 | Calendar icon: pure HTML table boxes — outer border = calendar frame, |
| 111 | top strip = header bar, inner cells = date grid. No SVG, no images. |
| 112 | --> |
| 113 | <table border="0" cellpadding="0" cellspacing="0" width="13" style="width:13px;border-collapse:collapse;"> |
| 114 | <!-- Calendar header (dark bar) --> |
| 115 | <tr> |
| 116 | <td colspan="3" style="height:4px;background-color:#6b7280;border-radius:2px 2px 0 0;font-size:0;line-height:0;"> </td> |
| 117 | </tr> |
| 118 | <!-- Two hook lines on top of calendar --> |
| 119 | <tr> |
| 120 | <td width="4" style="width:4px;height:3px;border-left:1.5px solid #6b7280;font-size:0;line-height:0;"> </td> |
| 121 | <td style="font-size:0;line-height:0;"> </td> |
| 122 | <td width="4" style="width:4px;height:3px;border-right:1.5px solid #6b7280;font-size:0;line-height:0;"> </td> |
| 123 | </tr> |
| 124 | <!-- Calendar body --> |
| 125 | <tr> |
| 126 | <td colspan="3" style="height:6px;border:1.5px solid #6b7280;border-top:none;border-radius:0 0 2px 2px;font-size:0;line-height:0;"> </td> |
| 127 | </tr> |
| 128 | </table> |
| 129 | </td> |
| 130 | <td valign="middle" style="font-family:Inter,Arial,sans-serif;font-size:12px;color:#6b7280;"> |
| 131 | <?php echo esc_html( html_entity_decode( $period_label, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); ?> |
| 132 | </td> |
| 133 | </tr> |
| 134 | </table> |
| 135 | </td> |
| 136 | </tr> |
| 137 | |
| 138 | <tr><td style="height:1px;background-color:#f3f4f6;font-size:0;line-height:0;padding:0;"> </td></tr> |
| 139 | <tr><td style="height:20px;font-size:0;line-height:0;"> </td></tr> |
| 140 | |
| 141 | <tr> |
| 142 | <td> |
| 143 | <table class="stat-cards-table" border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 144 | <tr> |
| 145 | |
| 146 | <?php if ( $show_total_forms ) : ?> |
| 147 | <td class="stat-card-wrapper" valign="top" width="48%" style="vertical-align:top;padding-bottom:0;"> |
| 148 | <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #e5e7eb;border-radius:12px;"> |
| 149 | <tr> |
| 150 | <td style="padding:16px;"> |
| 151 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 152 | <tr> |
| 153 | <td class="stat-icon-cell" valign="middle" width="52" style="width:52px;max-width:52px;min-width:52px;padding-right:12px;"> |
| 154 | <table border="0" cellpadding="0" cellspacing="0" width="40" height="40" style="width:40px;min-width:40px;height:40px;"> |
| 155 | <tr> |
| 156 | <td width="40" height="40" align="center" valign="middle" style="background-color:#f3f0ff;border-radius:10px;width:40px;height:40px;min-width:40px;"> |
| 157 | |
| 158 | <table border="0" cellpadding="0" cellspacing="0" style="margin:auto;border-collapse:collapse;"> |
| 159 | <tr> |
| 160 | <td style="width:14px;padding:3px 2px;border:1.5px solid #7c3aed;border-radius:3px;"> |
| 161 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 162 | <tr><td style="height:2px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td></tr> |
| 163 | <tr><td style="height:2px;font-size:0;"> </td></tr> |
| 164 | <tr><td style="height:2px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td></tr> |
| 165 | <tr><td style="height:2px;font-size:0;"> </td></tr> |
| 166 | <tr><td width="7" style="width:7px;height:2px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td></tr> |
| 167 | </table> |
| 168 | </td> |
| 169 | </tr> |
| 170 | </table> |
| 171 | </td> |
| 172 | </tr> |
| 173 | </table> |
| 174 | </td> |
| 175 | <td valign="middle"> |
| 176 | <p style="margin:0 0 4px;font-family:Inter,Arial,sans-serif;font-size:12px;color:#6b7280;"><?php esc_html_e( 'Total Forms', 'everest-forms' ); ?></p> |
| 177 | <p style="margin:0;font-family:Inter,Arial,sans-serif;font-size:26px;font-weight:bold;color:#111827;line-height:1;"><?php echo esc_html( $summary['total_forms'] ); ?></p> |
| 178 | </td> |
| 179 | </tr> |
| 180 | </table> |
| 181 | </td> |
| 182 | </tr> |
| 183 | </table> |
| 184 | </td> |
| 185 | |
| 186 | <td class="spacer-col" width="4%" style="font-size:0;line-height:0;"> </td> |
| 187 | <?php endif; ?> |
| 188 | |
| 189 | <td class="stat-card-wrapper" valign="top" width="<?php echo $show_total_forms ? '48%' : '100%'; ?>" style="vertical-align:top;padding-bottom:0;"> |
| 190 | <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #e5e7eb;border-radius:12px;"> |
| 191 | <tr> |
| 192 | <td style="padding:16px;"> |
| 193 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 194 | <tr> |
| 195 | <td class="stat-icon-cell" valign="middle" width="52" style="width:52px;max-width:52px;min-width:52px;padding-right:12px;"> |
| 196 | <table border="0" cellpadding="0" cellspacing="0" width="40" height="40" style="width:40px;min-width:40px;height:40px;"> |
| 197 | <tr> |
| 198 | <td width="40" height="40" align="center" valign="middle" style="background-color:#f3f0ff;border-radius:10px;width:40px;height:40px;min-width:40px;"> |
| 199 | |
| 200 | <table border="0" cellpadding="2" cellspacing="2" style="margin:auto;border-collapse:separate;border-spacing:2px;"> |
| 201 | <tr> |
| 202 | <td style="width:6px;height:6px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td> |
| 203 | <td style="width:6px;height:6px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td> |
| 204 | </tr> |
| 205 | <tr> |
| 206 | <td style="width:6px;height:6px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td> |
| 207 | <td style="width:6px;height:6px;background-color:#7c3aed;border-radius:1px;font-size:0;line-height:0;"> </td> |
| 208 | </tr> |
| 209 | </table> |
| 210 | </td> |
| 211 | </tr> |
| 212 | </table> |
| 213 | </td> |
| 214 | <td valign="middle"> |
| 215 | <p style="margin:0 0 4px;font-family:Inter,Arial,sans-serif;font-size:12px;color:#6b7280;"><?php esc_html_e( 'Total Entries', 'everest-forms' ); ?></p> |
| 216 | <table border="0" cellpadding="0" cellspacing="0"> |
| 217 | <tr> |
| 218 | <td valign="baseline" style="font-family:Inter,Arial,sans-serif;font-size:26px;font-weight:bold;color:#111827;line-height:1;padding-right:8px;"> |
| 219 | <?php echo esc_html( number_format( $summary['total_entries'] ) ); ?> |
| 220 | </td> |
| 221 | <?php if ( ! is_null( $summary['overall_change'] ) ) : ?> |
| 222 | <td valign="middle" style="padding-right:4px;white-space:nowrap;"> |
| 223 | <?php echo evf_report_change_inline( $summary['overall_change'] ); ?> |
| 224 | </td> |
| 225 | <td valign="middle" style="font-family:Inter,Arial,sans-serif;font-size:12px;color:#9ca3af;padding-right:8px;white-space:nowrap;"> |
| 226 | <?php echo esc_html( $vs_label ); ?> |
| 227 | </td> |
| 228 | <?php endif; ?> |
| 229 | <?php if ( array_key_exists( 'prev_overall_change', $summary ) && ! is_null( $summary['prev_overall_change'] ) ) : ?> |
| 230 | <td valign="middle" style="padding-right:4px;white-space:nowrap;"> |
| 231 | <?php echo evf_report_change_inline( $summary['prev_overall_change'] ); ?> |
| 232 | </td> |
| 233 | <td valign="middle" style="font-family:Inter,Arial,sans-serif;font-size:12px;color:#9ca3af;white-space:nowrap;"> |
| 234 | <?php esc_html_e( 'vs 2 periods ago', 'everest-forms' ); ?> |
| 235 | </td> |
| 236 | <?php endif; ?> |
| 237 | </tr> |
| 238 | </table> |
| 239 | </td> |
| 240 | </tr> |
| 241 | </table> |
| 242 | </td> |
| 243 | </tr> |
| 244 | </table> |
| 245 | </td> |
| 246 | |
| 247 | </tr> |
| 248 | </table> |
| 249 | </td> |
| 250 | </tr> |
| 251 | |
| 252 | <tr><td style="height:28px;font-size:0;line-height:0;"> </td></tr> |
| 253 | |
| 254 | <tr> |
| 255 | <td style="font-family:Inter,Arial,sans-serif;font-size:17px;font-weight:bold;color:#111827;padding-bottom:12px;"> |
| 256 | <?php esc_html_e( 'Form Entries', 'everest-forms' ); ?> |
| 257 | </td> |
| 258 | </tr> |
| 259 | |
| 260 | <tr> |
| 261 | <td> |
| 262 | <?php if ( empty( $entries_data ) ) : ?> |
| 263 | <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #e5e7eb;border-radius:12px;border-collapse:separate;border-spacing:0;"> |
| 264 | <tr> |
| 265 | <td align="center" style="padding:36px 20px;font-family:Inter,Arial,sans-serif;font-size:13px;color:#9ca3af;font-style:italic;"> |
| 266 | <?php esc_html_e( 'No forms selected for this report.', 'everest-forms' ); ?> |
| 267 | </td> |
| 268 | </tr> |
| 269 | </table> |
| 270 | <?php else : ?> |
| 271 | <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #e5e7eb;border-radius:12px;border-collapse:separate;border-spacing:0;"> |
| 272 | <tr style="background-color:#f9fafb;"> |
| 273 | <td style="padding:11px 18px;font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;color:#374151;border-bottom:1px solid #e5e7eb;border-radius:12px 0 0 0;width:55%;"><?php esc_html_e( 'Form name', 'everest-forms' ); ?></td> |
| 274 | <td style="padding:11px 18px;font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;color:#374151;border-bottom:1px solid #e5e7eb;width:25%;"><?php esc_html_e( 'Entries', 'everest-forms' ); ?></td> |
| 275 | <td align="right" style="padding:11px 18px;font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;color:#374151;border-bottom:1px solid #e5e7eb;border-radius:0 12px 0 0;width:20%;"><?php esc_html_e( 'Actions', 'everest-forms' ); ?></td> |
| 276 | </tr> |
| 277 | <?php |
| 278 | $row_count = count( $entries_data ); |
| 279 | $row_i = 0; |
| 280 | foreach ( $entries_data as $form ) : |
| 281 | ++$row_i; |
| 282 | $is_last = ( $row_i === $row_count ); |
| 283 | $row_border = $is_last ? '' : 'border-bottom:1px solid #f3f4f6;'; |
| 284 | $radius_left = $is_last ? 'border-radius:0 0 0 12px;' : ''; |
| 285 | $radius_right = $is_last ? 'border-radius:0 0 12px 0;' : ''; |
| 286 | ?> |
| 287 | <tr> |
| 288 | <td style="padding:13px 18px;font-family:Inter,Arial,sans-serif;font-size:13px;color:#111827;<?php echo $row_border . $radius_left; ?>"><?php echo esc_html( $form['form_name'] ); ?></td> |
| 289 | <td style="padding:13px 18px;font-family:Inter,Arial,sans-serif;font-size:13px;color:#111827;<?php echo $row_border; ?>"><?php echo esc_html( number_format( $form['current'] ) ); ?></td> |
| 290 | <td align="right" style="padding:13px 18px;<?php echo $row_border . $radius_right; ?>"> |
| 291 | <a href="<?php echo esc_url( $form['view_url'] ); ?>" style="font-family:Inter,Arial,sans-serif;font-size:12px;font-weight:bold;color:#7c3aed;text-decoration:none;"><?php esc_html_e( 'View', 'everest-forms' ); ?></a> |
| 292 | </td> |
| 293 | </tr> |
| 294 | <?php endforeach; ?> |
| 295 | </table> |
| 296 | <?php endif; ?> |
| 297 | </td> |
| 298 | </tr> |
| 299 | |
| 300 | <tr><td style="height:32px;font-size:0;line-height:0;"> </td></tr> |
| 301 | <tr><td style="height:1px;background-color:#f3f4f6;font-size:0;line-height:0;padding:0;"> </td></tr> |
| 302 | <tr><td style="height:24px;font-size:0;line-height:0;"> </td></tr> |
| 303 | |
| 304 | <tr> |
| 305 | <td align="center" style="padding-bottom:16px;"> |
| 306 | <table border="0" cellpadding="0" cellspacing="0"> |
| 307 | <tr> |
| 308 | <td align="center" style="background-color:#7c3aed;border-radius:8px;"> |
| 309 | <a href="<?php echo esc_url( $footer['entries_url'] ); ?>" target="_blank" style="display:inline-block;background-color:#7c3aed;color:#ffffff;text-decoration:none;font-family:Inter,Arial,sans-serif;font-size:14px;font-weight:bold;padding:12px 36px;border-radius:8px;mso-padding-alt:12px 36px;border:1px solid #7c3aed;"> |
| 310 | <?php esc_html_e( 'View all entries', 'everest-forms' ); ?> |
| 311 | </a> |
| 312 | </td> |
| 313 | </tr> |
| 314 | </table> |
| 315 | </td> |
| 316 | </tr> |
| 317 | |
| 318 | <tr> |
| 319 | <td align="center" style="font-family:Inter,Arial,sans-serif;font-size:12px;color:#9ca3af;"> |
| 320 | <?php printf( esc_html__( 'This email has been generated by %s', 'everest-forms' ), esc_html( $site_name ) ); ?> |
| 321 | </td> |
| 322 | </tr> |
| 323 | |
| 324 | </table> |
| 325 | </td> |
| 326 | </tr> |
| 327 | </table> |
| 328 | |
| 329 | </td> |
| 330 | </tr> |
| 331 | </table> |
| 332 | </body> |
| 333 | </html> |
| 334 |