public static function options_form_before($field)
 {
     if ('data' == $field['type']) {
         $form_list = FrmForm::get_published_forms();
         $selected_field = $selected_form_id = '';
         $current_field_id = $field['id'];
         if (isset($field['form_select']) && is_numeric($field['form_select'])) {
             $selected_field = FrmField::getOne($field['form_select']);
             if ($selected_field) {
                 $selected_form_id = FrmProFieldsHelper::get_parent_form_id($selected_field);
                 $fields = FrmField::get_all_for_form($selected_form_id);
             } else {
                 $selected_field = '';
             }
         } else {
             if (isset($field['form_select'])) {
                 $selected_field = $field['form_select'];
             }
         }
     }
     include FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/options-form-before.php';
 }
 public static function meta_through_join($hide_field, $selected_field, $observed_field_val, $this_field = false, &$metas)
 {
     if (is_array($observed_field_val)) {
         $observed_field_val = array_filter($observed_field_val);
     }
     if (empty($observed_field_val) || !is_numeric($observed_field_val) && !is_array($observed_field_val)) {
         return;
     }
     $observed_info = FrmField::getOne($hide_field);
     if (!$selected_field || !$observed_info) {
         return;
     }
     $form_id = FrmProFieldsHelper::get_parent_form_id($selected_field);
     $join_fields = FrmField::get_all_types_in_form($form_id, 'data');
     if (empty($join_fields)) {
         return;
     }
     foreach ($join_fields as $jf) {
         if (isset($jf->field_options['form_select']) && isset($observed_info->field_options['form_select']) && $jf->field_options['form_select'] == $observed_info->field_options['form_select']) {
             $join_field = $jf->id;
         }
     }
     if (!isset($join_field)) {
         return;
     }
     $observed_field_val = array_filter((array) $observed_field_val);
     $query = array('field_id' => (int) $join_field);
     $sub_query = array('it.meta_value' => $observed_field_val);
     foreach ($observed_field_val as $obs_val) {
         $sub_query['or'] = 1;
         $sub_query['it.meta_value LIKE'] = ':"' . $obs_val . '"';
     }
     $query[] = $sub_query;
     $user_id = '';
     if ($this_field && isset($this_field->field_options['restrict']) && $this_field->field_options['restrict']) {
         $query['e.user_id'] = get_current_user_id();
     }
     // the ids of all the entries that have been selected in the linked form
     $entry_ids = FrmEntryMeta::getEntryIds($query);
     if (!empty($entry_ids)) {
         if ($form_id != $selected_field->form_id) {
             // this is a child field so we need to get the child entries
             global $wpdb;
             $entry_ids = FrmDb::get_col($wpdb->prefix . 'frm_items', array('parent_item_id' => $entry_ids));
         }
         if (!empty($entry_ids)) {
             $metas = FrmEntryMeta::getAll(array('item_id' => $entry_ids, 'field_id' => $selected_field->id), ' ORDER BY meta_value');
         }
     }
 }