public function get_settings()
 {
     $account_choices = gravity_flow()->get_users_as_choices();
     $type_field_choices = array(array('label' => __('Select', 'gravityflow'), 'value' => 'select'), array('label' => __('Conditional Routing', 'gravityflow'), 'value' => 'routing'));
     $assignee_notification_fields = array(array('name' => 'assignee_notification_enabled', 'label' => '', 'type' => 'checkbox', 'choices' => array(array('label' => __('Send Email to the assignee(s).', 'gravityflow'), 'tooltip' => __('Enable this setting to send email to each of the assignees as soon as the entry has been assigned. If a role is configured to receive emails then all the users with that role will receive the email.', 'gravityflow'), 'name' => 'assignee_notification_enabled', 'default_value' => false))), array('name' => 'assignee_notification_from_name', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('From Name', 'gravityflow'), 'type' => 'text'), array('name' => 'assignee_notification_from_email', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('From Email', 'gravityflow'), 'type' => 'text', 'default_value' => '{admin_email}'), array('name' => 'assignee_notification_reply_to', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Reply To', 'gravityflow'), 'type' => 'text'), array('name' => 'assignee_notification_bcc', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('BCC', 'gravityflow'), 'type' => 'text'), array('name' => 'assignee_notification_subject', 'class' => 'large fieldwidth-1 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Subject', 'gravityflow'), 'type' => 'text'), array('name' => 'assignee_notification_message', 'label' => __('Message to Assignee(s)', 'gravityflow'), 'type' => 'visual_editor', 'default_value' => __('A new entry is pending your approval. Please check your Workflow Inbox.', 'gravityflow')), array('name' => 'resend_assignee_email', 'label' => '', 'type' => 'checkbox_and_text', 'checkbox' => array('label' => __('Send reminder', 'gravityflow')), 'text' => array('default_value' => 7, 'before_input' => __('Resend the assignee email after', 'gravityflow'), 'after_input' => ' ' . __('day(s)', 'gravityflow'))));
     $rejection_notification_fields = array(array('name' => 'rejection_notification_enabled', 'label' => '', 'type' => 'checkbox', 'choices' => array(array('label' => __('Send email when the entry is rejected', 'gravityflow'), 'tooltip' => __('Enable this setting to send an email when the entry is rejected.', 'gravityflow'), 'name' => 'rejection_notification_enabled', 'default_value' => false))), array('name' => 'rejection_notification_type', 'label' => __('Send To', 'gravityflow'), 'type' => 'radio', 'default_value' => 'select', 'horizontal' => true, 'choices' => $type_field_choices), array('id' => 'rejection_notification_users', 'name' => 'rejection_notification_users[]', 'label' => __('Select User', 'gravityflow'), 'size' => '8', 'multiple' => 'multiple', 'type' => 'select', 'choices' => $account_choices), array('name' => 'rejection_notification_routing', 'label' => __('Routing', 'gravityflow'), 'type' => 'user_routing'), array('name' => 'rejection_notification_from_name', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('From Name', 'gravityflow'), 'type' => 'text'), array('name' => 'rejection_notification_from_email', 'label' => __('From Email', 'gravityflow'), 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'type' => 'text', 'default_value' => '{admin_email}'), array('name' => 'rejection_notification_reply_to', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Reply To', 'gravityflow'), 'type' => 'text'), array('name' => 'rejection_notification_bcc', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('BCC', 'gravityflow'), 'type' => 'text'), array('name' => 'rejection_notification_subject', 'class' => 'fieldwidth-1 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Subject', 'gravityflow'), 'type' => 'text'), array('name' => 'rejection_notification_message', 'label' => __('Message', 'gravityflow'), 'type' => 'visual_editor', 'default_value' => __('Entry {entry_id} has been rejected', 'gravityflow')));
     $approval_notification_fields = array(array('name' => 'approval_notification_enabled', 'label' => '', 'type' => 'checkbox', 'choices' => array(array('label' => __('Send email when the entry is approved', 'gravityflow'), 'tooltip' => __('Enable this setting to send an email when the entry is approved.', 'gravityflow'), 'name' => 'approval_notification_enabled', 'default_value' => false))), array('name' => 'approval_notification_type', 'label' => __('Send To', 'gravityflow'), 'type' => 'radio', 'default_value' => 'select', 'horizontal' => true, 'choices' => $type_field_choices), array('id' => 'approval_notification_users', 'name' => 'approval_notification_users[]', 'label' => __('Select', 'gravityflow'), 'size' => '8', 'multiple' => 'multiple', 'type' => 'select', 'choices' => $account_choices), array('name' => 'approval_notification_routing', 'label' => __('Routing', 'gravityflow'), 'class' => 'large', 'type' => 'user_routing'), array('name' => 'approval_notification_from_name', 'label' => __('From Name', 'gravityflow'), 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'type' => 'text'), array('name' => 'approval_notification_from_email', 'label' => __('From Email', 'gravityflow'), 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'type' => 'text', 'default_value' => '{admin_email}'), array('name' => 'approval_notification_reply_to', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Reply To', 'gravityflow'), 'type' => 'text'), array('name' => 'approval_notification_bcc', 'class' => 'fieldwidth-2 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('BCC', 'gravityflow'), 'type' => 'text'), array('name' => 'approval_notification_subject', 'class' => 'fieldwidth-1 merge-tag-support mt-hide_all_fields mt-position-right ui-autocomplete-input', 'label' => __('Subject', 'gravityflow'), 'type' => 'text'), array('name' => 'approval_notification_message', 'label' => __('Approval Message', 'gravityflow'), 'type' => 'visual_editor', 'default_value' => __('Entry {entry_id} has been approved', 'gravityflow')));
     // Support for Gravity PDF 4
     if (defined('PDF_EXTENDED_VERSION') && version_compare(PDF_EXTENDED_VERSION, '4.0-beta2', '>=')) {
         $form_id = $this->get_form_id();
         $gpdf_feeds = GPDFAPI::get_form_pdfs($form_id);
         if (is_array($gpdf_feeds)) {
             $gpdf_choices = array();
             foreach ($gpdf_feeds as $gpdf_feed) {
                 $gpdf_choices[] = array('label' => $gpdf_feed['name'], 'value' => $gpdf_feed['id']);
             }
             $pdf_setting = array('name' => 'assignee_notification_gpdf', 'label' => '', 'type' => 'checkbox_and_select', 'checkbox' => array('label' => esc_html__('Attach PDF', 'gravityflow')), 'select' => array('choices' => $gpdf_choices));
             $assignee_notification_fields[] = $pdf_setting;
             $pdf_setting['name'] = 'rejection_notification_gpdf';
             $rejection_notification_fields[] = $pdf_setting;
             $pdf_setting['name'] = 'approval_notification_gpdf';
             $approval_notification_fields[] = $pdf_setting;
         }
     }
     $settings = array('title' => esc_html__('Approval', 'gravityflow'), 'fields' => array(array('name' => 'type', 'label' => __('Assign To:', 'gravityflow'), 'type' => 'radio', 'default_value' => 'select', 'horizontal' => true, 'choices' => $type_field_choices), array('id' => 'assignees', 'name' => 'assignees[]', 'tooltip' => __('Users and roles fields will appear in this list. If the form contains any assignee fields they will also appear here. Click on an item to select it. The selected items will appear on the right. If you select a role then anybody from that role can approve.', 'gravityflow'), 'size' => '8', 'multiple' => 'multiple', 'label' => esc_html__('Select Assignees', 'gravityflow'), 'type' => 'select', 'choices' => $account_choices), array('name' => 'routing', 'tooltip' => __('Build assignee routing rules by adding conditions. Users and roles fields will appear in the first drop-down field. If the form contains any assignee fields they will also appear here. Select the assignee and define the condition for that assignee. Add as many routing rules as you need.', 'gravityflow'), 'label' => __('Routing', 'gravityflow'), 'type' => 'routing'), array('name' => 'unanimous_approval', 'label' => __('Approval Policy', 'gravityflow'), 'tooltip' => __('Define how approvals should be processed. If all assignees must approve then the entry will require unanimous approval before the step can be completed. If the step is assigned to a role only one user in that role needs to approve.', 'gravityflow'), 'type' => 'radio', 'default_value' => false, 'choices' => array(array('label' => __('At least one assignee must approve', 'gravityflow'), 'value' => false), array('label' => __('All assignees must approve', 'gravityflow'), 'value' => true))), array('name' => 'instructions', 'label' => __('Instructions', 'gravityflow'), 'type' => 'checkbox_and_textarea', 'tooltip' => esc_html__('Activate this setting to display instructions to the user for the current step.', 'gravityflow'), 'checkbox' => array('label' => esc_html__('Display instructions', 'gravityflow')), 'textarea' => array('use_editor' => true, 'default_value' => esc_html__('Instructions: please review the values in the fields below and click on the Approve or Reject button', 'gravityflow'))), array('name' => 'display_fields', 'label' => __('Display Fields', 'gravityflow'), 'tooltip' => __('Select the fields to hide or display.', 'gravityflow'), 'type' => 'display_fields'), array('name' => 'notification_tabs', 'label' => __('Emails', 'gravityflow'), 'tooltip' => __('Configure the emails that should be sent for this step.', 'gravityflow'), 'type' => 'tabs', 'tabs' => array(array('label' => __('Assignee Email', 'gravityflow'), 'id' => 'tab_assignee_notification', 'fields' => $assignee_notification_fields), array('label' => __('Rejection Email', 'gravityflow'), 'id' => 'tab_rejection_notification', 'fields' => $rejection_notification_fields), array('label' => __('Approval Email', 'gravityflow'), 'id' => 'tab_approval_notification', 'fields' => $approval_notification_fields)))));
     $revert_field = array();
     $form_id = $this->get_form_id();
     $steps = gravity_flow()->get_steps($form_id);
     foreach ($steps as $step) {
         if ($step->get_type() === 'user_input') {
             $user_input_step_choices[] = array('label' => $step->get_name(), 'value' => $step->get_id());
         }
     }
     if (!empty($user_input_step_choices)) {
         $revert_field = array('name' => 'revert', 'label' => esc_html__('Revert to User Input step', 'gravityflow'), 'type' => 'checkbox_and_select', 'tooltip' => esc_html__('The Revert setting enables a third option in addition to Approve and Reject which allows the assignee to send the entry directly to a User Input step without changing the status. Enable this setting to show the Revert button next to the Approve and Reject buttons and specify the User Input step the entry will be sent to.', 'gravityflow'), 'checkbox' => array('label' => esc_html__('Enable', 'gravityflow')), 'select' => array('choices' => $user_input_step_choices));
     }
     $note_mode_setting = array('name' => 'note_mode', 'label' => esc_html__('Workflow Note', 'gravityflow'), 'type' => 'select', 'tooltip' => esc_html__('The text entered in the Note box will be added to the timeline. Use this setting to select the options for the Note box.', 'gravityflow'), 'default_value' => 'not_required', 'choices' => array(array('value' => 'hidden', 'label' => esc_html__('Hidden', 'gravityflow')), array('value' => 'not_required', 'label' => esc_html__('Not required', 'gravityflow')), array('value' => 'required', 'label' => esc_html__('Always required', 'gravityflow')), array('value' => 'required_if_approved', 'label' => esc_html__('Required if approved', 'gravityflow')), array('value' => 'required_if_rejected', 'label' => esc_html__('Required if rejected', 'gravityflow'))));
     if (!empty($revert_field)) {
         $note_mode_setting['choices'][] = array('value' => 'required_if_reverted', 'label' => esc_html__('Required if reverted', 'gravityflow'));
         $settings['fields'][] = $revert_field;
     }
     $settings['fields'][] = $note_mode_setting;
     return $settings;
 }
 public function gpdf_add_notification_attachment($notification, $gpdf_id)
 {
     global $gfpdf;
     if (!class_exists('GPDFAPI')) {
         return $notification;
     }
     $entry = $this->get_entry();
     /* @var \GFPDF\Model\Model_PDF $gpdf_model */
     $gpdf_model = GPDFAPI::get_pdf_class('model');
     $settings = GPDFAPI::get_pdf($entry['form_id'], $gpdf_id);
     if (!is_wp_error($settings)) {
         /* @var \GFPDF\Helper\Helper_Data $data */
         $data = GPDFAPI::get_data_class();
         $pdf_generator = new \GFPDF\Helper\Helper_PDF($entry, $settings, $gfpdf->form, $data);
         $pdf_generator->set_filename($gpdf_model->get_pdf_name($settings, $entry));
         if ($gpdf_model->process_and_save_pdf($pdf_generator)) {
             $pdf_path = $pdf_generator->get_path() . $pdf_generator->get_filename();
             if (is_file($pdf_path)) {
                 if (!isset($notification['attachments'])) {
                     $notification['attachments'] = array();
                 }
                 $notification['attachments'][] = $pdf_path;
             }
         }
     }
     return $notification;
 }