Beispiel #1
0
 public static function get_parameters()
 {
     $parentVal = parent::get_parameters();
     $retVal = array();
     foreach ($parentVal as $param) {
         if ($param['name'] == 'structure') {
             $param['default'] = "=Site=\r\n" . "[custom JS]\r\n" . "[location module]\r\n" . "[location attributes]\r\n" . "@lookUpListCtrl=radio_group\r\n" . "@lookUpKey=meaning_id\r\n" . "@sep= \r\n" . "@tabNameFilter=Site\r\n" . "[location spatial reference]\r\n" . "[location attributes]\r\n" . "@tabNameFilter=SpatialRef\r\n" . "[place search]\r\n" . "[map]\r\n" . "@scroll_wheel_zoom=false\r\n" . "@searchUpdatesSref=true\r\n" . "[location comment]\r\n" . "[*]\r\n" . "=Other Information=\r\n" . "[date]\r\n" . "[recorder names]\r\n" . "[*]\r\n" . "@sep= \r\n" . "@lookUpKey=meaning_id\r\n" . "[sample comment]\r\n" . "=Species=\r\n" . "[species]\r\n" . "@view=detail\r\n" . "@rowInclusionCheck=alwaysRemovable\r\n" . "[species attributes]\r\n" . "[*]\r\n";
         }
         if ($param['name'] == 'attribute_termlist_language_filter') {
             $param['default'] = true;
         }
         if ($param['name'] == 'grid_report') {
             $param['default'] = 'reports_for_prebuilt_forms/mnhnl_bats_grid';
         }
         if ($param['name'] != 'species_include_taxon_group' && $param['name'] != 'link_species_popups' && $param['name'] != 'species_include_both_names') {
             $retVal[] = $param;
         }
     }
     $retVal[] = array('name' => 'siteTypeOtherTermID', 'caption' => 'Site Type Attribute, Other Term ID', 'description' => 'The site type has an Other choice which when selected allows an additional text field to be filled in. This field holds the Indicia term meaning id for the radiobutton.', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'siteTypeOtherAttrID', 'caption' => 'Site Type Other Attribute ID', 'description' => 'The site type has an Other choice which when selected allows an additional text field to be filled in. This field holds the text field Indicia attribute id', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'entranceDefectiveTermID', 'caption' => 'Entrance hole Attribute, Defective Term ID', 'description' => 'The Entrance hole attribute has a Defective choice which when selected allows an additional text field to be filled in. This field holds the Indicia term meaning id for the checkbox.', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'entranceDefectiveCommentAttrID', 'caption' => 'Defective Entrance Comment Attribute ID', 'description' => 'The Entrance hole attribute has a Defective choice which when selected allows an additional text field to be filled in. This field holds the text field Indicia attribute id', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'disturbanceOtherTermID', 'caption' => 'Entrance hole Attribute, Defective Term ID', 'description' => 'The Disturbances attribute has an Other choice which when selected allows an additional text field to be filled in. This field holds the Indicia term meaning id for the checkbox.', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'disturbanceCommentAttrID', 'caption' => 'Disturbance Other Comment Attribute ID', 'description' => 'The Disturbances attribute has an Other choice which when selected allows an additional text field to be filled in. This field holds the text field Indicia attribute id', 'type' => 'int', 'group' => 'User Interface');
     $retVal[] = array('name' => 'removeBreakIDs', 'caption' => 'Attributes to remove the break after', 'description' => 'The Attributes to remove the break after. This text field holds a colon separated list of Indicia attribute ids', 'type' => 'string', 'group' => 'User Interface');
     $retVal[] = array('name' => 'attributeValidation', 'caption' => 'Attribute Validation Rules', 'description' => 'Client Validation rules to be enforced on attributes: allows more options than allowed by straight class led validation.', 'type' => 'textarea', 'required' => false, 'group' => 'User Interface');
     return $retVal;
 }
 /**
  * Get the list of parameters for this form.
  * @return array List of parameters that this form requires.
  */
 public static function get_parameters()
 {
     $parentVal = parent::get_parameters();
     $retVal = array();
     foreach ($parentVal as $param) {
         if ($param['name'] == 'grid_report') {
             $param['description'] = 'Name of the report to use to populate the grid for selecting existing data from. The report must return a sample_id ' . 'field for linking to the data entry form.';
             $param['default'] = 'reports_for_prebuilt_forms/mnhnl_dynamic_2_supersamples';
         }
         if ($param['name'] != 'structure' && $param['name'] != 'includeLocTools' && $param['name'] != 'no_grid') {
             $retVal[] = $param;
         }
     }
     $retVal = array_merge($retVal, array(array('name' => 'grid_rows', 'caption' => 'Number of Rows display in supersample grid', 'description' => 'Number of Rows display in supersample grid at one time.', 'type' => 'int', 'default' => 12, 'group' => 'User Interface'), array('name' => 'supersample_structure', 'caption' => 'Form Structure for supersample', 'description' => 'Define the structure of the supersample form. Each component goes on a new line and is nested inside the previous component where appropriate. The following types of ' . "component can be specified. <br/>" . "<strong>=tab name=</strong> is used to specify the name of a tab. (Alpha-numeric characters only)<br/>" . "<strong>[control name]</strong> indicates a predefined control is to be added to the form with the following predefined controls available: <br/>" . "&nbsp;&nbsp;<strong>[date]</strong><br/>" . "&nbsp;&nbsp;<strong>[map]</strong> - if you wish to see the subsamples associated with this supersample, add the option @layers=[\"SSLayer\"] to the following line<br/>" . "&nbsp;&nbsp;<strong>[spatial reference]</strong><br/>" . "&nbsp;&nbsp;<strong>[location name]</strong><br/>" . "&nbsp;&nbsp;<strong>[location autocomplete]</strong><br/>" . "&nbsp;&nbsp;<strong>[location select]</strong><br/>" . "&nbsp;&nbsp;<strong>[place search]</strong><br/>" . "&nbsp;&nbsp;<strong>[recorder names]</strong><br/>" . "&nbsp;&nbsp;<strong>[sample comment]</strong>. <br/>" . "&nbsp;&nbsp;<strong>[sub sample grid]</strong>. This requires the following options (see below): (1) grid_report - Name of the report to use to populate the grid for selecting existing data from; and (2) grid_rows - the number of rows to be displayed in a single page of the grid. The report must take a parent_id, and return a sample id field for linking to the data entry form.<br/>" . "<strong>@option=value</strong> on the line(s) following any control allows you to override (or set) one of the options passed to the control. The options " . "available depend on the control. For example @label=Abundance would set the untranslated label of a control to Abundance. Where the " . "option value is an array, use valid JSON to encode the value. For example an array of strings could be passed as @occAttrClasses=[\"class1\",\"class2\"]. " . "Other common options include helpText (set to a piece of additional text to display alongside the control) and class (to add css " . "classes to the control such as control-width-3). <br/>" . "<strong>[*]</strong> is used to make a placeholder for putting any custom attributes that should be inserted into the current tab.<br/>" . "<strong>?help text?</strong> is used to define help text to add to the tab, e.g. ?Enter the name of the site.?<br/><br/>" . "The <strong>=*=</strong> placeholder is not valid for this form.", 'type' => 'textarea', 'default' => "=Place=\r\n" . "?Please provide the spatial reference of the record. You can enter the reference directly, or search for a place then click on the map.?\r\n" . "[place search]\r\n" . "[spatial reference]\r\n" . "[map]\r\n" . "@layers=[\"SSLayer\"]\r\n" . "[*]\r\n" . "=Other Information=\r\n" . "?Please provide the following additional information.?\r\n" . "[date]\r\n" . "[sample comment]\r\n" . "[*]\r\n" . "=Occurrences=\r\n" . "?Please enter subsample and occurrence data. If you have made any changes to the supersample record, save those first, as they will be lost otherwise when you either add a new or edit an existing subsample.?\r\n" . "[sub sample grid]\r\n" . "@grid_report=reports_for_prebuilt_forms/mnhnl_dynamic_2_subsamples\r\n" . "@grid_rows=15\r\n" . "[*]\r\n", 'group' => 'User Interface'), array('name' => 'occurrence_structure', 'caption' => 'Form Structure for sample/occurrence pair', 'description' => 'Define the structure of the sample/occurrence form. Each component goes on a new line and is nested inside the previous component where appropriate. The following types of ' . "component can be specified, in addition to those given under the Form Structure for supersample. <br/>" . "<strong>[control name]</strong>: the following additional controls may be used: <br/>" . "&nbsp;&nbsp;<strong>[map]</strong> - if you wish to see the supersample associated with this subsample, add the option @layers=[\"SSLayer\"] to the following line<br/>" . "&nbsp;&nbsp;<strong>[species]</strong> - a species grid or input control<br/>" . "&nbsp;&nbsp;<strong>[species_attributes]</strong> - any custom attributes for the occurrence, if not using the grid<br/>" . "&nbsp;&nbsp;<strong>[record status]</strong><br/>" . "Some controls don't make sense being used in this context of this part of the form, though they are available: these include <strong>[location name]</strong>, <strong>[location autocomplete]</strong>, <strong>[location select]</strong> as the expectation is that the concept of a named location is based within the supersample, and the positioning of the individual occurrences would be based on selecting a point on the map associated with the supersample location.<br/>" . "Note as well that the date will be copied down from the parent supersample, and that care should be taken 1) when using any tab called Other Information, as this the default tab for any unassigned attributes, and 2) to avoid using tab names to hold attributes which are on both super and subsample records, as the attributes will then appear on both.", 'type' => 'textarea', 'default' => "=Place=\r\n" . "?Please provide the spatial reference of the record. You can enter the reference directly, or click on the map.?\r\n" . "[spatial reference]\r\n" . "[map]\r\n" . "@layers=[\"SSLayer\"]\r\n" . "[*]\r\n" . "=Species=\r\n" . "?Please enter the species you saw and any other information about them.?\r\n" . "[species]\r\n" . "[species attributes]\r\n" . "[*]\r\n", 'group' => 'User Interface')));
     return $retVal;
 }
 public static function get_parameters()
 {
     $retVal = array();
     $parentVal = array_merge(parent::get_parameters(), iform_mnhnl_getParameters(), array(array('name' => 'reportFilenamePrefix', 'caption' => 'Report Filename Prefix', 'description' => 'Prefix to be used at the start of the download report filenames.', 'type' => 'string', 'default' => 'ButterflySites', 'group' => 'Reporting'), array('name' => 'max_species_ids', 'caption' => 'max number of species to be returned by a search', 'description' => 'The maximum number of species to be returned by the drop downs at any one time.', 'default' => 100, 'type' => 'int', 'group' => 'Species'), array('name' => 'attributeValidation', 'caption' => 'Attribute Validation Rules', 'description' => 'Client Validation rules to be enforced on attributes: allows more options than allowed by straight class led validation.', 'type' => 'textarea', 'required' => false, 'group' => 'User Interface')));
     foreach ($parentVal as $param) {
         if ($param['name'] == 'structure') {
             $param['default'] = "=Sites=\r\n" . "[lux5kgrid2]\r\n" . "[map]\r\n" . "@layers=[\"ParentWMSLayer\",\"ParentLocationLayer\",\"SitePointLayer\",\"SitePathLayer\",\"SiteAreaLayer\",\"SiteLabelLayer\"]\r\n" . "@editLayer=false\r\n" . "@clickableLayers=[\"ParentWMSLayer\"]\r\n" . "@clickableLayersOutputMode=custom\r\n" . "@clickableLayersOutputDiv=clickableLayersOutputDiv\r\n" . "@clickableLayersOutputFn=setClickedParent\r\n" . "[point grid]\r\n" . "@srefs=2169,LUREF (m),X,Y,;4326,Lat/Long Deg,Lat,Long,D;4326,Lat/Long Deg:Min,Lat,Long,DM;4326,Lat/Long Deg:Min:Sec,Lat,Long,DMS\r\n" . "[sample comment]\r\n" . "=Conditions=\r\n" . "[recorder names]\r\n" . "[*]\r\n" . "@sep=&#32;\r\n" . "@lookUpKey=meaning_id\r\n" . "[year]\r\n" . "@boltTo=passage\r\n" . "[conditions grid]\r\n" . "@sep=<br />\r\n" . "@lookUpKey=meaning_id\r\n" . "@tabNameFilter=ConditionsGrid\r\n" . "@setRowRequired=2\r\n" . "@NumRows=4\r\n" . "@NumAttrCols=3\r\n" . "=Species=\r\n" . "[species grid]\r\n" . "[*]\r\n" . "[late JS]";
         }
         if ($param['name'] == 'attribute_termlist_language_filter') {
             $param['default'] = true;
         }
         if ($param['name'] == 'grid_report') {
             $param['default'] = 'reports_for_prebuilt_forms/MNHNL/mnhnl_butterflies2';
         }
         if ($param['name'] != 'species_include_taxon_group' && $param['name'] != 'link_species_popups' && $param['name'] != 'species_include_both_names') {
             $retVal[] = $param;
         }
     }
     return $retVal;
 }
 public static function get_parameters()
 {
     $retVal = array();
     $parentVal = array_merge(parent::get_parameters(), iform_mnhnl_getParameters(), array(array('name' => 'reportFilenamePrefix', 'caption' => 'Report Filename Prefix', 'description' => 'Prefix to be used at the start of the download report filenames.', 'type' => 'string', 'default' => 'bathibernation', 'group' => 'Reporting'), array('name' => 'siteTypeAttr', 'caption' => 'Site Type Attribute', 'description' => 'Caption of the location attribute used to indicate the site type.', 'type' => 'int', 'default' => 'Site type', 'group' => 'Locations'), array('name' => 'entranceDefectiveTermID', 'caption' => 'Entrance hole Attribute, Defective Term ID', 'description' => 'The Entrance hole attribute has a Defective choice which when selected allows an additional text field to be filled in. This field holds the Indicia term meaning id for the checkbox.', 'type' => 'int', 'group' => 'User Interface'), array('name' => 'entranceDefectiveCommentAttrID', 'caption' => 'Defective Entrance Comment Attribute ID', 'description' => 'The Entrance hole attribute has a Defective choice which when selected allows an additional text field to be filled in. This field holds the text field Indicia attribute id', 'type' => 'int', 'group' => 'User Interface'), array('name' => 'disturbanceOtherTermID', 'caption' => 'Disturbance Attribute, Other Term ID', 'description' => 'The Disturbances attribute has an Other choice which when selected allows an additional text field to be filled in. This field holds the Indicia term meaning id for the checkbox.', 'type' => 'int', 'group' => 'User Interface'), array('name' => 'disturbanceCommentAttrID', 'caption' => 'Disturbance Other Comment Attribute ID', 'description' => 'The Disturbances attribute has an Other choice which when selected allows an additional text field to be filled in. This field holds the text field Indicia attribute id', 'type' => 'int', 'group' => 'User Interface'), array('name' => 'removeBreakIDs', 'caption' => 'Remove breaks', 'description' => 'The Sample Attributes to remove the break after. This text field holds a colon separated list of Indicia attribute ids', 'type' => 'string', 'group' => 'User Interface'), array('name' => 'attributeValidation', 'caption' => 'Attribute Validation Rules', 'description' => 'Client Validation rules to be enforced on attributes: allows more options than allowed by straight class led validation.', 'type' => 'textarea', 'required' => false, 'group' => 'User Interface'), array('name' => 'max_species_ids', 'caption' => 'max number of species to be returned by a search', 'description' => 'The maximum number of species to be returned by the drop downs at any one time.', 'default' => 25, 'type' => 'int', 'group' => 'Species')));
     foreach ($parentVal as $param) {
         if ($param['name'] == 'structure') {
             $param['default'] = "=Site=\r\n" . "[custom JS]\r\n" . "[location module]\r\n" . "[location attributes]\r\n" . "@lookUpListCtrl=radio_group\r\n" . "@lookUpKey=meaning_id\r\n" . "@sep=&#32;\r\n" . "@tabNameFilter=Site\r\n" . "@class=wide\r\n" . "[location spatial reference]\r\n" . "[location attributes]\r\n" . "@tabNameFilter=SpatialRef\r\n" . "[place search]\r\n" . "[map]\r\n" . "@layers=[\"SiteAreaLayer\",\"SitePathLayer\",\"SitePointLayer\",\"SiteLabelLayer\"]\r\n" . "@editLayer=false\r\n" . "@searchLayer=true\r\n" . "@searchUpdatesSref=false\r\n" . "@maxZoom=17\r\n" . "[point grid]\r\n" . "@srefs=2169,LUREF (m),X,Y,;4326,Lat/Long Deg,Lat,Long,D;4326,Lat/Long Deg:Min,Lat,Long,DM;4326,Lat/Long Deg:Min:Sec,Lat,Long,DMS\r\n" . "[location comment]\r\n" . "[*]\r\n" . "=Conditions=\r\n" . "[date]\r\n" . "[recorder names]\r\n" . "[*]\r\n" . "@sep=&#32;\r\n" . "@lookUpKey=meaning_id\r\n" . "[sample comment]\r\n" . "=Species=\r\n" . "[species]\r\n" . "@view=detail\r\n" . "@rowInclusionCheck=alwaysRemovable\r\n" . "@sep=&#32;\r\n" . "@lookUpKey=meaning_id\r\n" . "[*]\r\n" . "[lateJS]\r\n";
         }
         if ($param['name'] == 'attribute_termlist_language_filter') {
             $param['default'] = true;
         }
         if ($param['name'] == 'grid_report') {
             $param['default'] = 'reports_for_prebuilt_forms/MNHNL/mnhnl_bats_grid';
         }
         if ($param['name'] != 'species_include_taxon_group' && $param['name'] != 'link_species_popups' && $param['name'] != 'species_include_both_names' && $param['name'] != 'includeLocTools' && $param['name'] != 'loctoolsLocTypeID') {
             $retVal[] = $param;
         }
     }
     return $retVal;
 }
 /**
  * Get the list of parameters for this form.
  * @return array List of parameters that this form requires.
  */
 public static function get_parameters()
 {
     $parentVal = array_merge(parent::get_parameters(), iform_mnhnl_getParameters(), array(array('name' => 'attributeValidation', 'caption' => 'Attribute Validation Rules', 'description' => 'Client Validation rules to be enforced on attributes: allows more options than allowed by straight class led validation.', 'type' => 'textarea', 'required' => false, 'group' => 'User Interface'), array('name' => 'targetSpeciesAttr', 'caption' => 'Target Species Attribute', 'description' => 'Name of lookup type Sample Attribute used to hold the target species. This is used in the reporting and control.', 'type' => 'text_input', 'group' => 'User Interface', 'required' => false), array('name' => 'targetSpeciesAttrList', 'caption' => 'Target Species Attribute List', 'description' => 'Comma separated list of sample attribute IDs used in the target species grid. This is used in the control and the reporting.', 'type' => 'text_input', 'group' => 'User Interface', 'required' => false), array('name' => 'target_species_subsample_method_id', 'caption' => 'Target Species Sample Method', 'type' => 'select', 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'extraParams' => array('termlist_external_key' => 'indicia:sample_methods'), 'required' => false, 'helpText' => 'The sample method that will be used when creating subsamples in the target species grid.'), array('name' => 'language', 'caption' => 'Language Override', 'description' => 'Two digit language override.', 'type' => 'string', 'required' => true, 'default' => 'en', 'group' => 'User Interface'), array('name' => 'subsample_method_id', 'caption' => 'Subsample Method', 'type' => 'select', 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'extraParams' => array('termlist_external_key' => 'indicia:sample_methods'), 'required' => false, 'helpText' => 'The sample method that will be used for created subsamples in the species grid.'), array('name' => 'reportFilenamePrefix', 'caption' => 'Report Filename Prefix', 'description' => 'Prefix to be used at the start of the download report filenames.', 'type' => 'string', 'group' => 'Reporting'), array('name' => 'sites_download_report', 'caption' => 'Sites download report', 'description' => 'Name of the sites download report.', 'type' => 'string', 'group' => 'Reporting', 'required' => false), array('name' => 'conditions_download_report', 'caption' => 'Conditions download report', 'description' => 'Name of the conditions download report.', 'type' => 'string', 'group' => 'Reporting', 'required' => false), array('name' => 'species_download_report', 'caption' => 'Species download report', 'description' => 'Name of the species download report.', 'type' => 'string', 'group' => 'Reporting')));
     $retVal = array();
     foreach ($parentVal as $param) {
         if ($param['name'] == 'grid_report') {
             $param['description'] = 'Name of the report to use to populate the grid for selecting existing data. The report must return a sample_id ' . 'field for linking to the data entry form.';
             $param['default'] = 'reports_for_prebuilt_forms/mnhnl_dynamic_2_supersamples';
         }
         if ($param['name'] == 'interface') {
             $param['options'] = array('tabs' => 'Tabs', 'wizard' => 'Wizard');
         }
         // No one_page
         if ($param['name'] != 'no_grid' && $param['name'] != 'occurrence_comment' && $param['name'] != 'occurrence_images' && $param['name'] != 'multiple_occurrence_mode' && $param['fieldname'] != 'list_id' && $param['fieldname'] != 'extra_list_id' && $param['fieldname'] != 'cache_lookup' && $param['fieldname'] != 'user_controls_taxon_filter') {
             $retVal[] = $param;
         }
         // Note the includeLocTools is left in in case any child forms use it
     }
     return $retVal;
 }
 public static function get_form($args, $node, $response = null)
 {
     global $indicia_templates;
     global $user;
     $indicia_templates['select_item'] = '<option value="{value}" {selected} >{caption}&nbsp;</option>';
     // we don't use the map, but a lot of the inherited code assumes the map is present.
     self::$svcUrl = data_entry_helper::$base_url . '/index.php/services';
     data_entry_helper::add_resource('openlayers');
     $indicia_templates['label'] = '<label for="{id}"{labelClass}>{label}:</label>';
     // can't have the CR on the end
     $indicia_templates['zilch'] = '';
     // can't have the CR on the end
     self::$locations = iform_loctools_listlocations($node);
     $retVal = parent::get_form($args, $node, $response);
     $reload = data_entry_helper::get_reload_link_parts();
     $reloadPath = $reload['path'];
     if (self::$mode != 0) {
         data_entry_helper::$javascript .= "\njQuery('<div class=\"ui-widget-content ui-state-default ui-corner-all indicia-button tab-cancel\"><span><a href=\"" . $reloadPath . "\">Cancel</a></span></div>').appendTo('.buttons');\n\$.validator.messages.required = \"" . lang::get('validation_required') . "\";";
         if (!iform_loctools_checkaccess($node, 'superuser')) {
             data_entry_helper::$javascript .= "\njQuery('[name=smpAttr\\:" . $args['observer_attr_id'] . "],[name^=smpAttr\\:" . $args['observer_attr_id'] . "\\:]').attr('readonly',true)";
             if (self::$mode == 1) {
                 data_entry_helper::$javascript .= ".val(\"" . $user->name . "\");";
             } else {
                 data_entry_helper::$javascript .= ";";
             }
         } else {
             $userlist = iform_loctools_listusers($node);
             data_entry_helper::$javascript .= "\nexisting = jQuery('[name=smpAttr\\:" . $args['observer_attr_id'] . "],[name^=smpAttr\\:" . $args['observer_attr_id'] . "\\:]');\nreplacement = '<select name=\"'+existing.attr('name')+'\" >";
             foreach ($userlist as $uid => $a_user) {
                 data_entry_helper::$javascript .= "<option value=\"" . $a_user->name . "\">" . $a_user->name . "&nbsp;</option>";
             }
             data_entry_helper::$javascript .= "</select>';\njQuery(replacement).insertBefore(existing).val(existing.val());\nexisting.remove();\n";
         }
         data_entry_helper::$javascript .= "\n// jQuery('#sample\\\\:date').datepicker( \"option\", \"minDate\", new Date(2010, 4 - 1, 1) );\nDate.prototype.getMonthName = function() {\nvar m = ['" . lang::get('January') . "','" . lang::get('February') . "','" . lang::get('March') . "',\n'" . lang::get('April') . "','" . lang::get('May') . "','" . lang::get('June') . "',\n'" . lang::get('July') . "','" . lang::get('August') . "','" . lang::get('September') . "',\n'" . lang::get('October') . "','" . lang::get('November') . "','" . lang::get('December') . "'];\nreturn m[this.getMonth()];\n} \nvar monthAttr = jQuery('[name=smpAttr\\\\:" . $args['month_attr_id'] . "],[name^=smpAttr\\\\:" . $args['month_attr_id'] . "\\\\:]').attr('disabled', true);\nmonthAttr.before('<input type=\"hidden\" id=\"storedMonth\" name=\"'+monthAttr.attr('name')+'\">');\nupdateSampleDate = function(context, doAlert){\n  jQuery('.displayDateDetails').empty().append('<span>'+jQuery('[name=sample\\:date]').val()+'</span>');\n  var myDate = jQuery(context).datepicker(\"getDate\").getMonthName();\n  var monthAttr = jQuery('[name=smpAttr\\\\:" . $args['month_attr_id'] . "],[name^=smpAttr\\\\:" . $args['month_attr_id'] . "\\\\:]').filter('select').val(\"\");\n  monthAttr.find(\"option:contains('\"+myDate+\"')\").attr('selected',true) ; \n  jQuery('#storedMonth').val(monthAttr.val()); // doing in this order converts the text to a number and stores that number in the storedMonth\n  if(doAlert && monthAttr.val() == \"\")\n  \talert('Given date is outside valid month range (April to September).');\n};\njQuery('#sample\\\\:date').change(function(){updateSampleDate(this, true);});\nupdateSampleDate('#sample\\\\:date', false);\njQuery('.tab-submit').unbind('click');\njQuery('.tab-submit').click(function() {\n  var current=jQuery('#controls').tabs('option', 'selected');\n  var tabinputs = jQuery('#entry_form div > .ui-tabs-panel:eq('+current+')').find('input,select');\n  var secList = '';\n  if (!tabinputs.valid()) { return; }\n  var rows = jQuery('.sectionlist').find('tr');\n  for(var i=1; i<= " . $args['max_number_sections'] . "; i++){\n    if(jQuery('.sectionlist').find('[section='+i+']').length > 0) {\n      var aucuneControl = jQuery(':checkbox[name^=\"SLA\\:'+i+'\\:\"]').filter('[name\$=\"\\:" . $args['aucune_attr_id'] . "\"]');\n      var foundEntry = false;\n      for(var j = 1; j < (rows.length-(numAttrs+1)); j++){\n        foundEntry = foundEntry || (jQuery(rows[j]).find('td').filter(':eq('+i+')').find('[value!=\"\"]').length > 0);\n      }\n      if(!foundEntry && !aucuneControl.attr('checked')){\n          secList = secList + (secList=='' ? '' : ', ') + i;\n      }\n    }\n  }\n  if (secList != ''){\n    alert('The following sections have no species recorded against them: Section(s) '+secList+'. In these circumstances, the \"No Observation\" checkbox must be checked for the relevant section.'); \n    return;\n  }\n  var form = jQuery(this).parents('form:first');\n  form.submit();\n});\n";
     } else {
         $retVal .= "<div style=\"display:none\" />\n    <form id=\"form-delete-survey\" action=\"" . $reloadPath . "\" method=\"POST\">" . self::$auth['write'] . "\n       <input type=\"hidden\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n       <input type=\"hidden\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n       <input type=\"hidden\" name=\"sample:id\" value=\"\" />\n       <input type=\"hidden\" name=\"sample:date\" value=\"2010-01-01\"/>\n       <input type=\"hidden\" name=\"sample:location_id\" value=\"\" />\n       <input type=\"hidden\" name=\"sample:deleted\" value=\"t\" />\n    </form>\n</div>";
         data_entry_helper::$javascript .= "\ndeleteSurvey = function(sampleID){\n  if(confirm(\"Are you sure you wish to delete survey \"+sampleID)){\n    jQuery.getJSON(\"" . self::$svcUrl . "/data/sample/\"+sampleID +\n            \"?mode=json&view=detail&auth_token=" . self::$auth['read']['auth_token'] . "&nonce=" . self::$auth['read']["nonce"] . "\" +\n            \"&callback=?\", function(data) {\n        if (data.length>0) {\n          jQuery('#form-delete-survey').find('[name=sample\\:id]').val(data[0].id);\n          jQuery('#form-delete-survey').find('[name=sample\\:date]').val(data[0].date_start);\n          jQuery('#form-delete-survey').find('[name=sample\\:location_id]').val(data[0].location_id);\n          jQuery('#form-delete-survey').submit();\n  }});\n  };\n};\n";
     }
     return $retVal;
 }
 public static function get_parameters()
 {
     $retVal = array();
     $parentVal = array_merge(parent::get_parameters(), iform_mnhnl_getParameters(), array(array('name' => 'attributeValidation', 'caption' => 'Attribute Validation Rules', 'description' => 'Client Validation rules to be enforced on attributes: allows more options than allowed by straight class led validation.', 'type' => 'textarea', 'required' => false, 'group' => 'User Interface'), array('name' => 'targetSpeciesAttr', 'caption' => 'Target Species Attribute', 'description' => 'Name of lookup type Sample Attribute used to hold the target species. This is used in the control and the reporting.', 'type' => 'text_input', 'default' => 'ReptileTargetSpecies', 'group' => 'User Interface'), array('name' => 'targetSpeciesAttrList', 'caption' => 'Target Species Attribute List', 'description' => 'Comma separated list of sample attribute IDs used in the target species grid. This is used in the control and the reporting.', 'type' => 'text_input', 'group' => 'User Interface'), array('name' => 'language', 'caption' => 'Language Override', 'description' => '', 'type' => 'string', 'required' => true, 'default' => 'en', 'group' => 'User Interface'), array('name' => 'reportFilenamePrefix', 'caption' => 'Report Filename Prefix', 'description' => 'Prefix to be used at the start of the download report filenames.', 'type' => 'string', 'default' => 'reptiles', 'group' => 'Reporting'), array('name' => 'sites_download_report', 'caption' => 'Sites download report', 'description' => 'Name of the sites download report.', 'type' => 'string', 'group' => 'Reporting', 'required' => false), array('name' => 'conditions_download_report', 'caption' => 'Conditions download report', 'description' => 'Name of the conditions download report.', 'type' => 'string', 'group' => 'Reporting', 'required' => false), array('name' => 'species_download_report', 'caption' => 'Species download report', 'description' => 'Name of the species download report.', 'type' => 'string', 'group' => 'Reporting', 'default' => 'reports_for_prebuilt_forms/MNHNL/mnhnl_reptile_download_report')));
     foreach ($parentVal as $param) {
         if ($param['name'] == 'structure') {
             $param['default'] = "=Site=\r\n" . "[custom JS]\r\n" . "@attrRestrictionsProcessOrder=<TBD>\r\n" . "@attrRestrictions=<TBD>\r\n" . "[lux5k grid]\r\n" . "[location attributes]\r\n" . "[location spatial reference]\r\n" . "[map]\r\n" . "@layers=[\"ParentWMSLayer\",\"ParentLocationLayer\",\"SitePointLayer\",\"SitePathLayer\",\"SiteAreaLayer\",\"SiteLabelLayer\"]\r\n" . "@editLayer=false\r\n" . "@clickableLayers=[\"ParentWMSLayer\"]\r\n" . "@clickableLayersOutputMode=custom\r\n" . "@clickableLayersOutputDiv=clickableLayersOutputDiv\r\n" . "@clickableLayersOutputFn=setClickedParent\r\n" . "[point grid]\r\n" . "@srefs=2169,LUREF (m),X,Y,;4326,Lat/Long Deg,Lat,Long,D;4326,Lat/Long Deg:Min,Lat,Long,DM;4326,Lat/Long Deg:Min:Sec,Lat,Long,DMS\r\n" . "[location comment]\r\n" . "=Conditions=\r\n" . "[target species grid]\r\n" . "@targetSpeciesTermList=reptile:targetSpecies\r\n" . "@disableOptions=<TBD>\r\n" . "[date]\r\n" . "[recorder names]\r\n" . "[*]\r\n" . "@sep=&#32;\r\n" . "@lookUpKey=meaning_id\r\n" . "[sample comment]\r\n" . "=Species=\r\n" . "[species]\r\n" . "@view=detail\r\n" . "@rowInclusionCheck=alwaysRemovable\r\n" . "@lookUpKey=meaning_id\r\n" . "[*]\r\n" . "@lookUpKey=meaning_id\r\n" . "[late JS]";
         }
         if ($param['name'] == 'attribute_termlist_language_filter') {
             $param['default'] = true;
         }
         if ($param['name'] == 'grid_report') {
             $param['default'] = 'reports_for_prebuilt_forms/MNHNL/mnhnl_reptiles';
         }
         if ($param['name'] == 'extendLocationNameTemplate') {
             $param['default'] = '{name} : created by {Creator}';
         }
         if ($param['name'] != 'species_include_taxon_group' && $param['name'] != 'link_species_popups' && $param['name'] != 'species_include_both_names') {
             $retVal[] = $param;
         }
     }
     return $retVal;
 }
 /** 
  * Get the location control as a select dropdown.
  */
 private static function get_control_locationselect($auth, $args, $tabalias, $options)
 {
     self::$want_location_layer = true;
     $location_list_args = array_merge(array('label' => lang::get('LANG_Location_Label'), 'view' => 'detail', 'extraParams' => array_merge(array('orderby' => 'name', 'website_id' => $args['website_id']), $auth['read'])), $options);
     return data_entry_helper::location_select($location_list_args);
 }
   /**
    * Return the generated form output.
    * @return Form HTML.
    */
   public static function get_form($args, $node)
   {
       define("MODE_GRID", 0);
       define("MODE_NEW_SAMPLE", 1);
       define("MODE_EXISTING", 2);
       self::parse_defaults($args);
       self::getArgDefaults($args);
       global $user;
       $logged_in = $user->uid > 0;
       self::$node = $node;
       // Get authorisation tokens to update and read from the Warehouse.
       $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
       $svcUrl = data_entry_helper::$base_url . '/index.php/services';
       self::$auth = $auth;
       $mode = isset($args['no_grid']) && $args['no_grid'] ? MODE_NEW_SAMPLE : MODE_GRID;
       // default mode when no grid set to false - display grid of existing data
       // mode MODE_EXISTING: display existing sample
       $loadedSampleId = null;
       $loadedOccurrenceId = null;
       if ($_POST) {
           if (!array_key_exists('website_id', $_POST)) {
               // non Indicia POST, in this case must be the location allocations. add check to ensure we don't corrept the data by accident
               if (function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin') && array_key_exists('mnhnld1', $_POST)) {
                   iform_loctools_deletelocations($node);
                   foreach ($_POST as $key => $value) {
                       $parts = explode(':', $key);
                       iform_loctools_insertlocation($node, $parts[2], $parts[1]);
                   }
               }
           } else {
               if (!is_null(data_entry_helper::$entity_to_load)) {
                   $mode = MODE_EXISTING;
                   // errors with new sample, entity populated with post, so display this data.
               }
           }
           // else valid save, so go back to gridview: default mode 0
       }
       if (array_key_exists('sample_id', $_GET) && $_GET['sample_id'] != '{sample_id}') {
           $mode = MODE_EXISTING;
           $loadedSampleId = $_GET['sample_id'];
       }
       if (array_key_exists('occurrence_id', $_GET) && $_GET['occurrence_id'] != '{occurrence_id}') {
           $mode = MODE_EXISTING;
           $loadedOccurrenceId = $_GET['occurrence_id'];
           self::$occurrenceIds = array($loadedOccurrenceId);
       }
       if ($mode != MODE_EXISTING && array_key_exists('newSample', $_GET)) {
           $mode = MODE_NEW_SAMPLE;
           data_entry_helper::$entity_to_load = array();
       }
       // else default to mode MODE_GRID or MODE_NEW_SAMPLE depending on no_grid parameter
       self::$mode = $mode;
       // default mode  MODE_GRID : display grid of the samples to add a new one
       // or edit an existing one.
       if ($mode == MODE_GRID) {
           $r = '';
           $attributes = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id']), false);
           $tabs = array('#sampleList' => lang::get('LANG_Main_Samples_Tab'));
           if ($args['includeLocTools'] && function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin')) {
               $tabs['#setLocations'] = lang::get('LANG_Allocate_Locations');
           }
           if (method_exists(get_called_class(), 'getExtraGridModeTabs')) {
               $extraTabs = call_user_func(array(get_called_class(), 'getExtraGridModeTabs'), false, $auth['read'], $args, $attributes);
               if (is_array($extraTabs)) {
                   $tabs = $tabs + $extraTabs;
               }
           }
           if (count($tabs) > 1) {
               $r .= "<div id=\"controls\">" . data_entry_helper::enable_tabs(array('divId' => 'controls', 'active' => '#sampleList')) . "<div id=\"temp\"></div>";
               $r .= data_entry_helper::tab_header(array('tabs' => $tabs));
           }
           $r .= "<div id=\"sampleList\">" . call_user_func(array(get_called_class(), 'getSampleListGrid'), $args, $node, $auth, $attributes) . "</div>";
           if ($args['includeLocTools'] && function_exists('iform_loctools_checkaccess') && iform_loctools_checkaccess($node, 'admin')) {
               $r .= '
 <div id="setLocations">
   <form method="post">
     <input type="hidden" id="mnhnld1" name="mnhnld1" value="mnhnld1" /><table border="1"><tr><td></td>';
               $url = $svcUrl . '/data/location?mode=json&view=detail&auth_token=' . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "&parent_id=NULL&orderby=name";
               $session = curl_init($url);
               curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
               $entities = json_decode(curl_exec($session), true);
               $userlist = iform_loctools_listusers($node);
               foreach ($userlist as $uid => $a_user) {
                   $r .= '<td>' . $a_user->name . '</td>';
               }
               $r .= "</tr>";
               if (!empty($entities)) {
                   foreach ($entities as $entity) {
                       if (!$entity["parent_id"]) {
                           // only assign parent locations.
                           $r .= "<tr><td>" . $entity["name"] . "</td>";
                           $defaultuserids = iform_loctools_getusers($node, $entity["id"]);
                           foreach ($userlist as $uid => $a_user) {
                               $r .= '<td><input type="checkbox" name="location:' . $entity["id"] . ':' . $uid . (in_array($uid, $defaultuserids) ? '" checked="checked"' : '"') . '></td>';
                           }
                           $r .= "</tr>";
                       }
                   }
               }
               $r .= "</table>\n      <input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save_Location_Allocations') . "\" />\n    </form>\n  </div>";
           }
           if (method_exists(get_called_class(), 'getExtraGridModeTabs')) {
               $r .= call_user_func(array(get_called_class(), 'getExtraGridModeTabs'), true, $auth['read'], $args, $attributes);
           }
           if (count($tabs) > 1) {
               // close tabs div if present
               $r .= "</div>";
           }
           return $r;
       }
       if ($mode == MODE_EXISTING && is_null(data_entry_helper::$entity_to_load)) {
           // only load if not in error situation
           data_entry_helper::$entity_to_load = array();
           // Displaying an existing sample. If we know the occurrence ID, and don't know the sample ID or are displaying just one occurrence
           // rather than a grid of occurrences then we must load the occurrence data to get the sample id.
           if ($loadedOccurrenceId && (!$loadedSampleId || !self::getGridMode($args))) {
               data_entry_helper::load_existing_record($auth['read'], 'occurrence', $loadedOccurrenceId);
               // Get the sample ID for the occurrence. This overwrites it if supply in GET but did not match the occurrence's sample
               $loadedSampleId = data_entry_helper::$entity_to_load['occurrence:sample_id'];
               if (self::getGridMode($args)) {
                   // in grid mode, we only needed to load the occurrence to find out the sample id.
                   data_entry_helper::$entity_to_load = array();
               }
           }
           if ($loadedSampleId) {
               data_entry_helper::load_existing_record($auth['read'], 'sample', $loadedSampleId);
           }
       }
       // attributes must be fetched after the entity to load is filled in - this is because the id gets filled in then!
       $attrOpts = array('id' => data_entry_helper::$entity_to_load['sample:id'], 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id']);
       // select only the custom attributes that are for this sample method or all sample methods, if this
       // form is for a specific sample method.
       if (!empty($args['sample_method_id'])) {
           $attrOpts['sample_method_id'] = $args['sample_method_id'];
       }
       $attributes = data_entry_helper::getAttributes($attrOpts, false);
       //// Make sure the form action points back to this page
       $reload = data_entry_helper::get_reload_link_parts();
       unset($reload['params']['sample_id']);
       unset($reload['params']['occurrence_id']);
       unset($reload['params']['newSample']);
       $reloadPath = $reload['path'];
       if (count($reload['params'])) {
           $reloadPath .= '?' . http_build_query($reload['params']);
       }
       $r = "<form method=\"post\" id=\"entry_form\" action=\"{$reloadPath}\">\n";
       // Get authorisation tokens to update the Warehouse, plus any other hidden data.
       $hiddens = $auth['write'] . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n" . "<input type=\"hidden\" id=\"survey_id\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
       if (!empty($args['sample_method_id'])) {
           $hiddens .= '<input type="hidden" name="sample:sample_method_id" value="' . $args['sample_method_id'] . '"/>';
       }
       if (isset(data_entry_helper::$entity_to_load['sample:id'])) {
           $hiddens .= "<input type=\"hidden\" id=\"sample:id\" name=\"sample:id\" value=\"" . data_entry_helper::$entity_to_load['sample:id'] . "\" />\n";
       }
       if (isset(data_entry_helper::$entity_to_load['occurrence:id'])) {
           $hiddens .= "<input type=\"hidden\" id=\"occurrence:id\" name=\"occurrence:id\" value=\"" . data_entry_helper::$entity_to_load['occurrence:id'] . "\" />\n";
       }
       // Check if Record Status is included as a control. If not, then add it as a hidden.
       $arr = explode("\r\n", $args['structure']);
       if (!in_array('[record status]', $arr)) {
           $value = isset($args['defaults']['occurrence:record_status']) ? $args['defaults']['occurrence:record_status'] : 'C';
           $hiddens .= "<input type=\"hidden\" id=\"occurrence:record_status\" name=\"occurrence:record_status\" value=\"{$value}\" />\n";
       }
       // request automatic JS validation
       if (!isset($args['clientSideValidation']) || $args['clientSideValidation']) {
           data_entry_helper::enable_validation('entry_form');
       }
       // If logged in, output some hidden data about the user
       if (isset($args['copyFromProfile']) && $args['copyFromProfile'] == true) {
           self::profile_load_all_profile($user);
       }
       foreach ($attributes as &$attribute) {
           $attrPropName = 'profile_' . strtolower(str_replace(' ', '_', $attribute['caption']));
           if (isset($args['copyFromProfile']) && $args['copyFromProfile'] == true && isset($user->{$attrPropName})) {
               if ($args['nameShow'] == true) {
                   $attribute['default'] = $user->{$attrPropName};
               } else {
                   // profile attributes are not displayed as the user is logged in
                   $attribute['handled'] = true;
                   $attribute['value'] = $user->{$attrPropName};
               }
           } elseif (strcasecmp($attribute['caption'], 'cms user id') == 0) {
               if ($logged_in) {
                   $attribute['value'] = $user->uid;
               }
               $attribute['handled'] = true;
               // user id attribute is never displayed
           } elseif (strcasecmp($attribute['caption'], 'cms username') == 0) {
               if ($logged_in) {
                   $attribute['value'] = $user->name;
               }
               $attribute['handled'] = true;
               // username attribute is never displayed
           } elseif (strcasecmp($attribute['caption'], 'email') == 0) {
               if ($logged_in) {
                   if ($args['emailShow'] != true) {
                       // email attribute is not displayed
                       $attribute['value'] = $user->mail;
                       $attribute['handled'] = true;
                   } else {
                       $attribute['default'] = $user->mail;
                   }
               }
           } elseif ((strcasecmp($attribute['caption'], 'first name') == 0 || strcasecmp($attribute['caption'], 'last name') == 0 || strcasecmp($attribute['caption'], 'surname') == 0) && $logged_in) {
               if ($args['nameShow'] != true) {
                   // name attributes are not displayed because we have the users login
                   $attribute['handled'] = true;
               }
           }
           // If we have a value for one of the user login attributes then we need to output this value. BUT, for existing data
           // we must not overwrite the user who created the record.
           if (isset($attribute['value']) && $mode != MODE_EXISTING) {
               $hiddens .= '<input type="hidden" name="' . $attribute['fieldname'] . '" value="' . $attribute['value'] . '" />' . "\n";
           }
       }
       $customAttributeTabs = get_attribute_tabs($attributes);
       $tabs = self::get_all_tabs($args['structure'], $customAttributeTabs);
       $r .= "<div id=\"controls\">\n";
       // Build a list of the tabs that actually have content
       $tabHtml = self::get_tab_html($tabs, $auth, $args, $attributes, $hiddens);
       // Output the dynamic tab headers
       if ($args['interface'] != 'one_page') {
           $headerOptions = array('tabs' => array());
           foreach ($tabHtml as $tab => $tabContent) {
               $alias = preg_replace('/[^a-zA-Z0-9]/', '', strtolower($tab));
               $tabtitle = lang::get("LANG_Tab_{$alias}");
               if ($tabtitle == "LANG_Tab_{$alias}") {
                   // if no translation provided, we'll just use the standard heading
                   $tabtitle = $tab;
               }
               $headerOptions['tabs']['#' . $alias] = $tabtitle;
           }
           $r .= data_entry_helper::tab_header($headerOptions);
           data_entry_helper::enable_tabs(array('divId' => 'controls', 'style' => $args['interface'], 'progressBar' => isset($args['tabProgress']) && $args['tabProgress'] == true));
       }
       // Output the dynamic tab content
       $pageIdx = 0;
       foreach ($tabHtml as $tab => $tabContent) {
           // get a machine readable alias for the heading
           $tabalias = preg_replace('/[^a-zA-Z0-9]/', '', strtolower($tab));
           $r .= '<div id="' . $tabalias . '">' . "\n";
           // For wizard include the tab title as a header.
           if ($args['interface'] == 'wizard') {
               $r .= '<h1>' . $headerOptions['tabs']['#' . $tabalias] . '</h1>';
           }
           $r .= $tabContent;
           // Add any buttons required at the bottom of the tab
           if ($args['interface'] == 'wizard') {
               $r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => $pageIdx === 0 ? 'first' : ($pageIdx == count($tabHtml) - 1 ? 'last' : 'middle')));
           } elseif ($pageIdx == count($tabHtml) - 1 && !($args['interface'] == 'tabs' && $args['save_button_below_all_pages'])) {
               // last part of a non wizard interface must insert a save button, unless it is tabbed interface with save button beneath all pages
               $r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" id=\"save-button\" value=\"" . lang::get('LANG_Save') . "\" />\n";
           }
           $pageIdx++;
           $r .= "</div>\n";
       }
       $r .= "</div>\n";
       if ($args['interface'] == 'tabs' && $args['save_button_below_all_pages']) {
           $r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" id=\"save-button\" value=\"" . lang::get('LANG_Save') . "\" />\n";
       }
       if (!empty(data_entry_helper::$validation_errors)) {
           $r .= data_entry_helper::dump_remaining_errors();
       }
       $r .= "</form>";
       $r .= self::link_species_popups($args);
       return $r;
   }