Esempio n. 1
0
 /**
  * Returns controls allowing a records filter to be defined and associated with the group. 
  * @param array $args Form configuration arguments
  * @return string HTML to output
  */
 private static function reportFilterBlock($args, $auth, &$hiddenPopupDivs)
 {
     $r = '';
     $hiddenPopupDivs = '';
     if ($args['include_report_filter']) {
         $r .= '<fieldset><legend>' . lang::get('Records that are of interest to the {1}', lang::get(self::$groupType)) . '</legend>';
         $r .= '<p>' . lang::get('LANG_Filter_Instruct', lang::get(self::$groupType), lang::get("group's")) . '</p>';
         $indexedLocationTypeIds = explode(',', $args['indexed_location_type_ids']);
         $otherLocationTypeIds = explode(',', $args['other_location_type_ids']);
         $r .= report_filter_panel($auth['read'], array('allowLoad' => false, 'allowSave' => false, 'filterTypes' => $args['filter_types'], 'embedInExistingForm' => true, 'indexedLocationTypeIds' => $indexedLocationTypeIds, 'otherLocationTypeIds' => $otherLocationTypeIds), $args['website_id'], $hiddenPopupDivs);
         // fields to auto-create a filter record for this group's defined set of records
         $r .= data_entry_helper::hidden_text(array('fieldname' => 'filter:id'));
         $r .= '<input type="hidden" name="filter:title" id="filter-title-val"/>';
         $r .= '<input type="hidden" name="filter:definition" id="filter-def-val"/>';
         $r .= '<input type="hidden" name="filter:sharing" value="R"/>';
         $r .= '</fieldset>';
     }
     return $r;
 }
 private static function report_filter_panel($args, $readAuth)
 {
     $options = array('allowSave' => true, 'sharing' => 'verification', 'linkToMapDiv' => 'map', 'filter-quality' => 'P');
     if (!function_exists('iform_ajaxproxy_url')) {
         return 'The AJAX Proxy module must be enabled to support saving filters.';
     }
     if (!function_exists('hostsite_get_user_field') || !hostsite_get_user_field('indicia_user_id')) {
         return 'The verification_4 form requires Easy Login.';
     }
     $r = report_filter_panel($readAuth, $options, $args['website_id'], $hiddenStuff);
     return $r . $hiddenStuff;
 }
 protected static function get_control_standardparams($auth, $args, $tabalias, $options)
 {
     self::$applyUserPrefs = false;
     $options = array_merge(array('allowSave' => true, 'sharing' => empty($args['sharing']) ? 'reporting' : $args['sharing']), $options);
     if ($args['redirect_on_success']) {
         $options['redirect_on_success'] = url($args['redirect_on_success']);
     }
     // any preset params on the report page should be loaded as initial settings for the filter.
     if (!empty($args['param_presets'])) {
         $params = data_entry_helper::explode_lines_key_value_pairs($args['param_presets']);
         foreach ($params as $key => $val) {
             $options["filter-{$key}"] = $val;
         }
     }
     foreach ($options as $key => &$value) {
         $value = apply_user_replacements($value);
     }
     if ($options['allowSave'] && !function_exists('iform_ajaxproxy_url')) {
         return 'The AJAX Proxy module must be enabled to support saving filters. Set @allowSave=false to disable this in the [standard params] control.';
     }
     if (!function_exists('hostsite_get_user_field') || !hostsite_get_user_field('indicia_user_id')) {
         return 'The standard params module requires Easy Login.';
     }
     $r = report_filter_panel($auth['read'], $options, $args['website_id'], $hiddenStuff);
     return $r . $hiddenStuff;
 }
//first. The filter requires a unique title/sharing/created_by_id option that isn't included in the model, the issue is only
//detected once the system tries to add the filter to the database, this will fail with a general error without even getting as far as doing the milestone model's
//title duplciate detection.
//So to fix this, collect the existing filters from the database so we can compare the titles with the one we create and then
//do the validation manually.
$readAuth = data_entry_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key'));
$existingFilterData = data_entry_helper::get_population_data(array('table' => 'filter', 'extraParams' => $readAuth, 'nocache' => true));
//When we save a milestone when we need to automatically set the filter title as there isn't a separate field
//to fill this in.
//Also hide the "who" filter as we don't need this for milestones as they can apply to all users
//Also manually do the unique milestone/filter title validation (see note above)
data_entry_helper::$javascript .= "\nvar existingFilterData=" . json_encode($existingFilterData) . ";  \n\$('#pane-filter_who').hide();\n\$('#milestones-form').submit(function() {\n  \$('#filter-title-val').val('" . 'Filter for milestone' . " ' + \$('#milestone\\\\:title').val());\n  for (var i = 0; i<existingFilterData.length;i++) {\n    //Note we must allow a duplicate title in the situaton where the duplicate title is for the already existing item\n    if (existingFilterData[i]['title']==\$('#filter-title-val').val() && existingFilterData[i]['id']!=\$('#filter\\\\:id').val()) {\n      alert('The filter title is generated from the milestone title you have entered and would cause a duplicate filter title, please choose a different title');\n      return false;\n    }\n  }\n  \$('#filter-def-val').val(JSON.stringify(indiciaData.filter.def));\n});\n";
$readAuth = data_entry_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key'));
$filterPanelHTML = '<h3>Specify the filter used to define which records count</h3>';
$hiddenPopupDivs = '';
$filterPanelHTML .= report_filter_panel($readAuth, array('allowLoad' => false, 'allowSave' => false, 'embedInExistingForm' => true, 'runningOnWarehouse' => true, 'taxon_list_id' => kohana::config('cache_builder_variables.master_list_id'), 'website_id' => html::initial_value($values, 'milestone:website_id') ? html::initial_value($values, 'milestone:website_id') : $values['website_id']), $this->uri->argument(1), $hiddenStuff);
// fields to auto-create a filter record for this group's defined set of records
$filterPanelHTML .= data_entry_helper::hidden_text(array('fieldname' => 'filter:id', 'default' => html::initial_value($values, 'filter:id')));
$filterPanelHTML .= '<input type="hidden" name="filter:title" id="filter-title-val"/>';
$filterPanelHTML .= '<input type="hidden" name="filter:definition" id="filter-def-val"/>';
$filterPanelHTML .= '<input type="hidden" name="filter:sharing" value="R"/>';
echo $filterPanelHTML;
echo html::form_buttons(html::initial_value($values, 'milestone:id') != null, false, false);
data_entry_helper::$dumped_resources[] = 'jquery';
data_entry_helper::$dumped_resources[] = 'jquery_ui';
data_entry_helper::$dumped_resources[] = 'fancybox';
data_entry_helper::enable_validation('milestones-form');
data_entry_helper::link_default_stylesheet();
echo data_entry_helper::dump_javascript();
?>
</fieldset>
 private static function report_filter_panel($args, $readAuth)
 {
     $options = array('allowSave' => true, 'sharing' => 'verification', 'linkToMapDiv' => 'map', 'filter-quality' => 'P', 'entity' => 'sample');
     if (!empty($args['indexed_location_type_ids'])) {
         $options['indexedLocationTypeIds'] = array_map('intval', explode(',', $args['indexed_location_type_ids']));
     }
     if (!empty($args['other_location_type_ids'])) {
         $options['otherLocationTypeIds'] = array_map('intval', explode(',', $args['other_location_type_ids']));
     }
     $r = report_filter_panel($readAuth, $options, $args['website_id'], $hiddenStuff);
     return $r . $hiddenStuff;
 }
Esempio n. 6
0
 /**
  * Returns controls allowing a records filter to be defined and associated with the group. 
  * @param array $args Form configuration arguments
  * @return string HTML to output
  */
 private static function reportFilterBlock($args, $auth, &$hiddenPopupDivs)
 {
     $r = '';
     $hiddenPopupDivs = '';
     if ($args['include_report_filter']) {
         $r .= '<p>' . lang::get('LANG_Filter_Instruct') . '</p>';
         $r .= '<label>' . lang::get(ucfirst(self::$groupType) . ' parameters') . ':</label>';
         $r .= report_filter_panel($auth['read'], array('allowLoad' => false, 'allowSave' => false, 'filterTypes' => $args['filter_types'], 'embedInExistingForm' => true), $args['website_id'], $hiddenPopupDivs);
         // fields to auto-create a filter record for this group's defined set of records
         $r .= data_entry_helper::hidden_text(array('fieldname' => 'filter:id'));
         $r .= '<input type="hidden" name="filter:title" id="filter-title-val"/>';
         $r .= '<input type="hidden" name="filter:definition" id="filter-def-val"/>';
         $r .= '<input type="hidden" name="filter:sharing" value="R"/>';
     }
     return $r;
 }
 private static function report_filter_panel($args, $readAuth)
 {
     $options = array('allowSave' => true, 'sharing' => 'verification', 'linkToMapDiv' => 'map', 'filter-quality' => 'P');
     $r = report_filter_panel($readAuth, $options, $args['website_id'], $hiddenStuff);
     return $r . $hiddenStuff;
 }