| |
| <?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| if (!defined('ABSPATH')) {
|
| exit;
|
| }
|
|
|
|
|
| add_action('acf/init', 'mst_add_contact_staging_fields_to_tab8', 13);
|
|
|
| function mst_add_contact_staging_fields_to_tab8() {
|
|
|
|
|
| if (!function_exists('acf_get_field_group')) {
|
| return;
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_contact_staging_section',
|
| 'label' => 'Weekly Contact Staging (Auto-Populated)',
|
| 'name' => '',
|
| 'type' => 'message',
|
| 'parent' => 'group_mst_case_master',
|
| 'message' => '<div style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 12px; margin: 10px 0;">
|
| <strong>⚠️ TEMPORARY STAGING FIELDS</strong><br>
|
| These fields are automatically populated every Friday at 3 PM from Form 301 contact logs.<br>
|
| They are <strong>overwritten weekly</strong> and used to pre-populate Form 302 Section VIII.<br>
|
| <strong>Permanent records are stored in weekly_case_summary posts.</strong>
|
| </div>',
|
| 'new_lines' => '',
|
| 'esc_html' => 0,
|
| 'wrapper' => array(
|
| 'width' => '100',
|
| ),
|
| ));
|
|
|
|
|
|
|
|
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_contact_logs_summary',
|
| 'label' => 'Contact Logs Summary (This Week)',
|
| 'name' => 'contact_logs_summary',
|
| 'type' => 'textarea',
|
| 'parent' => 'group_mst_case_master',
|
| 'instructions' => 'Formatted summary of all Form 301 contact logs for the current week. Auto-populated by Gravity Flow aggregation workflow (Friday 3 PM). This field is REPLACED each week.',
|
| 'required' => 0,
|
| 'conditional_logic' => 0,
|
| 'wrapper' => array(
|
| 'width' => '100',
|
| 'class' => 'contact-staging-field',
|
| 'id' => '',
|
| ),
|
| 'default_value' => '',
|
| 'placeholder' => 'No contact logs aggregated yet for this week...',
|
| 'maxlength' => '',
|
| 'rows' => 15,
|
| 'new_lines' => 'wpautop',
|
| 'readonly' => 1,
|
| ));
|
|
|
|
|
|
|
|
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_contact_hours_this_week',
|
| 'label' => 'Total Contact Hours (This Week)',
|
| 'name' => 'contact_hours_this_week',
|
| 'type' => 'number',
|
| 'parent' => 'group_mst_case_master',
|
| 'instructions' => 'Total contact hours from Form 301 entries this week. Auto-calculated by Gravity Flow.',
|
| 'required' => 0,
|
| 'conditional_logic' => 0,
|
| 'wrapper' => array(
|
| 'width' => '25',
|
| 'class' => 'contact-staging-field',
|
| 'id' => '',
|
| ),
|
| 'default_value' => 0,
|
| 'placeholder' => '0.0',
|
| 'min' => 0,
|
| 'max' => '',
|
| 'step' => 0.1,
|
| 'readonly' => 1,
|
| 'append' => 'hrs',
|
| ));
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_contact_count_this_week',
|
| 'label' => 'Contact Count (This Week)',
|
| 'name' => 'contact_count_this_week',
|
| 'type' => 'number',
|
| 'parent' => 'group_mst_case_master',
|
| 'instructions' => 'Number of Form 301 contact logs submitted this week. Auto-counted by Gravity Flow.',
|
| 'required' => 0,
|
| 'conditional_logic' => 0,
|
| 'wrapper' => array(
|
| 'width' => '25',
|
| 'class' => 'contact-staging-field',
|
| 'id' => '',
|
| ),
|
| 'default_value' => 0,
|
| 'placeholder' => '0',
|
| 'min' => 0,
|
| 'max' => '',
|
| 'step' => 1,
|
| 'readonly' => 1,
|
| 'append' => 'contacts',
|
| ));
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_face_to_face_hours_this_week',
|
| 'label' => 'Face-to-Face Hours (This Week)',
|
| 'name' => 'face_to_face_hours_this_week',
|
| 'type' => 'number',
|
| 'parent' => 'group_mst_case_master',
|
| 'instructions' => 'Face-to-face contact hours only. Filtered from Form 301 contact type field.',
|
| 'required' => 0,
|
| 'conditional_logic' => 0,
|
| 'wrapper' => array(
|
| 'width' => '25',
|
| 'class' => 'contact-staging-field',
|
| 'id' => '',
|
| ),
|
| 'default_value' => 0,
|
| 'placeholder' => '0.0',
|
| 'min' => 0,
|
| 'max' => '',
|
| 'step' => 0.1,
|
| 'readonly' => 1,
|
| 'append' => 'hrs',
|
| ));
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_phone_hours_this_week',
|
| 'label' => 'Phone/Virtual Hours (This Week)',
|
| 'name' => 'phone_hours_this_week',
|
| 'type' => 'number',
|
| 'parent' => 'group_mst_case_master',
|
| 'instructions' => 'Phone and virtual contact hours. Filtered from Form 301 contact type field.',
|
| 'required' => 0,
|
| 'conditional_logic' => 0,
|
| 'wrapper' => array(
|
| 'width' => '25',
|
| 'class' => 'contact-staging-field',
|
| 'id' => '',
|
| ),
|
| 'default_value' => 0,
|
| 'placeholder' => '0.0',
|
| 'min' => 0,
|
| 'max' => '',
|
| 'step' => 0.1,
|
| 'readonly' => 1,
|
| 'append' => 'hrs',
|
| ));
|
|
|
|
|
|
|
|
|
|
|
| acf_add_local_field(array(
|
| 'key' => 'field_contact_staging_help',
|
| 'label' => '',
|
| 'name' => '',
|
| 'type' => 'message',
|
| 'parent' => 'group_mst_case_master',
|
| 'message' => '<div style="background: #e7f3ff; border-left: 4px solid #2271b1; padding: 12px; margin: 10px 0;">
|
| <strong>📊 How This Works:</strong><br>
|
| <ol style="margin: 10px 0 0 20px;">
|
| <li><strong>Mon-Thu:</strong> Therapist submits Form 301 contact logs (stored as Gravity Forms entries)</li>
|
| <li><strong>Friday 3 PM:</strong> Gravity Flow aggregates all Form 301 entries for this week → Updates these fields</li>
|
| <li><strong>Friday PM:</strong> These fields pre-populate Form 302 Section VIII (Contact Summary)</li>
|
| <li><strong>After Form 302 submission:</strong> Data saved permanently to weekly_case_summary post</li>
|
| <li><strong>Next Monday:</strong> These fields are cleared and process repeats for new week</li>
|
| </ol>
|
| <p style="margin: 10px 0 0 0;"><em>💡 To view complete contact history, see the Contact Logs GravityView or individual Form 301 entries.</em></p>
|
| </div>',
|
| 'new_lines' => '',
|
| 'esc_html' => 0,
|
| 'wrapper' => array(
|
| 'width' => '100',
|
| ),
|
| ));
|
| }
|
|
|
|
|
|
|
|
|
|
|
| add_action('acf/input/admin_head', 'mst_contact_staging_fields_css');
|
|
|
| function mst_contact_staging_fields_css() {
|
| global $post_type;
|
|
|
| if ($post_type !== 'mst_case') {
|
| return;
|
| }
|
| ?>
|
| <style>
|
|
|
| .contact-staging-field .acf-input-wrap {
|
| background-color:
|
| border: 1px solid
|
| }
|
|
|
| .contact-staging-field .acf-input input[readonly],
|
| .contact-staging-field .acf-input textarea[readonly] {
|
| background-color:
|
| cursor: not-allowed;
|
| font-family: 'Monaco', 'Courier New', monospace;
|
| }
|
|
|
| .contact-staging-field .acf-label label {
|
| font-weight: 600;
|
| color:
|
| }
|
|
|
|
|
| .acf-field[data-name="contact_logs_summary"] {
|
| background:
|
| padding: 15px;
|
| border-radius: 4px;
|
| margin: 15px 0;
|
| }
|
|
|
|
|
| .contact-staging-field textarea[readonly] {
|
| font-size: 13px;
|
| line-height: 1.6;
|
| color:
|
| }
|
| </style>
|
| <?php
|
| }
|
| |
| |
Comments