protected static function get_form_html($args, $auth, $attributes)
 {
     global $user;
     data_entry_helper::$javascript .= "\n      var sampleCreatedOn;\n      var lockingDate;\n    ";
     //Test if the sample date is less than the locking date, if it is then lock the form.
     if (!empty($_GET['sample_id']) && !empty($args['locking_date']) && !in_array('administrator', $user->roles)) {
         $sampleData = data_entry_helper::get_population_data(array('table' => 'sample', 'extraParams' => $auth['read'] + array('id' => $_GET['sample_id'], 'view' => 'detail')));
         //The date also has a time element. However this breaks javascript new date, so just get first part of the date (remove time).
         //(the line below just gets the part of the string before the space).
         $sampleCreatedOn = strtok($sampleData[0]['created_on'], ' ');
         if (!empty($sampleCreatedOn)) {
             data_entry_helper::$javascript .= "\n          sampleCreatedOn = new Date('" . $sampleCreatedOn . "');\n          lockingDate = new Date('" . $args['locking_date'] . "');\n        ";
         }
     }
     //If the date the sample was created is less than the threshold date set by the user, then
     //lock the form (put simply, old data cannot be edited by the user).
     data_entry_helper::$javascript .= "\n      if (sampleCreatedOn&&lockingDate&&sampleCreatedOn<lockingDate) {  \n        \$('[id*=_lock]').remove();\n \$('.remove-row').remove();\n\n        \$('.scImageLink,.scClonableRow').hide();\n        \$('.edit-taxon-name,.remove-row').hide();\n        \$('#disableDiv').find('input, textarea, text, button, select').attr('disabled','disabled');\n      }";
     //remove default validation mode of 'message' as species grid goes spazzy
     data_entry_helper::$validation_mode = array('colour');
     //Div that can be used to disable page when required
     $r = '<div id = "disableDiv">';
     $r .= parent::get_form_html($args, $auth, $attributes);
     $r .= '</div>';
     return $r;
 }
예제 #2
0
 /**
  * Override get_form_html. We remove the second tab when first inputting a new sample, because
  * the second tab can't save unless there is a parent sample available to link to.
  */
 protected static function get_form_html($args, $auth, $attributes)
 {
     if (empty($_GET['id'])) {
         return 'This form must be called with an id in the URL parameters';
     }
     data_entry_helper::$javascript .= "indiciaData.latLongNotationPrecision=5;\n";
     return parent::get_form_html($args, $auth, $attributes);
 }
 protected static function get_form_html($args, $auth, $attributes)
 {
     if ($args['includeLocTools'] && function_exists('iform_loctools_listlocations')) {
         $squares = iform_loctools_listlocations(self::$node);
         if ($squares != "all" && count($squares) == 0) {
             return lang::get('Error: You do not have any squares allocated to you. Please contact your manager.');
         }
     }
     $r = call_user_func(array(self::$called_class, 'getHeaderHTML'), $args);
     $r .= parent::get_form_html($args, $auth, $attributes);
     $r .= call_user_func(array(self::$called_class, 'getTrailerHTML'), $args);
     return $r;
 }
예제 #4
0
 protected static function get_form_html($args, $auth, $attributes)
 {
     // @todo Process the available data to load subsamples (habitats) and associated records correctly.
     // toggle the checkboxes to after the label to match the form.
     global $indicia_templates;
     drupal_add_library('system', 'ui.tooltip', true);
     $indicia_templates['check_or_radio_group_item'] = '<li><label for="{itemId}">{caption}</label><input type="{type}" name="{fieldname}" id="{itemId}" value="{value}"{class}{checked}{title} {disabled}/></li>';
     // Create an array of custom attributes keyed by caption for easy lookup later
     foreach ($attributes as $attr) {
         self::$attrsByCaption[strtolower($attr['caption'])] = $attr;
     }
     // Build a list of the habitat-level attributes as well.
     $attributeOpts = array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'sample_method_id' => $args['habitat_sample_method_id']);
     $habitatAttributes = data_entry_helper::getAttributes($attributeOpts, false);
     foreach ($habitatAttributes as $attr) {
         self::$habitatAttrsByCaption[strtolower($attr['caption'])] = $attr;
     }
     // load the habitat attribute values, if we have an existing sample
     if (!empty(self::$loadedSampleId)) {
         self::load_existing(self::$loadedSampleId, $auth);
     } else {
         data_entry_helper::$javascript .= "indiciaData.existingSubsampleData=[];\n";
     }
     // output some attribute info we can use for validation & business logic
     data_entry_helper::$javascript .= "indiciaData.depthMinLimitAttrNames = " . json_encode(array(self::$attrsByCaption['depth shallow bsl']['fieldname'], self::$attrsByCaption['depth shallow bcd']['fieldname'])) . ";\n";
     data_entry_helper::$javascript .= "indiciaData.depthMaxLimitAttrNames = " . json_encode(array(self::$attrsByCaption['depth deepest bsl']['fieldname'], self::$attrsByCaption['depth deepest bcd']['fieldname'])) . ";\n";
     data_entry_helper::$javascript .= "indiciaData.driftAttrId = " . self::$attrsByCaption['drift dive?']['attributeId'] . ";\n";
     data_entry_helper::$javascript .= "indiciaData.depthCDAttrName = '" . self::$attrsByCaption['tidal correction to chart datum']['fieldname'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData.habitatMinDepthSLAttrId = " . self::$habitatAttrsByCaption['upper depth from sea level']['attributeId'] . ";\n";
     data_entry_helper::$javascript .= "indiciaData.habitatMaxDepthSLAttrId = " . self::$habitatAttrsByCaption['lower depth from sea level']['attributeId'] . ";\n";
     data_entry_helper::$javascript .= "indiciaData.habitatMinDepthCDAttrId = " . self::$habitatAttrsByCaption['upper depth from chart datum']['attributeId'] . ";\n";
     data_entry_helper::$javascript .= "indiciaData.habitatMaxDepthCDAttrId = " . self::$habitatAttrsByCaption['lower depth from chart datum']['attributeId'] . ";\n";
     return parent::get_form_html($args, $auth, $attributes);
 }