/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { return data_entry_helper::build_sample_occurrences_list_submission($values); }
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { // default for forms setup on old versions is grid - list of occurrences // Can't call getGridMode in this context as we might not have the $_GET value to indicate grid if (isset($values['gridmode'])) { $submission = data_entry_helper::build_sample_occurrences_list_submission($values); } else { $submission = data_entry_helper::build_sample_occurrence_submission($values); } return $submission; }
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { // pass true to the submission build, as it will include rows with any data (as the checkbox is hidden). return data_entry_helper::build_sample_occurrences_list_submission($values, true); }
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { // Any remembered fields need to be made available to the hook function outside this class. global $remembered; $remembered = isset($args['remembered']) ? $args['remembered'] : ''; // default for forms setup on old versions is grid - list of occurrences // Can't call getGridMode in this context as we might not have the $_GET value to indicate grid if (isset($values['speciesgridmapmode'])) { $submission = data_entry_helper::build_sample_subsamples_occurrences_submission($values); } else { if (isset($values['gridmode'])) { $submission = data_entry_helper::build_sample_occurrences_list_submission($values); } else { $submission = data_entry_helper::build_sample_occurrence_submission($values); } } return $submission; }
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Indicia external site species checklist test page</title> <link rel="stylesheet" href="demo.css" type="text/css" media="screen"> <link rel="stylesheet" href="../../../media/css/default_site.css" type="text/css" media="screen"> </head> <body> <div id="wrap"> <h1>Indicia Species Checklist Test</h1> <?php require_once '../../../client_helpers/data_entry_helper.php'; require_once '../data_entry_config.php'; // Catch and submit POST data. if ($_POST) { $submission = data_entry_helper::build_sample_occurrences_list_submission($_POST); $response = data_entry_helper::forward_post_to('save', $submission); echo data_entry_helper::dump_errors($response); } ?> <form method='post'> <?php // Get authorisation tokens to update and read from the Warehouse. $auth = data_entry_helper::get_read_write_auth($config['website_id'], $config['password']); echo $auth['write']; $readAuth = $auth['read']; ?> <input type='hidden' name='website_id' value='<?php echo $config['website_id']; ?>
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { $subSampleIds = array('path', 'square', 'linear'); //Need to supply false as the third parameter, this explicitely tells the system that there are no //attributes to check as zero abundance even though we have already given the system the rowInclusionCheck=hasData option //which tells the system that only species with data should be considered as an occurrence. //If we don't do this, the system will always create an occurrence for every species, even if the Paths checkbox is off. $submission = data_entry_helper::build_sample_occurrences_list_submission($values, true, false); // Now because it is not standard, we need to attach the sub-samples for each plot. // First, extract the attributes for each subsample into their own arrays. $subSamples = array(); foreach ($values as $key => $value) { if (strpos($key, ':')) { $parts = explode(':', $key); if (in_array($parts[0], $subSampleIds)) { $subSamples[$parts[0]][substr($key, strlen($parts[0]) + 1)] = $value; } } } // Now wrap each of the subsample arrays and attach them to the main submission. foreach ($subSamples as $prefix => $s) { if (isset($values[$prefix . '_sample_id'])) { $s['sample:id'] = $values[$prefix . '_sample_id']; } // specify some default values $s['sample:entered_sref_system'] = $values['sample:entered_sref_system']; $s['sample:entered_sref'] = $values['sample:entered_sref']; $s['sample:geom'] = $values['sample:geom']; $s['sample:date'] = $values['sample:date']; $s['sample:survey_id'] = $values['survey_id']; $s['location_name'] = $prefix; $wrapped = submission_builder::wrap_with_attrs($s, 'sample', $prefix); $submission['subModels'][] = array('fkId' => 'parent_id', 'model' => $wrapped); } return $submission; }
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { if (array_key_exists('newsample_parent_id', $_POST)) { // $mode = MODE_NEW_OCCURRENCE return null; } if (array_key_exists('sample:parent_id', $_POST)) { // $mode = MODE_POST_OCCURRENCE; // Can't call getGridMode in this context as we might not have the $_GET value to indicate grid if (isset($values['gridmode'])) { return data_entry_helper::build_sample_occurrences_list_submission($values); } else { return data_entry_helper::build_sample_occurrence_submission($values); } } else { // $mode = MODE_POST_SUPERSAMPLE; return submission_builder::build_submission($values, $structure = array('model' => 'sample')); } }
/** * Handles the construction of a submission array from a set of form values. * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { $subSampleIds = array('path', 'square', 'linear'); $submission = data_entry_helper::build_sample_occurrences_list_submission($values, true); // Now because it is not standard, we need to attach the sub-samples for each plot. // First, extract the attributes for each subsample into their own arrays. $subSamples = array(); foreach ($values as $key => $value) { if (strpos($key, ':')) { $parts = explode(':', $key); if (in_array($parts[0], $subSampleIds)) { $subSamples[$parts[0]][substr($key, strlen($parts[0]) + 1)] = $value; } } } // Now wrap each of the subsample arrays and attach them to the main submission. foreach ($subSamples as $prefix => $s) { if (isset($values[$prefix . '_sample_id'])) { $s['sample:id'] = $values[$prefix . '_sample_id']; } // specify some default values $s['sample:entered_sref_system'] = $values['sample:entered_sref_system']; $s['sample:entered_sref'] = $values['sample:entered_sref']; $s['sample:geom'] = $values['sample:geom']; $s['sample:date'] = $values['sample:date']; $s['sample:survey_id'] = $values['survey_id']; $s['location_name'] = $prefix; $wrapped = submission_builder::wrap_with_attrs($s, 'sample', $prefix); $submission['subModels'][] = array('fkId' => 'parent_id', 'model' => $wrapped); } return $submission; }
/** * Handles the construction of a submission array from a set of form values. * * @param array $values Associative array of form data values. * @param array $args iform parameters. * @return array Submission structure. */ public static function get_submission($values, $args) { $fromDate = self::getStartDate($args); $values['sample:date_start'] = date('Y-m-d', $fromDate); $dateEnd = strtotime('+' . ($args['weeks'] * 7 - 1) . ' days', $fromDate); // force max date to today to pass validation. if ($dateEnd > time()) { $dateEnd = time(); } $values['sample:date_end'] = date('Y-m-d', $dateEnd); $values['sample:date_type'] = 'DD'; $weekData = array(); $countValues = json_decode($values['table-data']); // existing samples being posted? $samplesDates = array(); if (!empty($values['samples-dates'])) { $samplesDates = json_decode($values['samples-dates'], true); } unset($values['table-data']); unset($values['samples-dates']); $parentSample = submission_builder::wrap_with_images($values, 'sample'); foreach ($countValues as $key => $value) { $tokens = explode(':', $key); // consider existing values, or filled in values only if (($value !== '' || count($tokens) === 6) && preg_match('/^sc([0-9]+):/', $key, $matches)) { $weekIdx = $matches[1]; if (!isset($weekData["week{$weekIdx}"])) { $weekData["week{$weekIdx}"] = array(); } $datelessKey = preg_replace('/^sc([0-9]+):/', 'sc:', $key); $weekData["week{$weekIdx}"][$datelessKey] = $value; $presenceKey = preg_replace('/occAttr:[0-9]+(:[0-9]+)?$/', 'present', $datelessKey); $weekData["week{$weekIdx}"][$presenceKey] = $tokens[1]; } } $parentSample['subModels'] = array(); // retrieve any sample data for each week $weekSampleData = array(); foreach ($values as $key => $value) { if (preg_match('/^smpAttr(\\d+):(.+)/', $key, $matches)) { if (!isset($weekSampleData["week{$matches['1']}"])) { $weekSampleData["week{$matches['1']}"] = array(); } $weekSampleData["week{$matches['1']}"]["smpAttr:{$matches['2']}"] = $value; } } foreach ($weekData as $week => $data) { $weekno = substr($week, 4); $weekstart = strtotime('+' . $weekno . ' weeks', $fromDate); if (isset($samplesDates[$weekstart])) { $data['sample:id'] = $samplesDates[$weekstart]; } $data['sample:date_start'] = date('Y-m-d', $weekstart); $data['sample:date_end'] = date('Y-m-d', strtotime('+6 days', $weekstart)); $data['sample:date_type'] = 'DD'; $data['website_id'] = $values['website_id']; $data['survey_id'] = $values['survey_id']; $data['entered_sref'] = $values['sample:entered_sref']; $data['entered_sref_system'] = $values['sample:entered_sref_system']; $data['geom'] = $values['sample:geom']; if (isset($weekSampleData["week{$weekno}"])) { $data = array_merge($data, $weekSampleData["week{$weekno}"]); } $subSampleAndOccs = data_entry_helper::build_sample_occurrences_list_submission($data); $parentSample['subModels'][] = array('fkId' => 'parent_id', 'model' => $subSampleAndOccs); } return $parentSample; }