本文整理汇总了PHP中data_entry_helper::report_grid方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::report_grid方法的具体用法?PHP data_entry_helper::report_grid怎么用?PHP data_entry_helper::report_grid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::report_grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_form
/**
* 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)
{
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
global $user;
$r = '';
$presetList = explode("\n", $args['param_presets']);
$presets = array();
foreach ($presetList as $param) {
$tokens = explode('=', $param);
if (count($tokens) == 2) {
$presets[$tokens[0]] = $tokens[1];
} else {
$r .= '<div class="page-notice ui-widget ui-widget-content ui-corner-all ui-state-error">' . 'Some of the preset parameters defined for this page are not of the form param=value.</div>';
}
}
$reportOptions = array('id' => 'report-grid', 'class' => '', 'thClass' => '', 'dataSource' => $args['report_name'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => array(), 'itemsPerPage' => 20, 'autoParamsForm' => $args['auto_params_form'], 'extraParams' => $presets);
// Add a download link
$r .= '<a href="' . data_entry_helper::get_report_data(array_merge($reportOptions, array('linkOnly' => true))) . '&mode=csv">Download this report</a>';
// now the grid
$r .= data_entry_helper::report_grid($reportOptions);
// Set up a page refresh for dynamic update of the report at set intervals
if ($args['refresh_timer'] !== 0 && is_numeric($args['refresh_timer'])) {
// is_int prevents injection
if (isset($args['load_on_refresh']) && !empty($args['load_on_refresh'])) {
data_entry_helper::$javascript .= "setTimeout('window.location=\"" . $args['load_on_refresh'] . "\";', " . $args['refresh_timer'] . "*1000 );\n";
} else {
data_entry_helper::$javascript .= "setTimeout('window.location.reload( false );', " . $args['refresh_timer'] . "*1000 );\n";
}
}
return $r;
}
示例2: getLocationListGrid
/**
* When viewing the list of locations for this user, get the grid to insert into the page.
* Filtering of locations is by Indicia User ID stored in the user profile.
* Enable Easy Login module to achieve this function.
*/
protected static function getLocationListGrid($args, $node, $auth)
{
global $user;
// User must be logged in before we can access their records.
if ($user->uid === 0) {
// Return a login link that takes you back to this form when done.
return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => 'destination=node/' . $node->nid)) . '">login</a> to the website.');
}
// get the Indicia User ID attribute so we can filter the grid to this user
if (function_exists('hostsite_get_user_field')) {
$iUserId = hostsite_get_user_field('indicia_user_id');
}
if (!isset($iUserId) || !$iUserId) {
return lang::get('LANG_No_User_Id');
}
// Subclassed forms may provide a getLocationListGridPreamble function
if (method_exists(self::$called_class, 'getLocationListGridPreamble')) {
$r = call_user_func(array(self::$called_class, 'getLocationListGridPreamble'));
} else {
$r = '';
}
$extraParams = array('website_id' => $args['website_id'], 'iUserID' => $iUserId);
if (!$args['list_all_locations']) {
// The option to list all locations is denied so enforce selection of own data.
$extraParams['ownData'] = '1';
}
$r .= data_entry_helper::report_grid(array('id' => 'locations-grid', 'dataSource' => $args['grid_report'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(self::$called_class, 'getReportActions')), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 10, 'autoParamsForm' => true, 'extraParams' => $extraParams, 'paramDefaults' => array('ownData' => '1')));
$r .= '<form>';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Location') . '" ' . 'onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => array('new' => '1'))) . '\'">';
$r .= '</form>';
return $r;
}
示例3: get_form
/**
* Return the Indicia form code.
* Expects there to be a sample attribute with caption 'Email' containing the email
* address.
* @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, $indicia_templates;
// put each param control in a div, which makes it easier to layout with CSS
$indicia_templates['prefix'] = '<div id="container-{fieldname}" class="param-container">';
$indicia_templates['suffix'] = '</div>';
$indicia_user_id = self::get_indicia_user_id($args);
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$r = '';
if ($_POST) {
// dump out any errors that occurred on verification
if (data_entry_helper::$validation_errors) {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all"><p>' . implode('</p></p>', array_values(data_entry_helper::$validation_errors)) . '</p></div>';
} else {
if (isset($_POST['email']) && !isset($response['error'])) {
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $user->mail . PHP_EOL . "\r\n";
$headers .= 'Return-Path: ' . $user->mail . "\r\n";
if (isset($_POST['photoHTML'])) {
$emailBody = str_replace('[photo]', '<br/>' . $_POST['photoHTML'], $_POST['email_content']);
} else {
$emailBody = $_POST['email_content'];
}
$emailBody = str_replace("\n", "<br/>", $emailBody);
// Send email. Depends upon settings in php.ini being correct
$success = mail($_POST['email_to'], $_POST['email_subject'], wordwrap($emailBody, 70), $headers);
if ($success) {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all"><p>An email was sent to ' . $_POST['email_to'] . '.</p></div>';
} else {
$r .= '<div class="page-notice ui-widget-content ui-corner-all ui-state-highlight left">The webserver is not correctly configured to send emails. Please send the following email manually: <br/>' . '<div id="manual-email"><span>To:</span><div>' . $_POST['email_to'] . '</div>' . '<span>Subject:</span><div>' . $_POST['email_subject'] . '</div>' . '<span>Content:</span><div>' . $emailBody . '</div>' . '</div></div><div style="clear: both">';
}
} else {
if (isset($_POST['occurrence:record_status']) && isset($response['success']) && $args['emails_enabled']) {
$r .= self::get_notification_email_form($args, $response, $auth);
}
}
}
if (isset($_POST['action']) && $_POST['action'] == 'send_to_verifier' && $args['log_send_to_verifier']) {
$comment = str_replace(array('%email%', '%date%', '%user%'), array($_POST['email_to'], date('jS F Y'), $user->name), $args['log_send_to_verifier_comment']);
} elseif (isset($_POST['action']) && ($_POST['action'] = 'general_comment')) {
$comment = $_POST['comment'];
}
// If there is a comment to save, add it to the occurrence comments
if (isset($comment)) {
// get our own write tokens for this submission, as the main ones are used in the JavaScript form.
$loggingAuth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$sub = data_entry_helper::wrap(array('comment' => $comment, 'occurrence_id' => $_POST['occurrence:id'], 'created_by_id' => $indicia_user_id), 'occurrence_comment');
$logResponse = data_entry_helper::forward_post_to('occurrence_comment', $sub, $loggingAuth['write_tokens']);
if (!array_key_exists('success', $logResponse)) {
$r .= data_entry_helper::dump_errors($response, false);
}
}
}
//extract fixed parameters for report grid.
$params = explode(",", $args['fixed_params']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$extraParams[$key] = $val;
}
// plus defaults which are not fixed
$params = explode("\n", $args['param_defaults']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$paramDefaults[$key] = $val;
}
$actions = array();
if ($args['send_for_verification']) {
// store authorisation details as a global in js, since some of the JavaScript needs to be able to access Indicia data
data_entry_helper::$javascript .= 'auth=' . json_encode($auth) . ';';
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Send to verifier')), 'class' => 'send_for_verification_btn', 'javascript' => 'indicia_send_to_verifier(\'{taxon}\', {occurrence_id}, ' . $user->uid . ', ' . $args['website_id'] . '); return false;');
$r .= self::get_send_for_verification_form();
}
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Verify')), 'javascript' => 'indicia_verify(\'{taxon}\', {occurrence_id}, true, ' . $user->uid . '); return false;');
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Reject')), 'javascript' => 'indicia_verify(\'{taxon}\', {occurrence_id}, false, ' . $user->uid . '); return false;');
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Comments')), 'javascript' => 'indicia_comments(\'{taxon}\', {occurrence_id}, ' . $user->uid . ', \'' . $auth['read']['nonce'] . '\', \'' . $auth['read']['auth_token'] . '\'); return false;');
if (isset($args['path_to_record_details_page']) && $args['path_to_record_details_page']) {
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('View details')), 'url' => '{rootFolder}' . $args['path_to_record_details_page'], 'urlParams' => array('occurrence_id' => '{occurrence_id}'));
}
// default columns behaviour is to just include anything returned by the report plus add an actions column
$columns = array(array('display' => 'Actions', 'actions' => $actions));
// this can be overridden
if (isset($args['columns_config']) && !empty($args['columns_config'])) {
$columns = array_merge(json_decode($args['columns_config'], true), $columns);
}
$r .= data_entry_helper::report_grid(array('id' => 'verification-grid', 'dataSource' => $args['report_name'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => $columns, 'rowId' => 'occurrence_id', 'itemsPerPage' => 10, 'autoParamsForm' => $args['auto_params_form'], 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults));
//.........这里部分代码省略.........
示例4: get_form
/**
* 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;
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$r = '';
if ($_POST) {
// dump out any errors that occurred on verification
if (data_entry_helper::$validation_errors) {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all"><p>' . implode('</p></p>', array_values(data_entry_helper::$validation_errors)) . '</p></div>';
} else {
if (isset($_POST['email'])) {
// Send email. Depends upon settings in php.ini being correct
$success = mail($_POST['email_to'], $_POST['email_subject'], wordwrap($_POST['email_body'], 70), 'From: ' . $user->mail . PHP_EOL . 'Return-Path: ' . $user->mail);
} else {
if (isset($_POST['occurrence:record_status']) && isset($response['success']) && $args['emails_enabled']) {
// Provide a send email form to allow the user to send a verification email
if ($_POST['occurrence:record_status'] == 'V') {
$action = 'verified';
} elseif ($_POST['occurrence:record_status'] == 'R') {
$action = 'rejected';
} else {
$action = '';
}
if ($action) {
$occ = data_entry_helper::get_population_data(array('table' => 'occurrence', 'extraParams' => $auth['read'] + array('id' => $response['outer_id'], 'view' => 'detail')));
$occ = $occ[0];
$email_attr = data_entry_helper::get_population_data(array('table' => 'sample_attribute_value', 'extraParams' => $auth['read'] + array('caption' => 'Email', 'sample_id' => $occ['sample_id'])));
$verified_taxa_taxon_list_id = $_POST['occAttr:' . $args['occ_attr_id']];
if ($action == 'verified' && $verified_taxa_taxon_list_id != $occ['taxa_taxon_list_id']) {
$action = 'misidentified';
$verified_taxon = data_entry_helper::get_population_data(array('table' => 'taxa_taxon_list', 'extraParams' => $auth['read'] + array('id' => $verified_taxa_taxon_list_id)));
$occ = array_merge($occ, array('verified_taxon' => $verified_taxon[0]['taxon']));
}
$subject = self::get_email_component('subject', $action, $occ, $args);
$body = self::get_email_component('body', $action, $occ, $args);
if (!empty($email_attr[0]['value'])) {
$r .= '
<form id="email" action="" method="post">
<fieldset>
<legend>Send a notification email to the recorder.</legend>
<label>To: <input type="text" name="email_to" size="80" value="' . $email_attr[0]['value'] . '"></label><br />
<label>Subject: <input type="text" name="email_subject" size="80" value="' . $subject . '"></label><br />
<label>Body: <textarea name="email_body" rows="5" cols="80">' . $body . '</textarea></label><br />
<input type="hidden" name="email" value="1">
<input type="button" value="Send Email" onclick="
$(\'form#email\').attr(\'action\', submit_to());
$(\'form#email\').submit();
">
</fieldset>
</form>
';
} else {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all">The record has been ' . $action . '. The recorder did not leave an email address so cannot be notified.</div>';
}
}
}
}
}
}
//extract fixed parameters for report grid.
$params = explode(",", $args['fixed_params']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$extraParams[$key] = $val;
}
$columns = array(array('display' => 'Actions', 'actions' => array(array('caption' => 'Verify', 'javascript' => 'indicia_verify({occurrence_id}, true, ' . $user->uid . '); return false;'), array('caption' => 'Reject', 'javascript' => 'indicia_verify({occurrence_id}, false, ' . $user->uid . '); return false;'))));
//create a list of species to choose from with a hidden field indicating which to preselect
//with javascript
$taxon_list = data_entry_helper::get_population_data(array('table' => 'taxa_taxon_list', 'extraParams' => $auth['read'] + array('taxon_list_id' => $args['taxon_list_id'], 'orderby' => 'taxon_id')));
$species = '<select id="species-{occurrence_id}">';
foreach ($taxon_list as $taxon) {
$species .= '<option value="' . $taxon['id'] . '">' . $taxon['taxon'] . '</opton>';
}
$species .= '</select>';
$species .= '<input type="hidden" value="{taxa_taxon_list_id}" />';
$columns = array_merge($columns, array(array('display' => 'Taxon', 'template' => $species)));
$r .= data_entry_helper::report_grid(array('id' => 'verification-grid', 'dataSource' => $args['report_name'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => $columns, 'itemsPerPage' => 10, 'autoParamsForm' => $args['auto_params_form'], 'extraParams' => $extraParams, 'callback' => 'indicia_verification_2_species_init'));
$r .= '
<form id="verify" method="post" action="">
' . $auth['write'] . '
<input type="hidden" id="occurrence:id" name="occurrence:id" value="" />
<input type="hidden" id="occurrence:record_status" name="occurrence:record_status" value="" />
<input type="hidden" id="website_id" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" id="occurrence:verified_by_id" name="occurrence:verified_by_id" value="" />
<input type="hidden" id="occAttr:' . $args['occ_attr_id'] . '" name="occAttr:' . $args['occ_attr_id'] . '" value="" />
</form>
';
drupal_add_js('
var verifiers_mapping = "' . $args['verifiers_mapping'] . '";
var url = ' . json_encode(data_entry_helper::get_reload_link_parts()) . ';
var verified_species = "occAttr:' . $args['occ_attr_id'] . '";', 'inline');
//.........这里部分代码省略.........
示例5: foreach
*
* @package Core
* @subpackage Views
* @author Indicia Team
* @license http://www.gnu.org/licenses/gpl.html GPL
* @link http://code.google.com/p/indicia/
*/
require_once DOCROOT . 'client_helpers/data_entry_helper.php';
$readAuth = data_entry_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key'));
?>
<form class="iform" action="<?php
echo url::site() . 'trigger/save';
?>
" method="post">
<fieldset>
<legend>Enter the parameters for the trigger</legend>
<?php
// dump out the previous page form's values
foreach ($_POST as $key => $value) {
if ($key != 'submit' && substr($key, 0, 6) != 'param-') {
echo "<input type=\"hidden\" name=\"{$key}\" value=\"{$value}\"/>\n";
}
}
// Ask the report grid code to build us a parameters form.
echo data_entry_helper::report_grid(array('id' => 'params', 'paramsOnly' => true, 'dataSource' => $_POST['trigger:trigger_template_file'], 'readAuth' => $readAuth, 'ignoreParams' => array('date'), 'completeParamsForm' => false, 'paramDefaults' => $other_data['defaults']));
?>
</fieldset>
<?php
echo html::form_buttons(true);
?>
</form>
示例6: getSampleListGrid
/**
* When viewing the list of samples for this user, get the grid to insert into the page.
*/
protected static function getSampleListGrid($args, $node, $auth, $attributes)
{
global $user;
// get the CMS User ID attribute so we can filter the grid to this user
if ($user->uid === 0) {
return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => 'destination=node/' . $node->nid)) . '">login</a> to the website.');
}
$userIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS User ID', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
if (!$userIdAttr) {
return lang::get('This form must be used with a survey that has the CMS User ID attribute associated with it so records can be tagged against their creator.');
}
$userNameAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS Username', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
if (!$userNameAttr) {
return lang::get('This form must be used with a survey that has the CMS User Name attribute associated with it so records can be tagged against their creator.');
}
$passageAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'Passage', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
if (!$passageAttr) {
return lang::get('This form must be used with a survey that has the Passage attribute associated with it.');
}
if (isset($args['grid_report'])) {
$reportName = $args['grid_report'];
} else {
// provide a default in case the form settings were saved in an old version of the form
$reportName = 'reports_for_prebuilt_forms/MNHNL/mnhnl_butterflies';
}
$r = call_user_func(array(get_called_class(), 'getSampleListGridPreamble'));
$r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $reportName, 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getReportActions')), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 25, 'autoParamsForm' => true, 'extraParams' => array('survey_id' => $args['survey_id'], 'userID_attr_id' => $userIdAttr, 'userID' => iform_loctools_checkaccess($node, 'superuser') ? -1 : $user->uid, 'userName_attr_id' => $userNameAttr, 'passage_attr_id' => $passageAttr)));
$r .= '<form>';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new')) . '\'">';
$r .= "</form>\n<div style=\"display:none\" />\n <form id=\"form-delete-survey\" method=\"POST\">" . parent::$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:deleted\" value=\"t\" />\n </form>\n</div>";
data_entry_helper::$javascript .= "\ndeleteSurvey = function(sampleID){\n if(confirm(\"" . lang::get('LANG_ConfirmSurveyDelete') . " \"+sampleID)){\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/sample/\"+sampleID +\n \"?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $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').submit();\n }});\n };\n};";
return $r;
}
示例7: array
* $body - gridview_table object.
*/
require_once DOCROOT . 'client_helpers/data_entry_helper.php';
$readAuth = data_entry_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key'));
$colDefs = array();
foreach ($columns as $fieldname => $title) {
if (!isset($orderby)) {
$orderby = $fieldname;
}
$def = array('fieldname' => $fieldname, 'display' => empty($title) ? str_replace('_', ' ', ucfirst($fieldname)) : $title);
if ($fieldname == 'path') {
$def['img'] = true;
}
$colDefs[] = $def;
}
$actions = $this->get_action_columns();
foreach ($actions as &$action) {
if (substr($action['url'], 0, 4) != 'http') {
$action['url'] = url::base(true) . $action['url'];
}
}
if (count($actions) > 0) {
$colDefs[] = array('display' => 'Actions', 'actions' => $actions);
}
echo data_entry_helper::report_grid(array('id' => $id, 'mode' => 'direct', 'dataSource' => $source, 'view' => 'gv', 'readAuth' => $readAuth, 'includeAllColumns' => false, 'columns' => $colDefs, 'extraParams' => array('orderby' => $orderby), 'filters' => $filter, 'itemsPerPage' => kohana::config('pagination.default.items_per_page')));
data_entry_helper::link_default_stylesheet();
// No need to re-link to jQuery
data_entry_helper::$dumped_resources[] = 'jquery';
data_entry_helper::$dumped_resources[] = 'jquery_ui';
data_entry_helper::$dumped_resources[] = 'fancybox';
echo data_entry_helper::dump_javascript();
示例8: getSampleListGrid
/**
* When viewing the list of samples for this user, get the grid to insert into the page.
*/
protected static function getSampleListGrid($args, $node, $auth, $attributes)
{
global $user;
// get the CMS User ID attribute so we can filter the grid to this user
$userIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS User ID');
if (!$userIdAttr) {
return lang::get('This form must be used with a survey that has the CMS User ID attribute associated with it so records can be tagged against their creator.');
}
$userNameAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS Username');
if (!$userNameAttr) {
return lang::get('This form must be used with a survey that has the CMS User Name attribute associated with it so records can be tagged against their creator.');
}
$targetSpeciesIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', $args['targetSpeciesAttr']);
if (!$targetSpeciesIdAttr) {
return lang::get('This form must be used with a survey that has the ' . $args['targetSpeciesAttr'] . ' attribute associated with it.');
}
if ($user->uid === 0) {
// Return a login link that takes you back to this form when done.
return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => 'destination=node/' . $node->nid)) . '">login</a> to the website.');
}
if (isset($args['grid_report'])) {
$reportName = $args['grid_report'];
} else {
// provide a default in case the form settings were saved in an old version of the form
$reportName = 'reports_for_prebuilt_forms/MNHNL/mnhnl_reptiles';
}
$extraParams = array('survey_id' => $args['survey_id'], 'userID_attr_id' => $userIdAttr, 'userID' => iform_loctools_checkaccess($node, 'superuser') ? -1 : $user->uid, 'userName_attr_id' => $userNameAttr, 'userName' => $user->name, 'target_species_attr_id' => $targetSpeciesIdAttr);
if (isset($args['filterAttrs']) && $args['filterAttrs'] != '') {
global $custom_terms;
$filterAttrs = explode(',', $args['filterAttrs']);
$idxN = 1;
foreach ($filterAttrs as $idx => $filterAttr) {
$filterAttr = explode(':', $filterAttr);
switch ($filterAttr[0]) {
case 'Display':
break;
case 'Parent':
$extraParams['attr_id_' . $idxN] = iform_mnhnl_getAttrID($auth, $args, 'location', $filterAttr[1]);
$custom_terms['attr_' . $idxN] = lang::get($filterAttr[1]);
$idxN++;
break;
default:
$extraParams['attr_id_' . $idxN] = iform_mnhnl_getAttrID($auth, $args, 'location', $filterAttr[0]);
$custom_terms['attr_' . $idxN] = lang::get($filterAttr[0]);
$idxN++;
break;
}
}
}
$r = call_user_func(array(get_called_class(), 'getSampleListGridPreamble'));
$r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $reportName, 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getReportActions')), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 25, 'autoParamsForm' => true, 'extraParams' => $extraParams));
$r .= '<form>';
if (isset($args['multiple_occurrence_mode']) && $args['multiple_occurrence_mode'] == 'either') {
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Single') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new')) . '\'">';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Grid') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new&gridmode')) . '\'">';
} else {
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new')) . '\'">';
}
$r .= '</form>
<div style="display:none" />
<form id="form-delete-survey" action="' . iform_mnhnl_getReloadPath() . '" method="POST">' . $auth['write'] . '
<input type="hidden" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '" />
<input type="hidden" name="sample:id" value="" />
<input type="hidden" name="sample:deleted" value="t" />
</form>
</div>
<div style="display:none" />
<form id="form-delete-survey-location" action="' . iform_mnhnl_getReloadPath() . '" method="POST">' . $auth['write'] . '
<input type="hidden" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '" />
<input type="hidden" name="sample:id" value="" />
<input type="hidden" name="sample:deleted" value="t" />
<input type="hidden" name="location:id" value="" />
<input type="hidden" name="location:deleted" value="t" />
</form>
</div>';
data_entry_helper::$javascript .= "\r\ndeleteSurvey = function(sampleID){\r\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/sample/\"+sampleID +\r\n \"?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "\" +\r\n \"&callback=?\", function(data) {\r\n if (data.length>0) {\r\n jQuery('#form-delete-survey').find('[name=sample\\:id]').val(data[0].id);\r\n jQuery('#form-delete-survey-location').find('[name=sample\\:id]').val(data[0].id);\r\n jQuery('#form-delete-survey-location').find('[name=location\\:id]').val(data[0].location_id);\r\n // next get the location ID from sample, count the samples that are attached to that location\r\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/sample?location_id=\"+data[0].location_id +\r\n \"&parent_id=NULL&mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "\" +\r\n \"&callback=?\", function(sdata) {\r\n if (sdata.length==1) {\r\n var dialog = \$('<p>" . lang::get('The site only has this survey associated with it. Do you wish to delete the site as well?') . "</p>').\r\n dialog({ title: 'Delete Location Data?',\r\n width: 400,\r\n buttons: {\r\n 'Cancel': function() { dialog.dialog('close'); },\r\n 'Survey Only': function() {\r\n dialog.dialog('close');\r\n jQuery('#form-delete-survey').submit();\r\n },\r\n 'Site and Survey': function() {\r\n dialog.dialog('close');\r\n jQuery('#form-delete-survey-location').submit();\r\n }}});\r\n } else if (sdata.length > 1) {\r\n if(confirm(\"" . lang::get('Are you sure you wish to delete survey ') . "\"+sampleID)){\r\n jQuery('#form-delete-survey').submit();\r\n }\r\n }\r\n });\r\n }\r\n });\r\n};\n";
return $r;
}
示例9: getSampleListGrid
protected static function getSampleListGrid($args, $node, $auth, $attributes)
{
global $user;
if ($user->uid === 0) {
return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => 'destination=node/' . $node->nid)) . '">login</a> to the website.');
}
$userIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS User ID');
if (!$userIdAttr) {
return lang::get('This form must be used with a survey that has the CMS User ID sample attribute associated with it so records can be tagged against their creator.');
}
$usernameAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS Username');
if (!$usernameAttr) {
return lang::get('This form must be used with a survey that has the CMS Username sampleattribute associated with it so records can be tagged against their creator.');
}
$villageAttr = iform_mnhnl_getAttrID($auth, $args, 'location', 'Village');
if (!$villageAttr) {
$villageAttr = iform_mnhnl_getAttrID($auth, $args, 'location', 'VillageDD');
}
if (!$villageAttr) {
return lang::get('This form must be used with a survey that has either the Village or VillageDD location attributes associated with it.');
}
$communeAttr = iform_mnhnl_getAttrID($auth, $args, 'location', 'Commune');
if (!$communeAttr) {
return lang::get('This form must be used with a survey that has the Commune location attribute associated with it.');
}
$reportName = $args['grid_report'];
if (method_exists(get_called_class(), 'getSampleListGridPreamble')) {
$r = call_user_func(array(get_called_class(), 'getSampleListGridPreamble'));
} else {
$r = '';
}
$isAdmin = isset($args['edit_permission']) && $args['edit_permission'] != "" && user_access($args['edit_permission']);
$isExpert = isset($args['ro_permission']) && $args['ro_permission'] != "" && user_access($args['ro_permission']);
$extraparams = array('survey_id' => $args['survey_id'], 'userID_attr_id' => $userIdAttr, 'username_attr_id' => $usernameAttr, 'village_attr_id' => $villageAttr, 'commune_attr_id' => $communeAttr);
if ($isAdmin || $isExpert) {
$extraparams['userID'] = -1;
} else {
$extraparams['userID'] = $user->uid;
}
$r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $reportName, 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getReportActions')), 'itemsPerPage' => $args['grid_num_rows'], 'autoParamsForm' => true, 'extraParams' => $extraparams));
$r .= '<form>';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new')) . '\'">';
$r .= "</form>\n<div style=\"display:none\" />\n <form id=\"form-delete-survey\" action=\"" . iform_mnhnl_getReloadPath() . "\" method=\"POST\">" . parent::$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:deleted\" value=\"t\" />\n </form>\n</div>";
if (!(function_exists('hostsite_get_user_field') && data_entry_helper::$entity_to_load['sample:created_by_id'] != 1 && data_entry_helper::$entity_to_load['sample:created_by_id'] !== ($userID = hostsite_get_user_field('indicia_user_id')))) {
$userID = 1;
}
data_entry_helper::$javascript .= "\ndeleteSurvey = function(sampleID){\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/sample/\"+sampleID +\n \"?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "\" +\n \"&callback=?\", function(data) {\n if (data.length>0) {\n if(" . ($isExpert ? 0 : 1) . " || data[0].created_by_id == " . $userID . "){\n if(confirm(\"" . lang::get('Are you sure you wish to delete survey') . " \"+sampleID+\"?\")){\n jQuery('#form-delete-survey').find('[name=sample\\:id]').val(data[0].id);\n jQuery('#form-delete-survey').submit();\n }\n } else\n alert(\"" . lang::get('You do not have permissions to delete survey') . " \"+sampleID+\". " . lang::get('You only have read only permissions on this survey.') . "\");\n }\n });\n};";
return $r;
}
示例10: getSampleListGrid
protected static function getSampleListGrid($args, $node, $auth, $attributes)
{
global $user;
// get the CMS User ID attribute so we can filter the grid to this user
$userIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS User ID', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
if (!$userIdAttr) {
return lang::get('getSampleListGrid function: This form must be used with a survey that has the CMS User ID sample attribute associated with it, so records can be tagged against their creator.');
}
$extraParams = array('survey_id' => $args['survey_id'], 'userID_attr_id' => $userIdAttr, 'userID' => user_access($args['edit_permission']) ? -1 : $user->uid);
// use -1 if admin - non logged in will not get this far.
$userNameAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'CMS Username', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
if ($userNameAttr) {
$extraParams['userName_attr_id'] = $userNameAttr;
}
if (isset($args['targetSpeciesAttr']) && $args['targetSpeciesAttr'] != "") {
$targetSpeciesIdAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', $args['targetSpeciesAttr'], $args['target_species_subsample_method_id']);
$extraParams['target_species_attr_id'] = $targetSpeciesIdAttr;
}
if (isset($args['filterAttrs']) && $args['filterAttrs'] != '') {
global $custom_terms;
$filterAttrs = explode(',', $args['filterAttrs']);
$idxN = 1;
foreach ($filterAttrs as $idx => $filterAttr) {
$filterAttr = explode(':', $filterAttr);
switch ($filterAttr[0]) {
case 'Parent':
$custom_terms['location name'] = lang::get('location name');
break;
case 'Shape':
$extraParams['attr_id_' . $idxN] = iform_mnhnl_getAttrID($auth, $args, 'location', $filterAttr[1]);
$custom_terms['attr_' . $idxN] = lang::get($filterAttr[1]);
$idxN++;
break;
default:
$extraParams['attr_id_' . $idxN] = iform_mnhnl_getAttrID($auth, $args, 'location', $filterAttr[0]);
$custom_terms['attr_' . $idxN] = lang::get($filterAttr[0]);
$idxN++;
break;
}
}
}
$r = call_user_func(array(get_called_class(), 'getSampleListGridPreamble'));
$r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $args['grid_report'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getReportActions')), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 25, 'autoParamsForm' => true, 'extraParams' => $extraParams));
$r .= '<form>';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'new')) . '\'">';
$r .= '</form>
<div style="display:none" />
<form id="form-delete-survey" action="' . iform_mnhnl_getReloadPath() . '" method="POST">' . $auth['write'] . '
<input type="hidden" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '" />
<input type="hidden" name="sample:id" value="" />
<input type="hidden" name="sample:deleted" value="t" />
</form>
</div>';
data_entry_helper::$javascript .= "\ndeleteSurvey = function(sampleID){\n if(confirm(\"Are you sure you wish to delete survey \"+sampleID)){\n jQuery.getJSON(\"" . data_entry_helper::$base_url . "/index.php/services/data/sample/\"+sampleID +\n \"?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $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').submit();\n }});\n };\n};";
return $r;
}
示例11: getSampleListGrid
/**
* Override function to add the report parameter for the ID of the custom attribute which holds the linked sample.
* Depends upon a report existing that uses the parameter e.g. npms_sample_occurrence_samples
*/
protected static function getSampleListGrid($args, $node, $auth, $attributes)
{
global $user;
// User must be logged in before we can access their records.
if ($user->uid === 0) {
// Return a login link that takes you back to this form when done.
return lang::get('Before using this facility, please <a href="' . url('user/login', array('query' => array('destination=node/' . $node->nid))) . '">login</a> to the website.');
}
// Get the Indicia User ID to filter on.
if (function_exists('hostsite_get_user_field')) {
$iUserId = hostsite_get_user_field('indicia_user_id');
if (isset($iUserId)) {
$filter = array('survey_id' => $args['survey_id'], 's1AttrID' => $args['survey_1_attr'], 'iUserID' => $iUserId);
}
}
// Return with error message if we cannot identify the user records
if (!isset($filter)) {
return lang::get('LANG_No_User_Id');
}
$r = data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => $args['grid_report'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => self::getReportActions(), 'itemsPerPage' => isset($args['grid_num_rows']) ? $args['grid_num_rows'] : 10, 'autoParamsForm' => true, 'extraParams' => $filter));
$r .= '<form>';
if (isset($args['multiple_occurrence_mode']) && $args['multiple_occurrence_mode'] == 'either') {
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Single') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => array('new'))) . '\'">';
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample_Grid') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => array('new&gridmode'))) . '\'">';
} else {
$r .= '<input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => array('new' => ''))) . '\'">';
}
$r .= '</form>';
return $r;
}
示例12: get_form
/**
* Return the Indicia form code.
* Expects there to be a sample attribute with caption 'Email' containing the email
* address.
* @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)
{
if (isset($_POST['enable'])) {
module_enable(array('iform_ajaxproxy'));
drupal_set_message(lang::get('The Indicia AJAX Proxy module has been enabled.', 'info'));
} elseif (!defined('IFORM_AJAXPROXY_PATH')) {
$r = '<p>' . lang::get('The Indicia AJAX Proxy module must be enabled to use this form. This lets the form save verifications to the ' . 'Indicia Warehouse without having to reload the page.') . '</p>';
$r .= '<form method="post">';
$r .= '<input type="hidden" name="enable" value="t"/>';
$r .= '<input type="submit" value="' . lang::get('Enable Indicia AJAX Proxy') . '"/>';
$r .= '</form>';
return $r;
}
if (function_exists('drupal_add_js')) {
drupal_add_js('misc/collapse.js');
}
iform_load_helpers(array('data_entry_helper', 'map_helper'));
// fancybox for popup comment forms etc
data_entry_helper::add_resource('fancybox');
data_entry_helper::add_resource('validation');
global $user, $indicia_templates;
$indicia_user_id = self::get_indicia_user_id($args);
$auth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
//extract fixed parameters for report grid.
$params = explode("\n", $args['param_presets']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$extraParams[$key] = $val;
}
// plus defaults which are not fixed
$params = explode("\n", $args['param_defaults']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$paramDefaults[$key] = $val;
}
$opts = array('id' => 'verification-grid', 'dataSource' => $args['report_name'], 'mode' => 'report', 'readAuth' => $auth, 'rowId' => 'occurrence_id', 'itemsPerPage' => 10, 'autoParamsForm' => true, 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults, 'fieldsetClass' => 'collapsible collapsed');
if (!empty($args['columns_config'])) {
$opts['columns'] = json_decode($args['columns_config'], true);
}
$grid = data_entry_helper::report_grid($opts);
$r = str_replace(array('{grid}'), array($grid), self::get_template_grid_left($args, $auth));
$link = data_entry_helper::get_reload_link_parts();
global $user;
data_entry_helper::$javascript .= 'indiciaData.username = "' . $user->name . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.rootUrl = "' . $link['path'] . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.website_id = ' . $args['website_id'] . ";\n";
data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url($node, 'occurrence') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.ajaxUrl="' . url('iform/ajax/verification_3') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.autoDiscard = ' . $args['auto_discard_rows'] . ";\n";
// output some translations for JS to use
data_entry_helper::$javascript .= "indiciaData.popupTranslations = {};\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.title="' . lang::get('Add {1} comment') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.save="' . lang::get('Save and {1}') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbV="' . lang::get('verify') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbR="' . lang::get('reject') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.V="' . lang::get('Verification') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.R="' . lang::get('Rejection') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailTitle="' . lang::get('Email record details for checking') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sendEmail="' . lang::get('Send Email') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailSent="' . lang::get('The email was sent successfully.') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.popupTranslations.requestManualEmail="' . lang::get('The webserver is not correctly configured to send emails. Please send the following email usual your email client:') . "\";\n";
data_entry_helper::$javascript .= "indiciaData.statusTranslations = {};\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.V = "' . lang::get('Verified') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.R = "' . lang::get('Rejected') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.I = "' . lang::get('In progress') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.T = "' . lang::get('Test record') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.S = "' . lang::get('Sent for verification') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.statusTranslations.C = "' . lang::get('Awaiting verification') . "\";\n";
data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_verifier = "' . $args['email_subject_send_to_verifier'] . "\";\n";
$body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_verifier']);
data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_verifier = "' . $body . "\";\n";
return $r;
}
示例13: get_control_subsamplegrid
/**
* Get the grid of subsamples.
*/
protected static function get_control_subsamplegrid($auth, $args, $tabalias, $options)
{
if (!array_key_exists('sample:id', data_entry_helper::$entity_to_load) || !data_entry_helper::$entity_to_load['sample:id']) {
return 'You have to save a new supersample before you can access aubsamples/occurrences for it.<br/>';
}
$r = "<div id=\"subSampleList\">";
$r .= data_entry_helper::report_grid(array('id' => 'subsample-grid', 'dataSource' => $options['grid_report'], 'mode' => 'report', 'readAuth' => self::$auth['read'], 'columns' => call_user_func(array(get_called_class(), 'getSubsampleReportActions')), 'itemsPerPage' => $options['grid_rows'], 'autoParamsForm' => true, 'extraParams' => array('survey_id' => $args['survey_id'], 'parent_id' => data_entry_helper::$entity_to_load['sample:id'])));
if ($args['multiple_occurrence_mode'] == 'either') {
$r .= '<input type="button" value="' . lang::get('LANG_Add_SubSample_Single') . '" id="new-subsample-button">';
$r .= '<input type="button" value="' . lang::get('LANG_Add_SubSample_Grid') . '" id="new-subsample-button-grid">';
} else {
$r .= '<input type="button" value="' . lang::get('LANG_Add_SubSample') . '" id="new-subsample-button">';
}
$r .= "</div>\n";
data_entry_helper::$onload_javascript .= "\njQuery('#new-subsample-button').click(function(e) {\n var form = jQuery('<form>');\n form.attr('action', '" . self::$currentUrl . "');\n form.attr('method', 'POST');\n var addParam = function(paramName, paramValue){\n var input = \$('<input type=\"hidden\">');\n input.attr({ 'id': paramName,\n 'name': paramName,\n 'value': paramValue });\n form.append(input);\n };\n addParam('newsample_parent_id', " . data_entry_helper::$entity_to_load['sample:id'] . ");\n addParam('newsample_date', jQuery('[name=sample:date]').val());\n // Submit the form, then remove it from the page\n form.appendTo(document.body);\n form.submit();\n form.remove(); \n});\njQuery('#new-subsample-button-grid').click(function(e) {\n var form = jQuery('<form>');\n form.attr('action', '" . self::$currentUrl . "');\n form.attr('method', 'POST');\n var addParam = function(paramName, paramValue){\n var input = \$('<input type=\"hidden\">');\n input.attr({ 'id': paramName,\n 'name': paramName,\n 'value': paramValue });\n form.append(input);\n };\n addParam('newsample_parent_id', " . data_entry_helper::$entity_to_load['sample:id'] . ");\n addParam('newsample_date', jQuery('[name=sample:date]').val());\n addParam('gridmode', 'YES');\n // Submit the form, then remove it from the page\n form.appendTo(document.body);\n form.submit();\n form.remove(); \n});";
return $r;
}
示例14: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node)
{
global $user;
$logged_in = $user->uid > 0;
$r = '';
// 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';
$mode = 0;
// default mode : display survey selector
// mode 1: display new sample
// mode 2: display existing sample
$loadID = null;
$displayThisOcc = true;
// when populating from the DB rather than POST we have to be
// careful with selection object, as geom in wrong format.
if ($_POST) {
if (!is_null(data_entry_helper::$entity_to_load)) {
$mode = 2;
// errors with new sample, entity poulated with post, so display this data.
}
// else valid save, so go back to gridview: default mode 0
} else {
if (array_key_exists('sample_id', $_GET)) {
$mode = 2;
$loadID = $_GET['sample_id'];
} else {
if (array_key_exists('newSample', $_GET)) {
$mode = 1;
data_entry_helper::$entity_to_load = array();
}
}
// else default to mode 0
}
///////////////////////////////////////////////////////////////////
// default mode 0 : display survey selector
///////////////////////////////////////////////////////////////////
if ($mode == 0) {
$r .= data_entry_helper::report_grid(array('id' => 'samples-grid', 'dataSource' => 'reports_for_prebuilt_forms/simple_sample_list_1', 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => array(array('display' => 'Actions', 'actions' => array(array('caption' => 'Edit', 'url' => '{currentUrl}', 'urlParams' => array('sample_id' => '{sample_id}'))))), 'itemsPerPage' => 10, 'autoParamsForm' => true, 'extraParams' => array('survey_id' => $args['survey_id'], 'userID_attr_id' => $args['uid_attr_id'], 'userID' => $user->uid)));
$r .= '<form><input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample')) . '\'"></form>';
return $r;
}
///////////////////////////////////////////////////////////////////
data_entry_helper::$javascript .= "\n// Create vector layers: one to display the location onto, and another for the occurrence list\n// the default edit layer is used for the occurrences themselves\nlocStyleMap = new OpenLayers.StyleMap({\n \"default\": new OpenLayers.Style({\n fillColor: \"Green\",\n strokeColor: \"Black\",\n fillOpacity: 0.3,\n strokeWidth: 1\n })\n });\nlocationLayer = new OpenLayers.Layer.Vector(\"" . lang::get("LANG_Location_Layer") . "\",\n {styleMap: locStyleMap});\n";
if ($loadID) {
// Can't cache these as data may have just changed
data_entry_helper::$entity_to_load['occurrence:record_status'] = 'I';
$url = $svcUrl . '/data/sample/' . $loadID;
$url .= "?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"];
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entity = json_decode(curl_exec($session), true);
// Attributes should be loaded by get_attributes.
data_entry_helper::$entity_to_load = array();
foreach ($entity[0] as $key => $value) {
data_entry_helper::$entity_to_load['sample:' . $key] = $value;
}
$url = $svcUrl . '/data/occurrence';
$url .= "?mode=json&view=detail&auth_token=" . $auth['read']['auth_token'] . "&nonce=" . $auth['read']["nonce"] . "&sample_id=" . $loadID . "&deleted=FALSE";
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entities = json_decode(curl_exec($session), true);
foreach ($entities as $entity) {
data_entry_helper::$entity_to_load['occurrence:record_status'] = $entity['record_status'];
data_entry_helper::$entity_to_load['sc:' . $entity['taxa_taxon_list_id'] . ':' . $entity['id'] . ':present'] = true;
}
data_entry_helper::$entity_to_load['sample:geom'] = '';
// value received from db is not WKT, which is assumed by all the code.
data_entry_helper::$entity_to_load['sample:date'] = data_entry_helper::$entity_to_load['sample:date_start'];
// bit of a bodge to get around vague dates.
}
$defAttrOptions = array('extraParams' => $auth['read']);
// $r .= "<h1>MODE = ".$mode."</h1>";
// $r .= "<h2>readOnly = ".$readOnly."</h2>";
$r = "<form method=\"post\" id=\"entry_form\">\n";
// Insert authorisation tokens to update the Warehouse.
$r .= $auth['write'];
$r .= "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" id=\"survey_id\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
if (array_key_exists('sample:id', data_entry_helper::$entity_to_load)) {
$r .= "<input type=\"hidden\" id=\"sample:id\" name=\"sample:id\" value=\"" . data_entry_helper::$entity_to_load['sample:id'] . "\" />\n";
}
// request automatic JS validation
data_entry_helper::enable_validation('entry_form');
$attributes = data_entry_helper::getAttributes(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']));
if ($logged_in) {
// If logged in, output some hidden data about the user
$uid = $user->uid;
$email = $user->mail;
$username = $user->name;
$uid_attr_id = $args['uid_attr_id'];
$email_attr_id = $args['email_attr_id'];
$username_attr_id = $args['username_attr_id'];
// This assumes that we have the following attributes : no built in error checking.
$r .= "<input type=\"hidden\" name=\"" . $attributes[$uid_attr_id]['fieldname'] . "\" value=\"{$uid}\" />\n";
$r .= "<input type=\"hidden\" name=\"" . $attributes[$email_attr_id]['fieldname'] . "\" value=\"{$email}\" />\n";
//.........这里部分代码省略.........
示例15: array
$svcUrl = data_entry_helper::$base_url . 'index.php/services';
?>
<head>
<title>Report Grid Demo</title>
<style type="text/css">
#charts .ui-widget-header {
margin: 0.2em;
padding: 0.2em;
}
#charts .ui-widget {
margin: 1em;
}
</style>
</head>
<body>
<?php
data_entry_helper::link_default_stylesheet();
$readAuth = data_entry_helper::get_read_auth($config['website_id'], $config['password']);
echo data_entry_helper::report_grid(array('dataSource' => 'occurrences_by_survey', 'mode' => 'report', 'readAuth' => $readAuth, 'columns' => array(array('fieldname' => 'survey', 'display' => 'Survey Title'), array('fieldname' => 'count', 'display' => 'Number of Occurrences'), array('display' => 'Custom column', 'template' => '{survey} has {count} occurrences')), 'includeAllColumns' => false, 'itemsPerPage' => 5, 'extraParams' => array('survey' => 'A')));
echo "<div id=\"charts\">\n";
echo data_entry_helper::report_chart(array('title' => 'Bar chart of record count per survey', 'id' => 'barChart', 'dataSource' => 'occurrences_by_survey', 'mode' => 'report', 'readAuth' => $readAuth, 'chartType' => 'bar', 'yValues' => 'count', 'xLabels' => 'survey', 'width' => 600, 'axesOptions' => array('yaxis' => array('min' => 0, 'max' => '3', 'tickInterval' => 1))));
echo data_entry_helper::report_chart(array('title' => 'Demonstration line chart (y=survey website id, x=survey id)', 'id' => 'lineChart', 'dataSource' => array('survey', 'term'), 'mode' => 'direct', 'readAuth' => $readAuth, 'chartType' => 'line', 'yValues' => array('website_id', 'language_id'), 'xValues' => 'id', 'width' => 600, 'legendOptions' => array('show' => true)));
echo data_entry_helper::report_chart(array('title' => 'Demonstration pie chart of occurrences per survey', 'id' => 'pieChart', 'dataSource' => 'occurrences_by_survey', 'mode' => 'report', 'readAuth' => $readAuth, 'chartType' => 'pie', 'yValues' => 'count', 'xLabels' => 'survey', 'legendOptions' => array('show' => true), 'width' => 500));
echo "</div>";
echo data_entry_helper::dump_javascript();
?>
</body>
</html>