コード例 #1
0
 private function get_links_hierarchy($auth, $layerLocationTypes, $countUnitBoundaryTypeId, $urlParameter)
 {
     iform_load_helpers(array('report_helper'));
     $locationId = $_GET[$urlParameter];
     $locationRecord = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('id' => $locationId), 'nocache' => true));
     $locationTypeId = $locationRecord[0]['location_type_id'];
     $i = -1;
     //Cycle round the list of all Location Types that can be displayed on the homepage map in order.
     //Then stop when we reach the location type that is the same as the location we have clicked on. This gives us a list of location
     //types up until that point.
     do {
         $i++;
         if (!empty($SupportedLocationTypeIdsAsString)) {
             $SupportedLocationTypeIdsAsString = $SupportedLocationTypeIdsAsString . ',' . $layerLocationTypes[$i];
         } else {
             $SupportedLocationTypeIdsAsString = $layerLocationTypes[$i];
         }
     } while ($locationTypeId != $layerLocationTypes[$i] && $i < count($layerLocationTypes) - 1);
     //Use a report to get a list of locations that match the different layer location types and also intersect the location we are interested in.
     $reportOptions = array('dataSource' => 'reports_for_prebuilt_forms/CUDI/get_map_hierarchy_for_current_position', 'readAuth' => $auth['read'], 'mode' => 'report', 'extraParams' => array('location_id' => $locationId, 'location_type_ids' => $SupportedLocationTypeIdsAsString));
     $breadcrumbHierarchy = report_helper::get_report_data($reportOptions);
     //The report doesn't know the order of the layers we want, so re-order the data.
     $breadcrumbHierarchy = self::reorderBreadcrumbHierarchy($breadcrumbHierarchy, $layerLocationTypes);
     return $breadcrumbHierarchy;
 }
コード例 #2
0
 public function setup()
 {
     $this->auth = report_helper::get_read_write_auth(1, 'password');
     // make the tokens re-usable
     $this->auth['write_tokens']['persist_auth'] = true;
     // set up a tiny bit of data. First pick a termlists_term_id to use which is never going to be a valid location type,
     // so we can filter for just our test location.
     $this->db = new Database();
     $qry = $this->db->select('id')->from('list_termlists_terms')->where(array('termlist_external_key' => 'indicia:dafor', 'term' => 'Frequent'))->get()->result_array(false);
     $this->locationTypeId = $qry[0]['id'];
     $loc = ORM::Factory('location');
     $loc->name = 'UnitTest';
     $loc->centroid_sref = 'SU01';
     $loc->centroid_sref_system = 'OSGB';
     $loc->location_type_id = $this->locationTypeId;
     $loc->set_metadata();
     $loc->save();
     $this->locationId = $loc->id;
     $locattr = ORM::Factory('location_attribute');
     $locattr->caption = 'UnitTest';
     $locattr->data_type = 'T';
     $locattr->public = 'f';
     $locattr->set_metadata();
     $locattr->save();
     $this->locationAttributeId = $locattr->id;
     $locwebsite = ORM::Factory('location_attributes_website');
     $locwebsite->website_id = 1;
     $locwebsite->location_attribute_id = $this->locationAttributeId;
     $locwebsite->set_metadata();
     $locwebsite->save();
     $this->locationAttrWebsiteId = $locwebsite->id;
 }
コード例 #3
0
 /** 
  * A report showing a chart of incoming records per week.
  */
 public static function records_by_week_chart($auth, $args, $tabalias, $options, $path)
 {
     iform_load_helpers(array('report_helper'));
     $args = array_merge(array('report_name' => 'library/weeks/filterable_records_by_week'), $args);
     $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('id' => 'records-by-week-chart', 'width' => 900, 'height' => 500, 'chartType' => 'line', 'yValues' => array('processed', 'total'), 'xLabels' => 'week', 'legendOptions' => array('show' => true), 'seriesOptions' => array(array('label' => 'Processed by verifiers', 'color' => '#00FF00'), array('label' => 'All records', 'color' => '#FF9900')), 'axesOptions' => array('yaxis' => array('min' => 0, 'tickOptions' => array('formatString' => '%d')), 'xaxis' => array('label' => 'Weeks ago'))), $options);
     return report_helper::report_chart($reportOptions);
 }
コード例 #4
0
ファイル: report_map.php プロジェクト: BirenRathod/drupal-6
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     iform_load_helpers(array('report_helper', 'map_helper'));
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     $reportOptions = iform_report_get_report_options($args, $auth);
     $r = '<div class="ui-helper-clearfix">';
     $reportOptions['geoserverLayer'] = $args['geoserver_layer'];
     $reportOptions['geoserverLayerStyle'] = $args['geoserver_layer_style'];
     $reportOptions['cqlTemplate'] = $args['cql_template'];
     $reportOptions['clickable'] = $args['click_on_map_mode'] != 'none';
     $reportOptions['clickableLayersOutputDiv'] = $args['click_on_map_div'];
     if (!empty($args['click_on_map_columns'])) {
         $reportOptions['clickableLayersOutputColumns'] = helper_base::explode_lines_key_value_pairs($args['click_on_map_columns']);
     }
     if ($args['click_on_map_mode'] != 'none') {
         $reportOptions['clickableLayersOutputMode'] = $args['click_on_map_mode'];
     }
     // Use the proxy module if enabled, to get round limitations in URL length for
     // filtered WMS requests.
     if (defined('DRUPAL_BOOTSTRAP_CONFIGURATION') && module_exists('iform_proxy')) {
         global $base_url;
         $reportOptions['proxy'] = $base_url . '/?q=' . variable_get('iform_proxy_path', 'proxy') . '&url=';
     }
     $r .= '<br/>' . report_helper::report_map($reportOptions);
     $options = iform_map_get_map_options($args, $readAuth);
     $olOptions = iform_map_get_ol_options($args);
     // This is used for drawing, so need an editlayer, but not used for input
     $options['editLayer'] = true;
     $options['editLayerInSwitcher'] = true;
     $options['clickForSpatialRef'] = false;
     if ($args['layer_picker'] != 'none') {
         $picker = array('id' => 'map-layer-picker', 'includeIcons' => false, 'includeSwitchers' => true, 'includeHiddenLayers' => true);
         if ($args['layer_picker'] == 'before') {
             $r .= map_helper::layer_list($picker);
         }
         // as we have a layer picker, we can drop the layerSwitcher from the OL map.
         if (array_search('layerSwitcher', $options['standardControls']) !== false) {
             unset($options['standardControls'][array_search('layerSwitcher', $options['standardControls'])]);
         }
     }
     if ($args['legend'] != 'none') {
         $legend = array('id' => 'map-legend', 'includeIcons' => true, 'includeSwitchers' => false, 'includeHiddenLayers' => false);
         if ($args['legend'] == 'before') {
             $r .= map_helper::layer_list($legend);
         }
     }
     if (isset($args['map_toolbar_pos'])) {
         $options['toolbarDiv'] = $args['map_toolbar_pos'];
     }
     $r .= map_helper::map_panel($options, $olOptions);
     if ($args['layer_picker'] == 'after') {
         $r .= map_helper::layer_list($picker);
     }
     if ($args['legend'] == 'after') {
         $r .= map_helper::layer_list($legend);
     }
     $r .= '</div>';
     return $r;
 }
コード例 #5
0
 /**
  * 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', 'map_helper'));
     $conn = iform_get_connection_details($node);
     $readAuth = report_helper::get_read_auth($conn['website_id'], $conn['password']);
     $r = '<div id="leftcol">';
     $reportOptions = iform_report_get_report_options($args, $readAuth);
     iform_report_apply_explore_user_own_preferences($reportOptions);
     $reportOptions = array_merge(array('rowId' => 'external_key', 'columns' => array(), 'callback' => 'grid_load', 'rememberParamsReportGroup' => 'explore', 'paramsFormButtonCaption' => lang::get('Filter')), $reportOptions);
     $reportOptions['rowId'] = 'external_key';
     $imgPath = empty(report_helper::$images_path) ? report_helper::relative_client_helper_path() . "../media/images/" : report_helper::$images_path;
     $reportOptions['columns'][] = array('actions' => array(array('img' => "{$imgPath}/add.png", 'caption' => 'Click to add this species to the map')));
     $r .= report_helper::report_grid($reportOptions);
     $r .= '</div>';
     $args['indicia_species_layer_slds'] = report_helper::explode_lines($args['indicia_species_layer_slds']);
     $r .= '<div id="rightcol">';
     $r .= '<div id="layerbox">';
     $r .= '<p id="instruct">' . lang::get('Click on the + buttons in the grid to add species layers to the map. You can add up to {1} layers at a time.', count($args['indicia_species_layer_slds']));
     $r .= '<p id="instruct2" style="display: none">' . lang::get('Use the - buttons to permanently remove layers, or untick the box in the legend to temporarily hide them.');
     $mapOptions = iform_map_get_map_options($args, $readAuth);
     $mapOptions['clickForSpatialRef'] = false;
     $olOptions = iform_map_get_ol_options($args, $readAuth);
     $r .= map_helper::layer_list(array('layerTypes' => array('overlay'), 'includeSwitchers' => true, 'includeHiddenLayers' => true));
     $r .= '</div>';
     $r .= map_helper::map_panel($mapOptions, $olOptions);
     $r .= '</div>';
     $websiteIds = iform_get_allowed_website_ids($readAuth);
     if (!empty($args['indicia_species_layer_feature_type']) && !empty(report_helper::$geoserver_url)) {
         $training = function_exists('hostsite_get_user_field') && hostsite_get_user_field('training') ? 't' : 'f';
         $cql = 'website_id IN (' . implode(',', $websiteIds) . ') AND ' . $args['indicia_species_layer_filter_field'] . "='{filterValue}' AND record_status NOT IN ('R', 'I', 'T') AND training='{$training}'";
         if (isset($_POST[$reportOptions['reportGroup'] . '-quality'])) {
             $quality = $_POST[$reportOptions['reportGroup'] . '-quality'];
         } else {
             $quality = $reportOptions['extraParams']['quality'];
         }
         // logic here must match the quality_check function logic on the database.
         switch ($quality) {
             case 'V':
                 $cql .= " AND record_status='V'";
                 break;
             case 'C':
                 $cql .= " AND (record_status='V' OR certainty='C')";
                 break;
             case 'L':
                 $cql .= " AND (record_status='V' OR ((certainty <> 'U' OR certainty IS NULL) AND record_status <> 'D'))";
                 break;
             case '!D':
                 $cql .= " AND record_status<>'D'";
                 break;
             case '!R':
                 // nothing to add - rejects are always excluded
         }
         report_helper::$javascript .= "indiciaData.indiciaSpeciesLayer = {\n" . '  "title":"' . lang::get('{1}') . "\",\n" . '  "myRecords":"' . lang::get('my records') . "\",\n" . '  "userId":"' . hostsite_get_user_field('indicia_user_id') . "\",\n" . '  "featureType":"' . $args['indicia_species_layer_feature_type'] . "\",\n" . '  "wmsUrl":"' . data_entry_helper::$geoserver_url . "wms\",\n" . "  \"cqlFilter\":\"{$cql}\",\n" . "  \"filterField\":\"taxon_meaning_id\",\n" . '  "slds":' . json_encode($args['indicia_species_layer_slds']) . "\n" . "};\n";
     }
     return $r;
 }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
 /**
  * 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);
 }
コード例 #8
0
 public static function add_template_locations_to_map($auth, $args, $tabalias, $options, $path)
 {
     if (empty($options['location_type_id']) || !preg_match('/^\\d+$/', $options['location_type_id'])) {
         throw new exception('Please supply a valid location_type_id option.');
     }
     iform_load_helpers(array('report_helper'));
     $r = report_helper::report_map(array('readAuth' => $auth['read'], 'dataSource' => 'library/locations/locations_list_mapping', 'dataSourceLoRes' => 'library/locations/locations_list_mapping', 'extraParams' => array('location_type_id' => $options['location_type_id']), 'ajax' => TRUE, 'clickable' => FALSE));
     // output a hidden grid, since the AJAX code for a report_map is in the grid.
     $r .= report_helper::report_grid(array('readAuth' => $auth['read'], 'dataSource' => 'library/locations/locations_list_mapping', 'extraParams' => array('location_type_id' => $options['location_type_id']), 'ajax' => TRUE, 'class' => 'report-grid hidden'));
     report_helper::$javascript .= "indiciaData.wantPathEditor = true;\n";
     return $r;
 }
コード例 #9
0
 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>';
     }
 }
コード例 #10
0
 /**
  * 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)
 {
     if (empty($_GET['group_id'])) {
         return 'This page needs a group_id URL parameter.';
     }
     require_once 'includes/map.php';
     require_once 'includes/groups.php';
     global $indicia_templates;
     iform_load_helpers(array('report_helper', 'map_helper'));
     $conn = iform_get_connection_details($node);
     $readAuth = report_helper::get_read_auth($conn['website_id'], $conn['password']);
     report_helper::$javascript .= "indiciaData.website_id={$conn['website_id']};\n";
     report_helper::$javascript .= "indiciaData.nodeId={$node->nid};\n";
     group_authorise_form($args, $readAuth);
     $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $readAuth + array('id' => $_GET['group_id'], 'view' => 'detail')));
     $group = $group[0];
     hostsite_set_page_title("{$group['title']}: {$node->title}");
     $actions = array();
     if (!empty($args['edit_location_path'])) {
         $actions[] = array('caption' => 'edit', 'url' => '{rootFolder}' . $args['edit_location_path'], 'urlParams' => array('group_id' => $_GET['group_id'], 'location_id' => '{location_id}'));
     }
     $actions[] = array('caption' => 'remove', 'javascript' => "remove_location_from_group({groups_location_id});");
     $leftcol = report_helper::report_grid(array('readAuth' => $readAuth, 'dataSource' => 'library/locations/locations_for_groups', 'sendOutputToMap' => true, 'extraParams' => array('group_id' => $_GET['group_id']), 'rowId' => 'location_id', 'columns' => array(array('display' => 'Actions', 'actions' => $actions, 'caption' => 'edit', 'url' => '{rootFolder}'))));
     $leftcol .= '<fieldset><legend>' . lang::Get('Add sites to the group') . '</legend>';
     $leftcol .= '<p>' . lang::get('LANG_Add_Sites_Instruct') . '</p>';
     if (!empty($args['edit_location_path'])) {
         $leftcol .= lang::get('Either') . ' <a class="button" href="' . hostsite_get_url($args['edit_location_path'], array('group_id' => $_GET['group_id'])) . '">' . lang::get('enter details of a new site') . '</a><br/>';
     }
     $leftcol .= data_entry_helper::select(array('label' => lang::get('Or, add an existing site'), 'fieldname' => 'add_existing_location_id', 'report' => 'library/locations/locations_available_for_group', 'caching' => false, 'blankText' => lang::get('<please select>'), 'valueField' => 'location_id', 'captionField' => 'name', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'user_id' => hostsite_get_user_field('indicia_user_id', 0)), 'afterControl' => '<button id="add-existing">Add</button>'));
     $leftcol .= '</fieldset>';
     // @todo Link existing My Site to group. Need a new report to list sites I created, with sites already in the group
     // removed. Show in a drop down with an add button. Adding must create the groups_locations record, plus refresh
     // the grid and refresh the drop down.
     // @todo set destination after saving added site
     $map = map_helper::map_panel(iform_map_get_map_options($args, $readAuth), iform_map_get_ol_options($args));
     $r = str_replace(array('{col-1}', '{col-2}'), array($leftcol, $map), $indicia_templates['two-col-50']);
     data_entry_helper::$javascript .= "indiciaData.group_id={$_GET['group_id']};\n";
     return $r;
 }
コード例 #11
0
ファイル: report_grid.php プロジェクト: BirenRathod/drupal-6
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting a verification.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     iform_load_helpers(array('report_helper'));
     data_entry_helper::add_resource('jquery_form');
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     $reportOptions = iform_report_get_report_options($args, $auth);
     // get the grid output before outputting the download link, so we can check if the download link is needed.
     $reportOptions['id'] = 'grid-' . $node->nid;
     if (isset($args['footer'])) {
         $reportOptions['footer'] = $args['footer'];
     }
     $reportOptions['downloadLink'] = !isset($args['download_link']) || $args['download_link'];
     $grid = report_helper::report_grid($reportOptions);
     return $grid;
 }
コード例 #12
0
 private static function get_notifications_html($auth, $sourceType, $website_id, $user_id, $options)
 {
     iform_load_helpers(array('report_helper'));
     $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path;
     $sendReply = $imgPath . "nuvola/mail_send-22px.png";
     $cancelReply = $imgPath . "nuvola/mail_delete-22px.png";
     //When the user wants to reply to a message, we have to add a new row
     report_helper::$javascript .= "\n    indiciaData.reply_to_message = function(notification_id, occurrence_id) {\n      if (!\$('#reply-row-'+occurrence_id).length) {\n        rowHtml = '<tr id='+\"reply-row-\"+occurrence_id+'><td><label for=\"\">" . lang::get('Enter your reply below') . ":</label><textarea style=\"width: 95%\" id=\"reply-' +occurrence_id+'\"></textarea></td>';\n        rowHtml += '<td class=\"actions\">';\n        rowHtml += '<div><img class=\"action-button\" src=\"{$sendReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',true);\" title=\"Send reply\">';\n        rowHtml += '<img class=\"action-button\" src=\"{$cancelReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',false);\" title=\"Cancel reply\">';\n        rowHtml += '</div></td></tr>';\n        \$(rowHtml).insertAfter('tr#row'+notification_id);\n        \$('tr#row'+notification_id+' .action-button').hide();\n      }\n    };\n\n    ";
     $urlParams = array('occurrence_id' => '{occurrence_id}');
     if (!empty($_GET['group_id'])) {
         $urlParams['group_id'] = $_GET['group_id'];
     }
     $availableActions = array(array('caption' => lang::get('Edit this record'), 'class' => 'edit-notification', 'url' => '{rootFolder}{editing_form}', 'urlParams' => $urlParams, 'img' => $imgPath . 'nuvola/package_editors-22px.png', 'visibility_field' => 'editable_flag'), array('caption' => lang::get('View this record'), 'class' => 'view-notification', 'url' => '{rootFolder}{viewing_form}', 'urlParams' => $urlParams, 'img' => $imgPath . 'nuvola/find-22px.png', 'visibility_field' => 'viewable_flag'), array('caption' => lang::get('Mark as read'), 'javascript' => 'remove_message({notification_id});', 'img' => $imgPath . 'nuvola/kmail-22px.png'));
     //Only allow replying for 'user' messages.
     if (isset($options['allowReply']) && $options['allowReply'] === true) {
         $availableActions = array_merge($availableActions, array(array('caption' => lang::get('Reply to this message'), 'img' => $imgPath . 'nuvola/mail_reply-22px.png', 'visibility_field' => 'reply_flag', 'javascript' => "indiciaData.reply_to_message(" . '{notification_id}' . "," . '{occurrence_id}' . ");")));
     }
     $extraParams = array('user_id' => $user_id, 'system_name' => 'indicia', 'orderby' => 'triggered_on', 'sortdir' => 'DESC', 'default_edit_page_path' => $options['default_edit_page_path'], 'view_record_page_path' => $options['view_record_page_path'], 'website_id' => $website_id);
     //Implode the source types so we can submit to the database in one text field.
     if (!empty($sourceType)) {
         $extraParams['source_types'] = "'" . implode("' ,'", $sourceType) . "'";
         //If the user has supplied some config options for the different source types then we don't need the
         // source filter drop down.
         $extraParams['source_filter'] = 'all';
     }
     //Only include notifications associated with a set of recording group ids if option is supplied.
     if (!empty($options['groupIds'])) {
         $extraParams['group_ids'] = $options['groupIds'];
     }
     $columns = array('data' => array('fieldname' => 'data', 'json' => true, 'template' => '<div class="type-{source_type}"><div class="status-{record_status}"></div></div><div class="note-type-{source_type}">{comment}</div>' . '<div class="comment-from helpText" style="margin-left: 34px; display: block;">from {username} on {triggered_date}</div>', 'display' => 'Message'), 'occurrence_id' => array('fieldname' => 'occurrence_id'), 'actions' => array('actions' => $availableActions), 'triggered_date' => array('fieldname' => 'triggered_date', 'visible' => false));
     // allow columns config to override our default setup
     if (!empty($options['columns'])) {
         foreach ($options['columns'] as $column) {
             if (!empty($column['actions'])) {
                 $columns['actions'] = $column;
             } elseif (!empty($column['fieldname'])) {
                 $columns[$column['fieldname']] = $column;
             }
         }
     }
     $r = report_helper::report_grid(array('id' => 'notifications-' . $options['id'], 'readAuth' => $auth['read'], 'itemsPerPage' => 10, 'dataSource' => 'library/notifications/notifications_list_for_notifications_centre', 'rowId' => 'notification_id', 'ajax' => true, 'mode' => 'report', 'extraParams' => $extraParams, 'paramDefaults' => array('source_filter' => 'all'), 'paramsFormButtonCaption' => lang::get('Filter'), 'columns' => array_values($columns)));
     return $r;
 }
コード例 #13
0
 private static function get_notifications_html($auth, $sourceType, $website_id, $user_id, $options)
 {
     iform_load_helpers(array('report_helper'));
     global $auth;
     $readNonce = $auth['nonce'];
     $readAuthToken = $auth['auth_token'];
     $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path;
     $sendReply = $imgPath . "nuvola/mail_send-22px.png";
     $cancelReply = $imgPath . "nuvola/mail_delete-22px.png";
     //When the user wants to reply to a message, we have to add a new row
     report_helper::$javascript .= "\n    indiciaData.reply_to_message = function(notification_id, occurrence_id) {\n      if (!\$('#reply-row-'+occurrence_id).length) {\n        rowHtml = '<tr id='+\"reply-row-\"+occurrence_id+'><td><label for=\"\">" . lang::get('Enter your reply below') . ":</label><textarea style=\"width: 95%\" id=\"reply-' +occurrence_id+'\"></textarea></td>';\n        rowHtml += '<td class=\"actions\">';\n        rowHtml += '<div><img class=\"action-button\" src=\"{$sendReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',true);\" title=\"Send reply\">';\n        rowHtml += '<img class=\"action-button\" src=\"{$cancelReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',false);\" title=\"Cancel reply\">';\n        rowHtml += '</div></td></tr>';\n        \$(rowHtml).insertAfter('tr#row'+notification_id);\n        \$('tr#row'+notification_id+' .action-button').hide();\n      }\n    };\n\n    ";
     //Setup the javascript needed to support the remove notification button.
     self::setup_source_types_hidden_fields($options, $sourceType, $website_id, $auth);
     $auth = report_helper::get_read_auth(variable_get('indicia_website_id', ''), variable_get('indicia_password', ''));
     //Implode the source types so we can submit to the database in one text field.
     foreach ($sourceType as &$type) {
         $type = "'" . $type . "'";
     }
     $sourceType = implode(',', $sourceType);
     $availableActions = array(array('caption' => lang::get('Edit this record'), 'class' => 'edit-notification', 'url' => '{rootFolder}{editing_form}', 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'img' => $imgPath . 'nuvola/package_editors-22px.png', 'visibility_field' => 'editable_flag'), array('caption' => lang::get('View this record'), 'class' => 'view-notification', 'url' => '{rootFolder}{viewing_form}', 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'img' => $imgPath . 'nuvola/find-22px.png', 'visibility_field' => 'viewable_flag'), array('caption' => lang::get('Mark as read'), 'javascript' => 'remove_message({notification_id});', 'img' => $imgPath . 'nuvola/kmail-22px.png'));
     //Only allow replying for 'user' messages.
     if ($options['allowReply'] === true) {
         $availableActions = array_merge($availableActions, array(array('caption' => lang::get('Reply to this message'), 'img' => $imgPath . 'nuvola/mail_reply-22px.png', 'javascript' => "indiciaData.reply_to_message(" . '{notification_id}' . "," . '{occurrence_id}' . ");")));
     }
     return report_helper::report_grid(array('id' => 'notifications-' . $options['id'], 'readAuth' => $auth, 'itemsPerPage' => 10, 'dataSource' => 'library/notifications/notifications_list_for_notifications_centre', 'rowId' => 'notification_id', 'ajax' => true, 'mode' => 'report', 'extraParams' => array('user_id' => $user_id, 'system_name' => 'indicia', 'source_types' => $sourceType, 'orderby' => 'triggered_on', 'sortdir' => 'DESC', 'default_edit_page_path' => $options['default_edit_page_path'], 'view_record_page_path' => $options['view_record_page_path'], 'website_id' => $website_id), 'columns' => array(array('fieldname' => 'data', 'json' => true, 'template' => '<div class="type-{source_type}"><div class="status-{record_status}"></div></div><div class="note-type-{source_type}">{comment}</div>' . '<div class="comment-from helpText" style="margin-left: 34px; display: block;">from {username} on {triggered_date}</div>', 'display' => 'Message'), array('actions' => $availableActions), array('fieldname' => 'triggered_date', 'visible' => false))));
 }
コード例 #14
0
ファイル: index.php プロジェクト: BirenRathod/indicia-code
 * any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/gpl.html.
 *
 * @package	Core
 * @subpackage Views
 * @author	Indicia Team
 * @license	http://www.gnu.org/licenses/gpl.html GPL
 * @link 	http://code.google.com/p/indicia/
 */
?>
<form action="<?php 
echo url::site();
?>
report_viewer/load" method="GET">
<?php 
require_once DOCROOT . 'client_helpers/report_helper.php';
$readAuth = report_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key'));
echo report_helper::report_picker(array('readAuth' => $readAuth));
report_helper::link_default_stylesheet();
echo report_helper::dump_javascript();
?>
<input type="submit" value="Load report" />
</form>


コード例 #15
0
 protected static function get_control_hideControlForNonGroupMembers($auth, $args, $tabalias, $options)
 {
     iform_load_helpers(array('report_helper'));
     $currentUserId = hostsite_get_user_field('indicia_user_id');
     if (empty($options['controlId'])) {
         drupal_set_message('The option to hide a control based on group has been specified, but no option to indicate which control has been provided.');
         return false;
     }
     if (empty($options['groupId'])) {
         drupal_set_message('The option to hide a control based on group has been specified, but no group id has been provided.');
         return false;
     }
     $reportOptions = array('dataSource' => 'library/groups/group_members', 'readAuth' => $auth['read'], 'mode' => 'report', 'extraParams' => array('group_id' => $options['groupId']));
     $usersInGroup = report_helper::get_report_data($reportOptions);
     //Check all members in the group, if the current user is in the group, then there is no need to hide the control.
     $userFoundInGroup = false;
     foreach ($usersInGroup as $userInGroup) {
         if ($userInGroup['id'] === $currentUserId) {
             $userFoundInGroup = true;
         }
     }
     if ($userFoundInGroup !== true || empty($_GET['group_id']) || $_GET['group_id'] != $options['groupId']) {
         //Parent hide control stops the control and label from showing on screen.
         //Disable control stops it appearing in the POST and getting submitted.
         data_entry_helper::$javascript .= "\$('#" . $options['controlId'] . "').attr('disabled', true);\n";
         data_entry_helper::$javascript .= "\$('#" . $options['controlId'] . "').parent().hide();\n";
     }
 }
コード例 #16
0
 /**
  * Method that retrieves the data from a report or a table/view, ready to display in a chart or grid.
  * @param array $options Refer to documentation for report_helper::get_report_data.
  * @param string $extra Refer to documentation for report_helper::get_report_data.
  * @deprecated, use report_helper::get_report_data instead.
  */
 public static function get_report_data($options, $extra = '')
 {
     require_once 'report_helper.php';
     return report_helper::get_report_data($options, $extra);
 }
コード例 #17
0
 /**
  * Performs the download.
  * @global array $indicia_templates
  * @param type $args
  * @param type $node
  */
 private static function do_data_services_download($args, $node)
 {
     iform_load_helpers(array('report_helper'));
     $format = $_POST['format'];
     $isCustom = preg_match('/^custom-(\\d+)$/', $_POST['format'], $matches);
     if ($isCustom) {
         $customFormats = json_decode($args['custom_formats'], true);
         $customFormat = $customFormats[$matches[1]];
         $report = $customFormat['report'];
         // strip unnecessary .xml from end of report name if provided
         $report = preg_replace('/\\.xml$/', '', $report);
         $format = $customFormat['format'];
         $additionalParamText = $customFormat['params'];
     } else {
         $report = $args["report_{$format}"];
         $additionalParamText = $args["report_params_{$format}"];
     }
     $params = self::build_params($args);
     $params = array_merge($params, get_options_array_with_user_data($additionalParamText));
     $conn = iform_get_connection_details($node);
     global $indicia_templates;
     // let's just get the URL, not the whole anchor element
     $indicia_templates['report_download_link'] = '{link}';
     $limit = $args['limit'] == 0 ? '' : $args['limit'];
     // unlimited or limited
     $sharing = substr($_POST['download-type'], 0, 1);
     $url = report_helper::report_download_link(array('readAuth' => data_entry_helper::$js_read_tokens, 'dataSource' => $report, 'extraParams' => $params, 'format' => $format, 'sharing' => self::expand_sharing_mode($sharing), 'itemsPerPage' => $limit));
     if ($args['reverse_proxy'] == true) {
         // Rewrite the url to pass through proxy.php
         $relative_proxy_path = iform_client_helpers_path() . 'proxy.php?url=' . report_helper::$base_url;
         global $base_url;
         $proxy_path = $base_url . substr($relative_proxy_path, 1);
         // remove report_helper::$base_url from $url
         $url = substr($url, strlen(report_helper::$base_url));
         // add $proxy_path to $url
         $url = $proxy_path . $url;
     }
     header("Location: {$url}");
 }
コード例 #18
0
ファイル: report_chart.php プロジェクト: BirenRathod/drupal-6
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting a verification.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     require_once drupal_get_path('module', 'iform') . '/client_helpers/report_helper.php';
     require_once drupal_get_path('module', 'iform') . '/client_helpers/map_helper.php';
     $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']);
     $chartOptions = iform_report_get_report_options($args, $auth);
     $chartOptions = array_merge($chartOptions, array('id' => 'chart-div', 'width' => $args['width'], 'height' => $args['height'], 'chartType' => $args['chart_type'], 'yValues' => explode(',', $args['y_values'])));
     $xLabels = trim($args['x_labels']);
     if (empty($xLabels)) {
         $chartOptions['xValues'] = explode(',', $args['x_values']);
     } else {
         $chartOptions['xLabels'] = explode(',', $args['x_labels']);
     }
     // advanced options
     $rendererOptions = trim($args['renderer_options']);
     if (!empty($rendererOptions)) {
         $chartOptions['rendererOptions'] = json_decode($rendererOptions, true);
     }
     $legendOptions = trim($args['legend_options']);
     if (!empty($legendOptions)) {
         $chartOptions['legendOptions'] = json_decode($legendOptions, true);
     }
     $seriesOptions = trim($args['series_options']);
     if (!empty($seriesOptions)) {
         $chartOptions['seriesOptions'] = json_decode($seriesOptions, true);
     }
     $axesOptions = trim($args['axes_options']);
     if (!empty($axesOptions)) {
         $chartOptions['axesOptions'] = json_decode($axesOptions, true);
     }
     // now the chart itself
     $r .= '<br/>' . report_helper::report_chart($chartOptions);
     return $r;
 }
コード例 #19
0
 /**
  * Hierarchy map control, which can be added to user interface form configurations using [site_hierarchy_navigator.map].
  *
  * Display a map with polygons loaded onto it of a particular location type. When the user clicks on one, reloads the map layer
  * to show the intersecting polygons from the next location type. Continues down the locations hierarchy in a supplied sequence of 
  * location types (e.g. you might set the location type sequence to Country, County, Parish, Site). 
  *
  * Supply an option @layerLocationTypes with a comma separated array of the location types ID to load in top down order.
  */
 public function map($auth, $args, $tabalias, $options, $path)
 {
     global $base_root;
     //Setup the path to the cudi information sheets.
     //Include the parameter on the end of the path, but leave off the parameter values
     //as these will change for each path used.
     iform_load_helpers(array('map_helper', 'report_helper'));
     $informationSheetLinkParts = explode('|', $options['informationSheetLink']);
     $path = $base_root . base_path() . (variable_get('clean_url', 0) ? '' : '?q=') . $informationSheetLinkParts[0] . (variable_get('clean_url', 0) ? '?' : '&') . $informationSheetLinkParts[1] . '=';
     map_helper::$javascript .= "indiciaData.informationSheetLink='" . $path . "';\n";
     if (empty($options['layerLocationTypes'])) {
         return '<p>Please provide a @layerLocationTypes option for the [site_hierarchy_navigator.map] map control on the edit tab</p>';
     }
     $msg = self::check_format($options, 'layerLocationTypes', 'location_type_id (from the termlists term table)', '/^([0-9]*,\\s*)*[0-9]*\\s*$/');
     if ($msg !== true) {
         return $msg;
     }
     //This option is optional, so don't need to check if it isn't present
     $msg = self::check_format($options, 'showCountUnitsForLayers', 'location_type_id (from the termlists term table)', '/^([0-9]*,\\s*)*[0-9]*\\s*$/');
     if ($msg !== true) {
         return $msg;
     }
     drupal_add_js(iform_client_helpers_path() . 'prebuilt_forms/extensions/site_hierarchy_navigator.js');
     //The location types are supplied by the user in a comma seperated list.
     //The first number is used as the initial location type to display.
     //The second number is used after the user clicks the first time on a feature and so on
     $layerLocationTypes = explode(',', $options['layerLocationTypes']);
     //Comma seperated list of location types which signify which layers should also display the Count Unit location type.
     //This should be a subset of $layerLocationTypes.
     $showCountUnitsForLayers = explode(',', $options['showCountUnitsForLayers']);
     $locationTypesWithSymbols = explode(',', $options['locationTypesWithSymbols']);
     //Annotation location types as defined on edit tab
     $annotationTypeIds = explode(',', $options['annotationTypeIds']);
     $mapOptions = iform_map_get_map_options($args, $auth);
     $olOptions = iform_map_get_ol_options($args);
     $mapOptions['readAuth'] = $mapOptions['readAuth']['read'];
     $mapOptions['clickForSpatialRef'] = false;
     //When user clicks on map, run specified Javascript function
     $mapOptions['clickableLayersOutputMode'] = 'customFunction';
     $mapOptions['customClickFn'] = 'move_to_new_layer';
     $mapOptions['clickableLayersOutputDiv'] = '';
     //Tell the system which layers we to be clickable.
     $mapOptions['clickableLayers'] = array('indiciaData.reportlayer');
     $r .= map_helper::map_panel($mapOptions, $olOptions);
     map_helper::$javascript .= "indiciaData.layerLocationTypes=" . json_encode($layerLocationTypes) . ";\n";
     $reportOptions = array('dataSource' => 'reports_for_prebuilt_forms/CUDI/get_layer_list_names', 'readAuth' => $auth['read'], 'mode' => 'report', 'extraParams' => array('layer_ids' => $options['layerLocationTypes']));
     //Return a list of location type names for the location type id layers list
     //provided by the user in the form structure.
     $locationTypeNamesDirty = data_entry_helper::get_report_data($reportOptions);
     //The data returned by the database is not a simple array of names, so convert the data and put into correct order
     foreach ($layerLocationTypes as $originalLayerIndex => $layerLocationTypeFromOriginalList) {
         foreach ($locationTypeNamesDirty as $locationTypeNamesData) {
             if ($locationTypeNamesData['id'] === $layerLocationTypeFromOriginalList) {
                 $locationTypeNamesClean[$originalLayerIndex] = $locationTypeNamesData['name'];
             }
         }
     }
     //Send the array of names to javascript
     map_helper::$javascript .= "indiciaData.layerLocationTypesNames=" . json_encode($locationTypeNamesClean) . ";\n";
     //Send the user supplied options for layers to display count units to Javascript
     map_helper::$javascript .= "indiciaData.showCountUnitsForLayers=" . json_encode($showCountUnitsForLayers) . ";\n";
     map_helper::$javascript .= "indiciaData.countUnitBoundaryTypeId=" . $options['countUnitBoundaryTypeId'] . ";\n";
     map_helper::$javascript .= "indiciaData.annotationTypeIds=" . json_encode($annotationTypeIds) . ";\n";
     map_helper::$javascript .= "indiciaData.deactivateSiteAttributeId=" . $options['deactivateSiteAttributeId'] . ";\n";
     //Get translatable label for top-level breadcrub item.
     map_helper::$javascript .= "indiciaData.allSitesLabel='" . lang::get('All Sites') . "';\n";
     $reportOptions = array('linkOnly' => 'true', 'dataSource' => 'reports_for_prebuilt_forms/cudi/get_boundaries_and_locations_for_cudi_map', 'readAuth' => $auth['read']);
     //Get the report options such as the Preset Parameters on the Edit Tab
     $reportOptions = array_merge(iform_report_get_report_options($args, $readAuth), $reportOptions);
     //Run the report that shows the locations (features) to the user when the map loads the first time.
     map_helper::$javascript .= "indiciaData.layerReportRequest='" . report_helper::get_report_data($reportOptions) . "';\n";
     //Options for the report that is used to draw the map breadcrumb
     $reportOptions = array('linkOnly' => 'true', 'dataSource' => 'reports_for_prebuilt_forms/CUDI/get_map_hierarchy_for_current_position', 'readAuth' => $auth['read']);
     //Get the report options such as the Preset Parameters on the Edit Tab
     $reportOptions = array_merge(iform_report_get_report_options($args, $readAuth), $reportOptions);
     //Run the report that builds the map breadcrumb.
     map_helper::$javascript .= "indiciaData.breadcrumbReportRequest='" . report_helper::get_report_data($reportOptions) . "';\n";
     return $r;
 }
コード例 #20
0
 /**
  * Return the generated 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.
  */
 public static function get_form($args, $node, $response = null)
 {
     iform_load_helpers(array('report_helper', 'map_helper'));
     $readAuth = report_helper::get_read_auth($args['website_id'], $args['password']);
     $sharing = 'reporting';
     $reportOptions = array_merge(iform_report_get_report_options($args, $readAuth), array('reportGroup' => 'explore', 'rememberParamsReportGroup' => 'explore', 'paramsOnly' => true, 'paramsInMapToolbar' => true, 'sharing' => $sharing, 'paramsFormButtonCaption' => lang::get('Filter'), 'rowId' => 'occurrence_id'));
     iform_report_apply_explore_user_own_preferences($reportOptions);
     $reportOptions['extraParams']['limit'] = 3000;
     $r = report_helper::report_grid($reportOptions);
     $r .= report_helper::report_map(array('readAuth' => $readAuth, 'dataSource' => $args['report_name'], 'extraParams' => $reportOptions['extraParams'], 'paramDefaults' => $reportOptions['paramDefaults'], 'autoParamsForm' => false, 'reportGroup' => 'explore', 'rememberParamsReportGroup' => 'explore', 'clickableLayersOutputMode' => 'report', 'sharing' => $sharing, 'rowId' => 'occurrence_id', 'ajax' => TRUE));
     $options = array_merge(iform_map_get_map_options($args, $readAuth), array('featureIdField' => 'occurrence_id', 'clickForSpatialRef' => false, 'reportGroup' => 'explore', 'toolbarDiv' => 'top'));
     $olOptions = iform_map_get_ol_options($args);
     $r .= map_helper::map_panel($options, $olOptions);
     $allowDownload = !isset($args['downloadOwnDataOnly']) || !$args['downloadOwnDataOnly'] || isset($reportOptions['extraParams']['ownData']) && $reportOptions['extraParams']['ownData'] === 1 || isset($_POST['explore-ownData']) && $_POST['explore-ownData'] === '1' || !(isset($_POST['explore-ownData']) || $_POST['explore-ownData'] === '0') && isset($reportOptions['paramDefaults']['ownData']) && $reportOptions['paramDefaults']['ownData'] === 1;
     $reportOptions = array_merge($reportOptions, array('id' => 'explore-records', 'paramsOnly' => false, 'autoParamsForm' => false, 'downloadLink' => $allowDownload, 'rowClass' => 'certainty{certainty}'));
     if (isset($args['includeEditLink']) && $args['includeEditLink'] && !empty($args['includeEditLinkPath'])) {
         $reportOptions['columns'][] = array('display' => 'Actions', 'actions' => array(array('caption' => 'edit', 'url' => url($args['includeEditLinkPath']), 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'visibility_field' => 'belongs_to_user')));
     }
     $r .= report_helper::report_grid($reportOptions);
     return $r;
 }
コード例 #21
0
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting a verification.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     global $user;
     $logged_in = $user->uid > 0;
     if (!$logged_in) {
         return '<p>' . lang::get('Please log in before attempting to use this form.') . '</p>';
     }
     // can't really do this automatically: better to give warning
     if (isset($args['locationTypeFilter'])) {
         return '<p>' . lang::get('Please contact the site administrator. This version of the form uses a different method of specifying the location types.') . '</p>';
     }
     iform_load_helpers(array('report_helper'));
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     if (!self::set_up_survey($args, $auth)) {
         return lang::get('set_up_survey returned false: survey_id missing from presets or location_type definition.');
     }
     $reportOptions = self::get_report_calendar_options($args, $auth);
     $reportOptions['id'] = 'calendar-summary-' . $node->nid;
     if (!empty($args['removable_params'])) {
         self::$removableParams = get_options_array_with_user_data($args['removable_params']);
     }
     self::copy_args($args, $reportOptions, array('weekstart', 'weekOneContains', 'weekNumberFilter', 'outputTable', 'outputChart', 'simultaneousOutput', 'tableHeaders', 'chartLabels', 'disableableSeries', 'chartType', 'rowGroupColumn', 'rowGroupID', 'width', 'height', 'includeTableTotalRow', 'includeTableTotalColumn', 'includeChartTotalSeries', 'includeChartItemSeries', 'includeRawData', 'includeSummaryData', 'includeEstimatesData', 'summaryDataCombining', 'dataRound', 'zeroPointAnchor', 'interpolation', 'firstValue', 'lastValue', 'linkURL', 'includeRawGridDownload', 'includeRawListDownload', 'includeSummaryGridDownload', 'includeEstimatesGridDownload', 'includeListDownload', 'avgFields'));
     if (isset($_GET['outputSource'])) {
         $reportOptions['outputSource'] = $_GET['outputSource'];
     }
     if (isset($_GET['outputFormat'])) {
         $reportOptions['outputFormat'] = $_GET['outputFormat'];
     } else {
         $reportOptions['outputFormat'] = $args['defaultOutput'];
     }
     if (isset($_GET['outputSeries'])) {
         $reportOptions['outputSeries'] = $_GET['outputSeries'];
     }
     // default is all
     // Advanced Chart options
     $rendererOptions = trim($args['renderer_options']);
     if (!empty($rendererOptions)) {
         $reportOptions['rendererOptions'] = json_decode($rendererOptions, true);
     }
     $legendOptions = trim($args['legend_options']);
     if (!empty($legendOptions)) {
         $reportOptions['legendOptions'] = json_decode($legendOptions, true);
     }
     $axesOptions = trim($args['axes_options']);
     if (!empty($axesOptions)) {
         $reportOptions['axesOptions'] = json_decode($axesOptions, true);
     }
     if (isset($args['countColumn']) && $args['countColumn'] != '') {
         $reportOptions['countColumn'] = 'attr_occurrence_' . str_replace(' ', '_', strtolower($args['countColumn']));
         // assume that this is an occurrence attribute.
         $reportOptions['extraParams']['occattrs'] = $args['countColumn'];
     }
     // for a normal user, we can only link to those samples we have created
     $reportOptions['location_list'] = array();
     // for a branch user, we have an allowed list of locations for which we can link to the sample.
     self::$branchLocationList = array();
     if (isset($args['branchManagerPermission']) && $args['branchManagerPermission'] != "" && user_access($args['branchManagerPermission'])) {
         // Get list of locations attached to this user via the branch cms user id attribute
         // first need to scan param_presets for survey_id..
         $attrArgs = array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth, 'survey_id' => self::$siteUrlParams[self::$SurveyKey]);
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $attrArgs['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
         }
         $locationAttributes = data_entry_helper::getAttributes($attrArgs, false);
         $cmsAttr = self::extract_attr($locationAttributes, $args['branchFilterAttribute']);
         if (!$cmsAttr) {
             return lang::get('Branch Manager location list lookup: missing Branch allocation attribute') . ' {' . print_r($attrArgs, true) . '} : ' . $args['branchFilterAttribute'];
         }
         $attrListArgs = array('extraParams' => array_merge(array('view' => 'list', 'website_id' => $args['website_id'], 'location_attribute_id' => $cmsAttr['attributeId'], 'raw_value' => $user->uid), $auth), 'table' => 'location_attribute_value');
         $attrList = data_entry_helper::get_population_data($attrListArgs);
         if (isset($attrList['error'])) {
             return $attrList['error'];
         }
         if (count($attrList) > 0) {
             foreach ($attrList as $attr) {
                 self::$branchLocationList[] = $attr['location_id'];
             }
         }
         $reportOptions['location_list'] = self::$branchLocationList;
     }
     // for an admin, we can link to all samples.
     if (isset($args['managerPermission']) && $args['managerPermission'] != "" && user_access($args['managerPermission'])) {
         $reportOptions['location_list'] = 'all';
     }
     if (function_exists('module_exists') && module_exists('easy_login') && function_exists('hostsite_get_user_field')) {
         $reportOptions['my_user_id'] = hostsite_get_user_field('indicia_user_id');
     } else {
         $reportOptions['my_user_id'] = $user->uid;
     }
     $retVal = '';
     // Add controls first: set up a control bar
     $retVal .= "\n<table id=\"controls-table\" class=\"ui-widget ui-widget-content ui-corner-all controls-table\"><thead class=\"ui-widget-header\"><tr>";
     $retVal .= self::date_control($args, $auth, $node, $reportOptions);
     $retVal .= '<th>' . self::user_control($args, $auth, $node, $reportOptions) . '</th>';
     $retVal .= '<th>' . self::location_control($args, $auth, $node, $reportOptions) . '</th>';
     // note this includes the location_type control if needed
     $siteUrlParams = self::get_site_url_params();
     if (!empty($args['removable_params'])) {
         foreach (self::$removableParams as $param => $caption) {
             $checked = isset($_GET[$param]) && $_GET[$param] === 'true' ? ' checked="checked"' : '';
             $retVal .= '<th><input type="checkbox" name="removeParam-' . $param . '" id="removeParam-' . $param . '" class="removableParam"' . $checked . '/>' . '<label for="removeParam-' . $param . '" >' . lang::get($caption) . '</label></th>';
         }
         self::set_up_control_change('removeParam-' . $param, $param, array(), true);
     }
     // are there any params that should be set to blank using one of the removable params tickboxes?
     foreach (self::$removableParams as $param => $caption) {
         if (isset($_GET[$param]) && $_GET[$param] === 'true') {
             $reportOptions['extraParams'][$param] = '';
         }
     }
     if (self::$siteUrlParams[self::$userKey]['value'] == '' && self::$siteUrlParams[self::$locationKey]['value'] == '') {
         $checked = self::$siteUrlParams[self::$cacheKey]['value'] === 'true' ? ' checked="checked"' : '';
         $retVal .= '<th><input type="checkbox" name="cachingParam" id="cachingParam" class="cachingParam"' . $checked . '/>' . '<label for="cachingParam" title="' . lang::get("When fetching the full data set, selcting this improves performance by not going to the warehouse to get the data. Occassionally, even when selected, the data will be refreshed, which will appear to slow down the response.") . '" >' . lang::get("Use cached data") . '</label></th>';
         $reportOptions['caching'] = self::$siteUrlParams[self::$cacheKey]['value'] === 'true' ? true : 'store';
         self::set_up_control_change('cachingParam', self::$cacheKey, array(), true);
         $checked = self::$siteUrlParams[self::$downloadKey]['value'] === 'true' ? ' checked="checked"' : '';
         if (self::$siteUrlParams[self::$downloadKey]['value'] !== 'true' && isset($reportOptions['includeListDownload']) && $reportOptions['includeListDownload'] == true) {
             $reportOptions['includeRawGridDownload'] = false;
             $reportOptions['includeRawListDownload'] = false;
             $reportOptions['includeSummaryGridDownload'] = false;
             $reportOptions['includeEstimatesGridDownload'] = false;
             $reportOptions['includeListDownload'] = false;
             for ($i = 1; $i <= 4; $i++) {
                 unset($args['Download' . $i . 'Caption']);
                 unset($args['download_report_' . $i]);
             }
             data_entry_helper::$javascript .= "jQuery('.downloads-table-label').remove();\n" . "jQuery('#downloads-table thead tr').prepend('<th>" . "<label for=\"downloadParam\" title=\"" . lang::get("When fetching the full data set, unselecting this improves performance by not including the download data in the page. This extra data can lead to a significantly increase in download time.") . "\" >" . lang::get("Include Downloads") . "</label>" . "<input type=\"checkbox\" name=\"downloadParam\" id=\"downloadParam\" class=\"downloadParam\"" . $checked . "/>" . "</th>');\n";
             self::set_up_control_change('downloadParam', self::$downloadKey, array(), true);
         }
     }
     if (self::$siteUrlParams[self::$locationTypeKey]['value'] == '') {
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $types = explode(',', $args['locationTypesFilter']);
             $terms = self::get_sorted_termlist_terms(array('read' => $auth), 'indicia:location_types', array($types[0]));
             $reportOptions['extraParams']['location_type_id'] = $terms[0]['id'];
         }
     } else {
         $reportOptions['extraParams']['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
     }
     $reportOptions['includeReportTimeStamp'] = isset($args['includeFilenameTimestamps']) && $args['includeFilenameTimestamps'];
     $retVal .= '</tr></thead></table>';
     $reportOptions['highlightEstimates'] = true;
     $retVal .= report_helper::report_calendar_summary($reportOptions);
     // upto this point the report options holds the cms user id as user_id: the report_helper converts this to the indicia
     // user_id if relevant to this installation. We now need to do the same for the report links.
     if (isset($reportOptions['extraParams']['user_id'])) {
         $reportOptions['extraParams']['cms_user_id'] = $reportOptions['extraParams']['user_id'];
         if (function_exists('module_exists') && module_exists('easy_login')) {
             $account = user_load($reportOptions['extraParams']['user_id']);
             if (function_exists('profile_load_profile')) {
                 profile_load_profile($account);
             }
             /* will not be invoked for Drupal7 where the fields are already in the account object */
             if (isset($account->profile_indicia_user_id)) {
                 $reportOptions['extraParams']['user_id'] = $account->profile_indicia_user_id;
             }
         }
     }
     if (isset($args['managerPermission']) && $args['managerPermission'] != "" && user_access($args['managerPermission']) || $reportOptions['extraParams']['location_list'] != '' || $reportOptions['extraParams']['user_id'] != '') {
         // if user specified - either me in normal or branch mode, or a manager
         global $indicia_templates;
         $indicia_templates['report_download_link'] = '<th><a href="{link}"><button type="button">{caption}</button></a></th>';
         // format is assumed to be CSV
         $downloadOptions = array('readAuth' => $auth, 'extraParams' => array_merge($reportOptions['extraParams'], array('date_from' => $reportOptions['date_start'], 'date_to' => $reportOptions['date_end'])), 'itemsPerPage' => false);
         // there are problems dealing with location_list as an array if empty, so connvert
         if ($downloadOptions['extraParams']['location_list'] == "") {
             $downloadOptions['extraParams']['location_list'] = "(-1)";
         } else {
             $downloadOptions['extraParams']['location_list'] = '(' . $downloadOptions['extraParams']['location_list'] . ')';
         }
         for ($i = 1; $i <= 4; $i++) {
             if (isset($args['Download' . $i . 'Caption']) && $args['Download' . $i . 'Caption'] != "" && isset($args['download_report_' . $i]) && $args['download_report_' . $i] != "") {
                 $downloadOptions['caption'] = $args['Download' . $i . 'Caption'];
                 $downloadOptions['dataSource'] = $args['download_report_' . $i];
                 $downloadOptions['filename'] = $reportOptions['downloadFilePrefix'] . preg_replace('/[^A-Za-z0-9]/i', '', $args['Download' . $i . 'Caption']);
                 $downloadOptions['filename'] .= isset($reportOptions['includeReportTimeStamp']) && $reportOptions['includeReportTimeStamp'] ? '_' . date('YmdHis') : '';
                 if (isset($args['download_report_' . $i . '_format'])) {
                     $downloadOptions['format'] = $args['download_report_' . $i . '_format'];
                 }
                 data_entry_helper::$javascript .= "\nif(jQuery('#downloads-table th').length==0)\n  jQuery('#downloads-table thead tr').append('<th class=\"downloads-table-label\">" . lang::get("Downloads") . "</th>');\njQuery('#downloads-table thead tr').append('" . report_helper::report_download_link($downloadOptions) . "');\n";
             }
         }
     }
     return $retVal;
 }
コード例 #22
0
 /**
  * Performs the download.
  * URL arguments date_from, date_to, survey_list, format, download-type
  * @global array $indicia_templates
  * @param type $args
  * @param type $node
  */
 private static function do_data_services_download($args, $node)
 {
     iform_load_helpers(array('report_helper'));
     // default data format JSON
     if (!array_key_exists('format', $_GET)) {
         $_GET['format'] = 'json';
     }
     $format = $_GET['format'];
     // download type set to Reporting by default
     if (!array_key_exists('download-type', $_GET)) {
         $_GET['download-type'] = 'R';
     }
     $isCustom = preg_match('/^custom-(\\d+)$/', $_GET['format'], $matches);
     if ($isCustom) {
         $customFormats = json_decode($args['custom_formats'], true);
         $customFormat = $customFormats[$matches[1]];
         $report = $customFormat['report'];
         // strip unnecessary .xml from end of report name if provided
         $report = preg_replace('/\\.xml$/', '', $report);
         $format = $customFormat['format'];
         $additionalParamText = $customFormat['params'];
     } else {
         if ($format == 'json') {
             $report = $args["report_csv"];
             $additionalParamText = $args["report_params_csv"];
         } else {
             $report = $args["report_{$format}"];
             $additionalParamText = $args["report_params_{$format}"];
         }
     }
     //Getting the form params first and then allowing the user to
     //overwrite then through $args
     require_once 'includes/user.php';
     $params = get_options_array_with_user_data($additionalParamText);
     $params = array_merge($params, self::build_params($args));
     $conn = iform_get_connection_details($node);
     global $indicia_templates;
     // let's just get the URL, not the whole anchor element
     $indicia_templates['report_download_link'] = '{link}';
     $limit = $args['limit'] == 0 ? '' : $args['limit'];
     // unlimited or limited
     $sharing = substr($_GET['download-type'], 0, 1);
     $url = report_helper::report_download_link(array('readAuth' => data_entry_helper::$js_read_tokens, 'dataSource' => $report, 'extraParams' => $params, 'format' => $format, 'sharing' => self::expand_sharing_mode($sharing), 'itemsPerPage' => $limit));
     header("Location: {$url}");
 }
コード例 #23
0
 /**
  * Additional functionality required to load habitat data for existing samples.
  * @param integer $sample_id ID of the parent sample being loaded
  * @param array $auth Authorisation tokens
  */
 protected static function load_existing($sample_id, $auth)
 {
     iform_load_helpers(array('report_helper'));
     $samples = report_helper::get_report_data(array('dataSource' => 'library/samples/subsamples', 'readAuth' => $auth['read'], 'extraParams' => array('parent_sample_id' => $sample_id)));
     foreach ($samples as $sample) {
         self::$existingSubsampleData['sample:' . $sample['id']] = array('sample_id' => $sample['id'], 'comment' => $sample['comment'], 'values' => array());
     }
     $values = report_helper::get_report_data(array('dataSource' => 'library/sample_attribute_values/subsample_attribute_values', 'readAuth' => $auth['read'], 'extraParams' => array('parent_sample_id' => $sample_id)));
     foreach ($values as $idx => $value) {
         self::$existingSubsampleData['sample:' . $value['sample_id']]['values']["{$idx}:{$value['sample_attribute_id']}"] = "{$value['id']}:{$value['value']}:{$value['data_type']}";
     }
     data_entry_helper::$javascript .= "indiciaData.existingSubsampleData=" . json_encode(array_values(self::$existingSubsampleData)) . ";\n";
 }
コード例 #24
0
 /**
  * Return the Indicia form code
  * @param array $args Input parameters.
  * @param array $node Drupal node object
  * @param array $response Response from Indicia services after posting a verification.
  * @return HTML string
  */
 public static function get_form($args, $node, $response)
 {
     global $user;
     $retVal = '';
     $logged_in = $user->uid > 0;
     if (!$logged_in) {
         return '<p>' . lang::get('Please log in before attempting to use this form.') . '</p>';
     }
     // can't really do this automatically: better to give warning
     if (isset($args['locationTypeFilter'])) {
         return '<p>' . lang::get('Please contact the site administrator. This version of the form uses a different method of specifying the location types.') . '</p>';
     }
     iform_load_helpers(array('report_helper'));
     $auth = report_helper::get_read_auth($args['website_id'], $args['password']);
     if (!self::set_up_survey($args, $auth)) {
         return lang::get('set_up_survey returned false: survey_id missing from presets or location_type definition.');
     }
     $reportOptions = self::get_report_calendar_2_options($args, $auth);
     $reportOptions['id'] = 'calendar-summary-' . $node->nid;
     if (!empty($args['removable_params'])) {
         self::$removableParams = get_options_array_with_user_data($args['removable_params']);
     }
     self::copy_args($args, $reportOptions, array('weekstart', 'weekOneContains', 'weekNumberFilter', 'outputTable', 'outputChart', 'tableHeaders', 'chartLabels', 'disableableSeries', 'chartType', 'rowGroupColumn', 'rowGroupID', 'width', 'height', 'includeChartTotalSeries', 'includeChartItemSeries', 'includeRawData', 'includeSummaryData', 'includeEstimatesData', 'includeRawGridDownload', 'includeSummaryGridDownload', 'includeEstimatesGridDownload', 'sampleFields'));
     if (isset($_GET['outputSeries'])) {
         $reportOptions['outputSeries'] = $_GET['outputSeries'];
     }
     // default is all
     // Advanced Chart options
     $rendererOptions = trim($args['renderer_options']);
     if (!empty($rendererOptions)) {
         $reportOptions['rendererOptions'] = json_decode($rendererOptions, true);
     }
     $axesOptions = trim($args['axes_options']);
     if (!empty($axesOptions)) {
         $reportOptions['axesOptions'] = json_decode($axesOptions, true);
     }
     if (isset($args['countColumn']) && $args['countColumn'] != '') {
         $reportOptions['countColumn'] = 'attr_occurrence_' . str_replace(' ', '_', strtolower($args['countColumn']));
         // assume that this is an occurrence attribute.
         $reportOptions['extraParams']['occattrs'] = $args['countColumn'];
     }
     // for a normal user, we can only link to those samples we have created
     $reportOptions['location_list'] = array();
     // for a branch user, we have an allowed list of locations for which we can link to the sample.
     self::$branchLocationList = array();
     if (isset($args['branch_manager_permission']) && $args['branch_manager_permission'] != "" && user_access($args['branch_manager_permission'])) {
         // Get list of locations attached to this user via the branch cms user id attribute
         // first need to scan param_presets for survey_id..
         $attrArgs = array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth, 'survey_id' => self::$siteUrlParams[self::$SurveyKey]);
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $attrArgs['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
         }
         $locationAttributes = data_entry_helper::getAttributes($attrArgs, false);
         $cmsAttr = self::extract_attr($locationAttributes, $args['branchFilterAttribute']);
         if (!$cmsAttr) {
             return lang::get('Branch Manager location list lookup: missing Branch allocation attribute') . ' {' . print_r($attrArgs, true) . '} : ' . $args['branchFilterAttribute'];
         }
         $attrListArgs = array('extraParams' => array_merge(array('view' => 'list', 'website_id' => $args['website_id'], 'location_attribute_id' => $cmsAttr['attributeId'], 'raw_value' => $user->uid), $auth), 'table' => 'location_attribute_value');
         $attrList = data_entry_helper::get_population_data($attrListArgs);
         if (isset($attrList['error'])) {
             return $attrList['error'];
         }
         if (count($attrList) > 0) {
             foreach ($attrList as $attr) {
                 self::$branchLocationList[] = $attr['location_id'];
             }
         }
         $reportOptions['location_list'] = self::$branchLocationList;
     }
     // for an admin, we can link to all samples.
     if (isset($args['manager_permission']) && $args['manager_permission'] != "" && user_access($args['manager_permission'])) {
         $reportOptions['location_list'] = 'all';
     }
     // Add controls first: set up a control bar
     $retVal .= "\n<table id=\"controls-table\" class=\"ui-widget ui-widget-content ui-corner-all controls-table\"><thead class=\"ui-widget-header\"><tr>";
     $retVal .= self::year_control($args, $auth, $node, $reportOptions);
     $retVal .= '<th>' . self::user_control($args, $auth, $node, $reportOptions) . '</th>';
     $retVal .= '<th>' . self::location_control($args, $auth, $node, $reportOptions) . '</th>';
     // note this includes the location_type control if needed
     $siteUrlParams = self::get_site_url_params();
     if (!empty($args['removable_params'])) {
         foreach (self::$removableParams as $param => $caption) {
             $checked = isset($_GET[$param]) && $_GET[$param] === 'true' ? ' checked="checked"' : '';
             $retVal .= '<th><input type="checkbox" name="removeParam-' . $param . '" id="removeParam-' . $param . '" class="removableParam"' . $checked . '/>' . '<label for="removeParam-' . $param . '" >' . lang::get($caption) . '</label></th>';
             if ($checked != '') {
                 $reportOptions['downloadFilePrefix'] .= 'RM' . preg_replace('/[^A-Za-z0-9]/i', '', $param) . '_';
             }
         }
         self::set_up_control_change('removeParam-' . $param, $param, array(), true);
     }
     // are there any params that should be set to blank using one of the removable params tickboxes?
     foreach (self::$removableParams as $param => $caption) {
         if (isset($_GET[$param]) && $_GET[$param] === 'true') {
             $reportOptions[$param] = '';
             $reportOptions['extraParams'][$param] = '';
         }
     }
     if (self::$siteUrlParams[self::$locationTypeKey]['value'] == '') {
         if (isset($args['locationTypesFilter']) && $args['locationTypesFilter'] != "") {
             $types = explode(',', $args['locationTypesFilter']);
             $terms = self::get_sorted_termlist_terms(array('read' => $auth), 'indicia:location_types', array($types[0]));
             $reportOptions['extraParams']['location_type_id'] = $terms[0]['id'];
         }
     } else {
         $reportOptions['extraParams']['location_type_id'] = self::$siteUrlParams[self::$locationTypeKey]['value'];
     }
     if (isset($args['linkURL'])) {
         $reportOptions['linkURL'] = $args['linkURL'] . (isset($siteUrlParams[self::$URLExtensionKey]) ? $siteUrlParams[self::$URLExtensionKey] : '');
         $reportOptions['linkURL'] .= (strpos($reportOptions['linkURL'], '?') !== FALSE ? '&' : '?') . 'sample_id=';
     }
     $reportOptions['includeReportTimeStamp'] = isset($args['includeFilenameTimestamps']) && $args['includeFilenameTimestamps'];
     $retVal .= '</tr></thead></table>';
     $reportOptions['survey_id'] = self::$siteUrlParams[self::$SurveyKey];
     // Sort of assuming that only one location type recorded against per survey.
     $reportOptions['downloads'] = array();
     if (isset($args['manager_permission']) && $args['manager_permission'] != "" && user_access($args['manager_permission']) || $reportOptions['extraParams']['location_list'] != '' || $reportOptions['extraParams']['user_id'] != '') {
         // if user specified - either me in normal or branch mode, or a manager
         for ($i = 1; $i <= 4; $i++) {
             if (isset($args['Download' . $i . 'Caption']) && $args['Download' . $i . 'Caption'] != "" && isset($args['download_report_' . $i]) && $args['download_report_' . $i] != "") {
                 $reportOpts = array('caption' => $args['Download' . $i . 'Caption'], 'dataSource' => $args['download_report_' . $i], 'filename' => $reportOptions['downloadFilePrefix'] . preg_replace('/[^A-Za-z0-9]/i', '', $args['Download' . $i . 'Caption']) . (isset($reportOptions['includeReportTimeStamp']) && $reportOptions['includeReportTimeStamp'] ? '_' . date('YmdHis') : ''));
                 if (isset($args['download_report_' . $i . '_format'])) {
                     $reportOpts['format'] = $args['download_report_' . $i . '_format'];
                 }
                 $reportOptions['downloads'][] = $reportOpts;
             }
         }
     } else {
         $reportOptions['includeRawGridDownload'] = false;
     }
     $retVal .= report_helper::report_calendar_summary2($reportOptions);
     return $retVal;
 }
コード例 #25
0
 /**
  * Loads the record associated with the page if not already loaded.
  */
 protected static function load_record($auth)
 {
     if (!isset(self::$record)) {
         $records = report_helper::get_report_data(array('readAuth' => $auth['read'], 'dataSource' => 'reports_for_prebuilt_forms/record_details_2/record_data', 'extraParams' => array('occurrence_id' => $_GET['occurrence_id'], 'sharing' => 'reporting')));
         self::$record = $records[0];
     }
 }
コード例 #26
0
 /**
  * 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.
  */
 public static function get_form($args, $node, $response = null)
 {
     global $indicia_templates;
     iform_load_helpers(array('map_helper', 'report_helper'));
     // apply defaults
     $args = array_merge(array(), $args);
     $reloadPath = self::getReloadPath();
     data_entry_helper::$website_id = $args['website_id'];
     $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
     if (!empty($_GET['user_trust_id'])) {
         self::loadExistingUserTrust($_GET['user_trust_id'], $auth, $args);
     }
     $r = "<form method=\"post\" id=\"entry_form\" action=\"{$reloadPath}\">\n";
     $r .= $auth['write'] . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
     $r .= data_entry_helper::hidden_text(array('fieldname' => 'user_trust:id'));
     $r .= data_entry_helper::autocomplete(array('label' => lang::get('Recorder to trust'), 'fieldname' => 'user_trust:user_id', 'table' => 'user', 'valueField' => 'id', 'captionField' => 'person_name', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'class' => 'control-width-4'));
     $col1 = '<p>Define the combination of survey, taxon group and/or location that this recorder is trusted for below.</p>';
     $col1 .= '<fieldset><legend>' . lang::get('Trust settings') . '</legend>';
     $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this survey'), 'fieldname' => 'user_trust:survey_id', 'table' => 'survey', 'valueField' => 'id', 'captionField' => 'title', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'] + array('sharing' => 'verification'), 'class' => 'control-width-4'));
     $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this taxon group'), 'fieldname' => 'user_trust:taxon_group_id', 'table' => 'taxon_group', 'valueField' => 'id', 'captionField' => 'title', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'], 'class' => 'control-width-4'));
     $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this location'), 'fieldname' => 'user_trust:location_id', 'table' => 'location', 'valueField' => 'id', 'captionField' => 'name', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'] + array('location_type_id' => variable_get('indicia_profile_location_type_id', '')), 'class' => 'control-width-4'));
     $col2 = '<p>' . lang::get('Review this recorder\'s experience in the tabs below') . '</p>';
     $col2 .= '<div id="summary-tabs">';
     $col2 .= data_entry_helper::tab_header(array('tabs' => array('#tab-surveys' => lang::get('Surveys'), '#tab-taxon-groups' => lang::get('Taxon groups'), '#tab-locations' => lang::get('Locations'))));
     data_entry_helper::enable_tabs(array('divId' => 'summary-tabs'));
     $col2 .= '<div id="tab-surveys">';
     $col2 .= report_helper::report_grid(array('id' => 'surveys-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/surveys/filterable_surveys_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1)));
     $col2 .= '</div>';
     $col2 .= '<div id="tab-taxon-groups">';
     $col2 .= report_helper::report_grid(array('id' => 'taxon-groups-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/taxon_groups/filterable_taxon_groups_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1)));
     $col2 .= '</div>';
     $col2 .= '<div id="tab-locations">';
     $col2 .= report_helper::report_grid(array('id' => 'locations-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/locations/filterable_locations_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1, 'location_type_id' => variable_get('indicia_profile_location_type_id', ''))));
     $col2 .= '</div>';
     $col2 .= '</div>';
     $r .= str_replace(array('{col-1}', '{col-2}'), array($col1, $col2), $indicia_templates['two-col-50']);
     $r .= '</fieldset>';
     $r .= '<input type="submit" class="indicia-button" id="save-button" value="' . (empty(data_entry_helper::$entity_to_load['user_trust_id:id']) ? lang::get('Grant trust') : lang::get('Update trust settings')) . "\" />\n";
     if (!empty($_GET['user_trust_id'])) {
         $r .= '<input type="submit" class="indicia-button" id="delete-button" name="delete-button" value="' . lang::get('Revoke this trust') . "\" />\n";
         data_entry_helper::$javascript .= "\$('#delete-button').click(function(e) {\n        if (!confirm(\"Are you sure you want to revoke this trust?\")) {\n          e.preventDefault();\n          return false;\n        }\n      });\n";
     }
     $r .= '</form>';
     data_entry_helper::enable_validation('entry_form');
     return $r;
 }
コード例 #27
0
 /**
  * Ajax method to retrieve phenology data for a species by external key.
  */
 public static function ajax_phenology($website_id, $password)
 {
     iform_load_helpers(array('report_helper'));
     $readAuth = report_helper::get_read_auth($website_id, $password);
     $extraParams = array('external_key' => empty($_GET['external_key']) || $_GET['external_key'] === 'null' ? '' : $_GET['external_key'], 'taxon_meaning_id' => empty($_GET['external_key']) || $_GET['external_key'] === 'null' ? $_GET['taxon_meaning_id'] : '', 'date_from' => '', 'date_to' => '', 'survey_id' => '', 'quality' => 'V');
     $data = report_helper::get_report_data(array('dataSource' => 'library/months/phenology', 'readAuth' => $readAuth, 'extraParams' => $extraParams, 'sharing' => 'verification'));
     // must output all months
     $output = array(array(1, 0), array(2, 0), array(3, 0), array(4, 0), array(5, 0), array(6, 0), array(7, 0), array(8, 0), array(9, 0), array(10, 0), array(11, 0), array(12, 0));
     foreach ($data as $month) {
         // -1 here, because our array is zero indexed, but the report returns a real month number
         $output[$month['name'] - 1][1] = intval($month['value']);
     }
     echo json_encode($output);
 }
コード例 #28
0
 protected static function getAnnotationsList($args, $locationId, $auth)
 {
     iform_load_helpers(array('report_helper'));
     $extraParams = array('count_unit_id' => $locationId, 'count_unit_boundary_location_type_id' => $args['count_unit_boundary_location_type_id']);
     $optionsForAnnotationsReport = array('dataSource' => 'reports_for_prebuilt_forms/CUDI/get_count_unit_annotations', 'readAuth' => $auth['read'], 'extraParams' => $extraParams);
     //Get the report options such as the Preset Parameters on the Edit Tab
     $optionsForAnnotationsReport = array_merge(iform_report_get_report_options($args, $readAuth), $optionsForAnnotationsReport);
     //Collect the annotations from a report.
     $annotations = report_helper::get_report_data($optionsForAnnotationsReport);
     return $annotations;
 }
コード例 #29
0
 private static function do_data_services_download($args, $format)
 {
     iform_load_helpers(array('report_helper'));
     $conn = iform_get_connection_details($node);
     $readAuth = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
     if (preg_match('/^library\\/occurrences\\/filterable/', $args["report_{$format}"])) {
         $filter = self::build_filter($args, $readAuth, $format, true);
     } else {
         $filter = self::build_filter($args, $readAuth, $format, false);
     }
     global $indicia_templates;
     // let's just get the URL, not the whole anchor element
     $indicia_templates['report_download_link'] = '{link}';
     $limit = $args['limit'] == 0 ? '' : $args['limit'];
     // unlimited or limited
     $sharing = preg_match('/^expert/', $_POST['user-filter']) ? 'verification' : 'data_flow';
     $url = report_helper::report_download_link(array('readAuth' => $readAuth, 'dataSource' => $args["report_{$format}"], 'extraParams' => $filter, 'format' => $format, 'sharing' => $sharing, 'itemsPerPage' => $limit));
     header("Location: {$url}");
 }
コード例 #30
0
 protected static function get_control_reportchartparams($auth, $args, $tabalias, $options)
 {
     if (!isset($options['yValues']) || !isset($options['dataSource']) || !isset($options['chartType'])) {
         $r = '<h4>Please fill in the following options for the chart parameters control: yValues, dataSource, chartType</h4>';
         return $r;
     }
     iform_load_helpers(array('report_helper'));
     $sharing = empty($args['sharing']) ? 'reporting' : $args['sharing'];
     $args['report_name'] = '';
     $options = array_merge(iform_report_get_report_options($args, $auth), $options, array('reportGroup' => 'dynamic', 'paramsOnly' => true, 'sharing' => $sharing, 'paramsFormButtonCaption' => lang::get('Filter'), 'yValues' => explode(',', $options['yValues']), 'readAuth' => $auth['read'], 'dataSource' => $options['dataSource']));
     $r = '<br/>' . report_helper::report_chart($options);
     return $r;
 }