/**
  * Used by the tree card tress species selection modal
  */
 public function tree_species_fetch()
 {
     //check nounce and clear buffer
     $data = $this->start_ajax('tree_card_metabox', '_tree-card-nounce');
     try {
         $arguments = array_key_exists('data', $_POST) ? $_POST['data'] : null;
         if ($arguments) {
             $arguments = ForestUtils::get_instance()->json_decode($arguments);
             $arguments = $this->parse_tree_args($arguments);
             $current_page = $arguments['current_page'];
             $filter = $arguments['filter'];
             $sort = $arguments['sort'];
             $query = new TreeSpeciesDbQuery();
             $query_result = $query->get_tree_species($current_page, $filter, $sort);
             if ($query_result) {
                 $data['message'] = _tfm(sprintf('%d trees where found', $query->rows_found));
                 $data['type'] = 'success';
                 $data['rows'] = $query_result;
                 $data['currentPage'] = $current_page;
                 $data['columnIds'] = $current_page;
                 $data['pageCount'] = $query->max_num_pages;
                 $data['action'] = $this->get_ajax_action(__FUNCTION__);
                 //has to match the html tab id
             } else {
                 $data['message'] = _tfm('No trees where found for this filter');
                 $data['type'] = 'error';
                 $data['action'] = $this->get_ajax_action(__FUNCTION__);
             }
         } else {
             $data['type'] = 'error';
             $data['message'] = _tfm('Error saving plan');
         }
     } catch (Exception $e) {
         $data['type'] = 'error';
         $data['message'] = _tfm('Error saving plan. Server error was:') . $e->getMessage();
     }
     //add error bufferd to data and json encode
     echo $this->end_ajax($data);
     die;
     // this is
 }
 /**
  * A Filter: called by the modal generator to create the table rows
  *
  * @param $current_page
  *
  * @return array
  */
 public function get_post_selection_rows($current_page)
 {
     $qry = new TreeSpeciesDbQuery();
     $filter = $qry->get_default_filter();
     $sort = $qry->get_default_sort();
     $tree_species = $qry->get_tree_species($current_page, $filter, $sort);
     return $tree_species;
 }