setup exporting
This commit is contained in:
36
go-form-plugin/export/csv.php
Normal file
36
go-form-plugin/export/csv.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
go_form_admin_action('export_csv');
|
||||||
|
if (!isset($_POST['value_one'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_id = intval($_POST['value_one']);
|
||||||
|
$form = go_form_get_form_by_id($form_id);
|
||||||
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
|
$entries = go_form_get_entries($form_id);
|
||||||
|
|
||||||
|
header('Content-Type: text/csv; charset=utf-8');
|
||||||
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||||
|
|
||||||
|
$output = fopen('php://output', 'w');
|
||||||
|
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
||||||
|
|
||||||
|
foreach ($entries as $e) {
|
||||||
|
global $ranks;
|
||||||
|
fputcsv($output, [
|
||||||
|
$e->id,
|
||||||
|
$e->first_name,
|
||||||
|
$e->last_name,
|
||||||
|
$e->country,
|
||||||
|
$e->club,
|
||||||
|
$ranks[$e->rank] ?? '',
|
||||||
|
$e->email,
|
||||||
|
$e->egd_number,
|
||||||
|
$e->comment,
|
||||||
|
$e->created_at
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($output);
|
||||||
36
go-form-plugin/export/mcmahon.php
Normal file
36
go-form-plugin/export/mcmahon.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
go_form_admin_action('export_mcmahon');
|
||||||
|
if (!isset($_POST['value_one'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_id = intval($_POST['value_one']);
|
||||||
|
$form = go_form_get_form_by_id($form_id);
|
||||||
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
|
$entries = go_form_get_entries($form_id);
|
||||||
|
|
||||||
|
header('Content-Type: text/csv; charset=utf-8');
|
||||||
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||||
|
|
||||||
|
$output = fopen('php://output', 'w');
|
||||||
|
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
||||||
|
|
||||||
|
foreach ($entries as $e) {
|
||||||
|
global $ranks;
|
||||||
|
fputcsv($output, [
|
||||||
|
$e->id,
|
||||||
|
$e->first_name,
|
||||||
|
$e->last_name,
|
||||||
|
$e->country,
|
||||||
|
$e->club,
|
||||||
|
$ranks[$e->rank] ?? '',
|
||||||
|
$e->email,
|
||||||
|
$e->egd_number,
|
||||||
|
$e->comment,
|
||||||
|
$e->created_at
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($output);
|
||||||
36
go-form-plugin/export/opengoth.php
Normal file
36
go-form-plugin/export/opengoth.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
go_form_admin_action('export_opengoth');
|
||||||
|
if (!isset($_POST['value_one'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_id = intval($_POST['value_one']);
|
||||||
|
$form = go_form_get_form_by_id($form_id);
|
||||||
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
|
$entries = go_form_get_entries($form_id);
|
||||||
|
|
||||||
|
header('Content-Type: text/json; charset=utf-8');
|
||||||
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||||
|
|
||||||
|
$output = fopen('php://output', 'w');
|
||||||
|
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
||||||
|
|
||||||
|
foreach ($entries as $e) {
|
||||||
|
global $ranks;
|
||||||
|
fputcsv($output, [
|
||||||
|
$e->id,
|
||||||
|
$e->first_name,
|
||||||
|
$e->last_name,
|
||||||
|
$e->country,
|
||||||
|
$e->club,
|
||||||
|
$ranks[$e->rank] ?? '',
|
||||||
|
$e->email,
|
||||||
|
$e->egd_number,
|
||||||
|
$e->comment,
|
||||||
|
$e->created_at
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($output);
|
||||||
24
go-form-plugin/export/pairgoth.php
Normal file
24
go-form-plugin/export/pairgoth.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
go_form_admin_action('export_pairgoth');
|
||||||
|
if (!isset($_POST['value_one'])) {
|
||||||
|
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_id = intval($_POST['value_one']);
|
||||||
|
$form = go_form_get_form_by_id($form_id);
|
||||||
|
$form_name = $form ? $form->name : 'Unknown Form';
|
||||||
|
$entries = go_form_get_entries($form_id);
|
||||||
|
|
||||||
|
header('Content-Type: text/json; charset=utf-8');
|
||||||
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.tour"');
|
||||||
|
|
||||||
|
$output = fopen('php://output', 'w');
|
||||||
|
|
||||||
|
fwrite($output, "{}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fclose($output);
|
||||||
@@ -225,45 +225,33 @@ function go_form_delete_form()
|
|||||||
}
|
}
|
||||||
add_action('admin_post_go_form_delete_form', 'go_form_delete_form');
|
add_action('admin_post_go_form_delete_form', 'go_form_delete_form');
|
||||||
|
|
||||||
function go_form_export()
|
function go_form_export_csv()
|
||||||
{
|
{
|
||||||
go_form_admin_action('export');
|
include_once 'export/csv.php';
|
||||||
if (!isset($_POST['value_one'])) {
|
|
||||||
wp_redirect(admin_url('admin.php?page=go-form-settings'));
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
add_action('admin_post_go_form_export_csv', 'go_form_export_csv');
|
||||||
|
|
||||||
$form_id = intval($_POST['value_one']);
|
function go_form_export_pairgoth()
|
||||||
$form = go_form_get_form_by_id($form_id);
|
{
|
||||||
$form_name = $form ? $form->name : 'Unknown Form';
|
include_once 'export/pairgoth.php';
|
||||||
$entries = go_form_get_entries($form_id);
|
|
||||||
|
|
||||||
header('Content-Type: text/csv; charset=utf-8');
|
|
||||||
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
|
||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
|
||||||
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
|
||||||
|
|
||||||
foreach ($entries as $e) {
|
|
||||||
global $ranks;
|
|
||||||
fputcsv($output, [
|
|
||||||
$e->id,
|
|
||||||
$e->first_name,
|
|
||||||
$e->last_name,
|
|
||||||
$e->country,
|
|
||||||
$e->club,
|
|
||||||
$ranks[$e->rank] ?? '',
|
|
||||||
$e->email,
|
|
||||||
$e->egd_number,
|
|
||||||
$e->comment,
|
|
||||||
$e->created_at
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose($output);
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
add_action('admin_post_go_form_export', 'go_form_export');
|
add_action('admin_post_go_form_export_pairgoth', 'go_form_export_pairgoth');
|
||||||
|
|
||||||
|
function go_form_export_opengotha()
|
||||||
|
{
|
||||||
|
include_once 'export/opengoth.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_export_opengotha', 'go_form_export_opengotha');
|
||||||
|
|
||||||
|
function go_form_export_mcmahon()
|
||||||
|
{
|
||||||
|
include_once 'export/mcmahon.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
add_action('admin_post_go_form_export_mcmahon', 'go_form_export_mcmahon');
|
||||||
|
|
||||||
// ========== Admin Page ====================
|
// ========== Admin Page ====================
|
||||||
function go_form_admin_menu()
|
function go_form_admin_menu()
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ if (isset($_GET['created']))
|
|||||||
echo '<div style="margin-bottom:15px">';
|
echo '<div style="margin-bottom:15px">';
|
||||||
|
|
||||||
action_button('go_form_delete_form', 'Delete Form', 'Delete this form and ALL entries?', $selected_form_id);
|
action_button('go_form_delete_form', 'Delete Form', 'Delete this form and ALL entries?', $selected_form_id);
|
||||||
action_button('go_form_export', 'Export to CSV', 'Confrm Export', $selected_form_id);
|
action_button('go_form_export_csv', 'Export to CSV', 'Confrm Export', $selected_form_id);
|
||||||
|
action_button('go_form_export_pairgoth', 'Export to Pairgoth', 'Confrm Export', $selected_form_id);
|
||||||
|
action_button('go_form_export_opengotha', 'Export to Opengoth', 'Confrm Export', $selected_form_id);
|
||||||
|
action_button('go_form_export_mcmahon', 'Export to McMahon', 'Confrm Export', $selected_form_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
$entries = go_form_get_entries($selected_form_id);
|
$entries = go_form_get_entries($selected_form_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user