/**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $node The Drupal node object.
  * @param array $response When this form is reloading after saving a submission, contains the response from the service call.
  * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
  * @return Form HTML.
  * @todo: Implement this method 
  */
 public static function get_form($args, $node, $response = null)
 {
     require_once drupal_get_path('module', 'iform') . '/client_helpers/report_helper.php';
     $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']);
     $reportOptions = iform_report_get_report_options($args, $auth);
     $reportOptions['header'] = $args['header'];
     $reportOptions['footer'] = $args['footer'];
     $reportOptions['bands'] = json_decode($args['bands'], true);
     return report_helper::freeform_report($reportOptions);
 }
 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $node The Drupal node object.
  * @param array $response When this form is reloading after saving a submission, contains the response from the service call.
  * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
  * @return Form HTML.
  * @todo: Implement this method 
  */
 public static function get_form($args, $node, $response = null)
 {
     iform_load_helpers(array('report_helper'));
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     $reportOptions = iform_report_get_report_options($args, $auth);
     $reportOptions['header'] = $args['header'];
     $reportOptions['footer'] = $args['footer'];
     $reportOptions['bands'] = json_decode($args['bands'], true);
     return report_helper::freeform_report($reportOptions);
 }
 public function informationSheetReport($auth, $args, $tabalias, $options, $path)
 {
     //List an array of display labels and their database values.
     //We then loop around an html template of one report line inserting each label and database value name until we have a
     //full template.
     //We then call a freeform report that then populates this template.
     $fields = array('Count Unit Name' => 'name', 'Alternative Name 1' => 'alternative_1', 'Alternative Name 2' => 'alternative_2', 'Abbreviation' => 'abbreviation', 'Site Name' => 'parent_location_name', 'Country' => 'country', 'Central Grid Ref/Coordinates' => 'centroid', 'Habitat' => 'habitat', 'Local Organiser Region' => 'local_organiser_region', 'Official Reason For Change' => 'official_reason_for_change');
     foreach ($fields as $caption => $databaseValue) {
         $attrsTemplate .= '<div class="field ui-helper-clearfix"><span>' . $caption . ':</span><span>{' . $databaseValue . '}</span></div>';
     }
     if (!empty($options['alternative_1_attr_id']) && !empty($options['alternative_2_attr_id']) && !empty($options['country_attr_id']) && !empty($options['habitat_attr_id']) && !empty($options['official_reason_for_change_attr_id']) && !empty($options['site_location_type_id']) && !empty($options['loc_org_reg_attr_id'])) {
         //Call the report to populate the html template
         return $attrs_report = report_helper::freeform_report(array('readAuth' => $auth['read'], 'class' => 'information-sheet-details-fields', 'dataSource' => 'reports_for_prebuilt_forms/CUDI/cudi_information_sheet', 'bands' => array(array('content' => $attrsTemplate)), 'extraParams' => array('id' => $_GET['id'], 'alternative_1_attr_id' => $options['alternative_1_attr_id'], 'alternative_2_attr_id' => $options['alternative_2_attr_id'], 'country_attr_id' => $options['country_attr_id'], 'habitat_attr_id' => $options['habitat_attr_id'], 'official_reason_for_change_attr_id' => $options['official_reason_for_change_attr_id'], 'site_location_type_id' => $options['site_location_type_id'], 'loc_org_reg_attr_id' => $options['loc_org_reg_attr_id'], 'sharing' => 'reporting')));
     } else {
         return '<div><h2>Plesse configure the Form Structure for the CUDI Information Sheet report</h2></div>';
     }
 }
 /**
  * Displays a list of determinations associated with an occurrence record. This particular panel
  * is ommitted if there are no determinations.
  * 
  * @return string The determinations report grid.
  */
 protected static function get_control_previousdeterminations($auth, $args, $tabalias, $options)
 {
     iform_load_helpers(array('report_helper'));
     $options = array_merge(array('report' => 'library/determinations/determinations_list'));
     return report_helper::freeform_report(array('readAuth' => $auth['read'], 'dataSource' => $options['report'], 'mode' => 'report', 'autoParamsForm' => false, 'header' => '<div class="detail-panel" id="detail-panel-previousdeterminations"><h3>' . lang::get('Previous determinations') . '</h3>', 'bands' => array(array('content' => '<div class="field ui-helper-clearfix">{taxon_html} by {person_name} on {date}</div>')), 'footer' => '</div>', 'extraParams' => array('occurrence_id' => $_GET['occurrence_id'], 'sharing' => 'reporting')));
 }
 /**
  * Draw Photos section of the page.
  * @return string The output report grid.
  * 
  * @package    Client
  * @subpackage PrebuiltForms
  */
 protected static function get_control_photos($auth, $args, $tabalias, $options)
 {
     iform_load_helpers(array('report_helper'));
     data_entry_helper::add_resource('fancybox');
     $options = array_merge(array('itemsPerPage' => 20, 'imageSize' => 'thumb', 'class' => 'detail-gallery'), $options);
     //Use this report to return the photos
     $reportName = 'library/occurrence_images/explore_list_2';
     return '<div class="detail-panel" id="detail-panel-photos"><h3>' . lang::get('Photos and media') . '</h3>' . report_helper::freeform_report(array('readAuth' => $auth['read'], 'dataSource' => $reportName, 'itemsPerPage' => $options['itemsPerPage'], 'class' => $options['class'], 'header' => '<ul>', 'footer' => '</ul>', 'bands' => array(array('content' => '<li class="gallery-item"><a href="{imageFolder}{path}" class="fancybox single"><img src="{imageFolder}' . $options['imageSize'] . '-{path}" /></a><br/>{caption}</li>')), 'emptyText' => '<p>No photos or media files available</p>', 'mode' => 'report', 'autoParamsForm' => false, 'extraParams' => array('taxon_meaning_id' => self::$taxon_meaning_id, 'smpattrs' => '', 'occattrs' => '', 'searchArea' => '', 'idlist' => '', 'currentUser' => '', 'ownData' => 0, 'location_id' => '', 'ownLocality' => 0, 'taxon_groups' => '', 'ownGroups' => 0, 'survey_id' => '', 'date_from' => '', 'date_to' => '', 'sharing' => 'reporting', 'quality' => 'V'))) . '</div>';
 }
 /**
  * Draw the Species Details section of the page.
  * @return string The output html string.
  * 
  * @package    Client
  * @subpackage PrebuiltForms
  */
 protected static function get_control_speciesdetails($auth, $args, $tabalias, $options)
 {
     $fields = helper_base::explode_lines($args['fields']);
     $fieldsLower = helper_base::explode_lines(strtolower($args['fields']));
     //If the user sets the option to exclude particular fields then we set to the hide flag
     //on the name types they have specified.
     if ($args['operator'] == 'not in') {
         $hidePreferred = false;
         $hideCommon = false;
         $hideSynonym = false;
         foreach ($fieldsLower as $theField) {
             if ($theField == 'preferred names' || $theField == 'preferred name' || $theField == 'preferred') {
                 $hidePreferred = true;
             }
             if ($theField == 'common names' || $theField == 'common name' || $theField == 'common') {
                 $hideCommon = true;
             }
             if ($theField == 'synonym names' || $theField == 'synonym name' || $theField == 'synonym') {
                 $hideSynonym = true;
             }
         }
     }
     //If the user sets the option to only include particular fields then we set to the hide flag
     //to true unless they have specified the name type.
     if ($args['operator'] == 'in') {
         $hidePreferred = true;
         $hideCommon = true;
         $hideSynonym = true;
         foreach ($fieldsLower as $theField) {
             if ($theField == 'preferred names' || $theField == 'preferred name' || $theField == 'preferred') {
                 $hidePreferred = false;
             }
             if ($theField == 'common names' || $theField == 'common name' || $theField == 'common') {
                 $hideCommon = false;
             }
             if ($theField == 'synonym names' || $theField == 'synonym name' || $theField == 'synonym') {
                 $hideSynonym = false;
             }
         }
     }
     //Draw the names on the page
     $details_report = self::draw_names($auth['read'], $hidePreferred, $hideCommon, $hideSynonym);
     $attrsTemplate = '<div class="field ui-helper-clearfix"><span>{caption}:</span><span>{value}</span></div>';
     //draw any custom attributes for the species added by the user
     $attrs_report = report_helper::freeform_report(array('readAuth' => $auth['read'], 'class' => 'species-details-fields', 'dataSource' => 'library/taxa/taxon_attributes_with_hiddens', 'bands' => array(array('content' => $attrsTemplate)), 'extraParams' => array('taxa_taxon_list_id' => self::$taxa_taxon_list_id, 'attrs' => strtolower(self::convert_array_to_set($fields)), 'testagainst' => $args['testagainst'], 'operator' => $args['operator'], 'sharing' => 'reporting')));
     $r = '<div class="record-details-fields ui-helper-clearfix">';
     //draw the species names and custom attributes
     if (isset($details_report)) {
         $r .= $details_report;
     }
     if (isset($attrs_report)) {
         $r .= $attrs_report;
     }
     $r .= '</div>';
     return $r;
 }
 /**
  * Outputs a list of associated occurrence information (recorded interactions).
  * @param $auth
  * @param $args
  * @param $tabalias
  * @param $options
  * @return string
  * @throws \exception
  */
 protected static function get_control_occurrenceassociations($auth, $args, $tabalias, $options)
 {
     iform_load_helpers(array('report_helper'));
     $options = array_merge(array('dataSource' => 'library/occurrence_associations/filterable_explore_list', 'itemsPerPage' => 100, 'header' => '<ul>', 'footer' => '</ul>', 'bands' => array(array('content' => '<li>{association_detail}</li>')), 'emptyText' => '<p>No association information available</p>'), $options);
     return '<div class="detail-panel" id="detail-panel-occurrenceassociations"><h3>' . lang::get('Associations') . '</h3>' . report_helper::freeform_report(array('readAuth' => $auth['read'], 'dataSource' => $options['dataSource'], 'itemsPerPage' => $options['itemsPerPage'], 'header' => $options['header'], 'footer' => $options['footer'], 'bands' => $options['bands'], 'emptyText' => $options['emptyText'], 'mode' => 'report', 'autoParamsForm' => false, 'extraParams' => array('occurrence_id' => $_GET['occurrence_id']))) . '</div>';
 }
 /**
  * Outputs a div containing a "cloud" of taxon names, based on the proportion of the recent records
  * recorded for each taxon.  
  * @param array $auth Authorisation tokens.
  * @param array $args Form arguments (the settings on the form edit tab).
  * @param string $tabalias The alias of the tab this is being loaded onto.
  * @param array $options The options passed to this control using @option=value settings in the form structure.
  * Options supported are those which can be passed to the report_helper::report_grid method, for example set @limit
  * to control how many taxa to display and set @title=... to include a heading in the output
  * @param string $path The page reload path, in case it is required for the building of links.
  * @return string HTML to insert into the page for the location map. JavaScript is added to the variables in helper_base.
  *
  * @link http://www.biodiverseit.co.uk/indicia/dev/docs/classes/report_helper.html#method_freeform_report API docs for report_helper::freeform_report
  */
 public static function trending_taxa_cloud($auth, $args, $tabalias, $options, $path)
 {
     iform_load_helpers(array('report_helper'));
     $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('dataSource' => 'library/taxa/filterable_trending_taxa', 'header' => '<ul class="taxon cloud">', 'bands' => array(array('content' => '<li style="font-size: {font_size}px">{species}</li>')), 'footer' => '</ul>', 'limit' => 15, 'autoParamsForm' => false, 'caching' => true, 'cachePerUser' => false), $options);
     $reportOptions['extraParams']['limit'] = $reportOptions['limit'];
     $r = self::output_title($options);
     $r .= report_helper::freeform_report($reportOptions);
     return $r;
 }
 protected static function get_control_occurrenceassociations($auth, $args, $tabalias, $options)
 {
     iform_load_helpers(array('report_helper'));
     $currentUrl = report_helper::get_reload_link_parts();
     // automatic handling for Drupal clean urls.
     $pathParam = function_exists('variable_get') && variable_get('clean_url', 0) == '0' ? 'q' : '';
     // amend currentUrl path if we have drupal dirty URLs so javascript will work properly
     if ($pathParam === 'q' && isset($currentUrl['params']['q']) && strpos($currentUrl['path'], '?') === false) {
         $currentUrl['path'] .= '?q=' . $currentUrl['params']['q'] . '&taxon_meaning_id=';
     } else {
         $currentUrl['path'] . '&taxon_meaning_id';
     }
     $options = array_merge(array('dataSource' => 'library/occurrence_associations/filterable_associated_species_list_cloud', 'itemsPerPage' => 20, 'class' => 'cloud', 'header' => '<ul>', 'footer' => '</ul>', 'bands' => array(array('content' => '<li style="font-size: {font_size}px">' . "<a href=\"{$currentUrl['path']}{taxon_meaning_id}\">{species}<a/></li>")), 'emptyText' => '<p>No association species information available</p>'), $options);
     return '<div class="detail-panel" id="detail-panel-occurrenceassociations"><h3>' . lang::get('Associated species') . '</h3>' . report_helper::freeform_report(array('readAuth' => $auth['read'], 'dataSource' => $options['dataSource'], 'itemsPerPage' => $options['itemsPerPage'], 'class' => $options['class'], 'header' => $options['header'], 'footer' => $options['footer'], 'bands' => $options['bands'], 'emptyText' => $options['emptyText'], 'mode' => 'report', 'autoParamsForm' => false, 'extraParams' => array('taxon_meaning_list' => self::$taxon_meaning_id))) . '</div>';
 }
 /**
  * Outputs a div containing a "cloud" of taxon names, based on the proportion of the recent records
  * recorded for each taxon.  
  * @param array $auth Authorisation tokens.
  * @param array $args Form arguments (the settings on the form edit tab).
  * @param string $tabalias The alias of the tab this is being loaded onto.
  * @param array $options The options passed to this control using @option=value settings in the form structure.
  * Options supported are those which can be passed to the report_helper::report_grid method, for example set @limit
  * to control how many taxa to display.
  * @param string $path The page reload path, in case it is required for the building of links.
  * @return string HTML to insert into the page for the location map. JavaScript is added to the variables in helper_base.
  *
  * @link http://www.biodiverseit.co.uk/indicia/dev/docs/classes/report_helper.html#method_freeform_report API docs for report_helper::freeform_report
  */
 public static function trending_taxa_cloud($auth, $args, $tabalias, $options, $path)
 {
     iform_load_helpers(array('report_helper'));
     $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('dataSource' => 'library/taxa/trending_taxa_for_event', 'header' => '<ul class="taxon cloud">', 'bands' => array(array('content' => '<li style="font-size: {font_size}px">{species}</li>')), 'footer' => '</ul>', 'limit' => 15), $options);
     $reportOptions['extraParams']['limit'] = $reportOptions['limit'];
     return report_helper::freeform_report($reportOptions);
 }