Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
5bdadc6a
authored
2011-09-19 17:44:24 -0400
by
Marty Penner
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Adding form to MySQLTable output. refs #981
1 parent
f29753ab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
6 deletions
com/MySQLTable/MySQLTable.php
com/MySQLTable/MySQLTable.php
View file @
5bdadc6
<?php
namespace
Tz\WordPress\Tools\MySQLTable
;
function
array2table
(
$arr
,
$width
=
"100%"
)
{
function
array2table
(
$arr
,
$width
=
"100%"
,
$with_form
=
true
)
{
$count
=
count
(
$arr
);
if
(
$count
>
0
){
if
(
!
$count
)
echo
''
;
reset
(
$arr
);
$num
=
count
(
current
(
$arr
));
echo
"<table border=
\"
0
\"
cellpadding=
\"
5
\"
cellspacing=
\"
0
\"
width=
\"
$width
\"
class=
\"
cbv-report-list
\"
>
\n
"
;
if
(
$with_form
)
{
echo
<<<HTML
<form id="report-form" action="http://cbv/wp-admin/admin.php?page=report_manager&action=run_action&report_id={$_GET['report_id']}&action_to_run=change_user_status" method="post">
<div style="margin-bottom: 20px">
<label for="action-list"><h4 style="margin-bottom: 5px">With Selected:</h4></label>
<select id="action-list">
<option value="change_user_status">Change User Status</option>
<option value="change_user_role">Change User Role</option>
<option value="add_ce_hours">Add Continuing Education Hours</option>
<option value="send_notification">Send Notification</option>
<option value="create_invoice">Create an Invoice / Credit Note</option>
</select>
<input type="submit" value="Go" />
</div>
HTML;
}
echo
"<table border=
\"
0
\"
cellpadding=
\"
5
\"
cellspacing=
\"
0
\"
width=
\"
$width
\"
class=
\"
cbv-report-list
\"
>
\n
"
;
echo
"<thead>
\n
"
;
echo
"<tr>
\n
"
;
if
(
$with_form
)
{
echo
'<th style ="min-width: 30px"><input type="checkbox" checked="checked" name="selector" id="selector" /></th>'
;
}
foreach
(
current
(
$arr
)
as
$key
=>
$value
){
echo
"<th valign='bottom'>"
;
echo
$key
.
" "
;
...
...
@@ -18,12 +46,17 @@ function array2table($arr,$width = "100%")
echo
"</tr>
\n
"
;
echo
"</thead>
\n
"
;
echo
"<tbody>
\n
"
;
$wi
=
0
;
while
(
$curr_row
=
current
(
$arr
))
{
$rclass
=
(
$wi
%
2
)
?
"odd"
:
""
;
echo
"<tr class='"
.
$rclass
.
"'>
\n
"
;
$col
=
1
;
// Are you fucking kidding me with this shit, Kevin???
if
(
$with_form
)
{
echo
'<td style="min-width: 30px"><input type="checkbox" checked="checked" name="records['
.
$curr_row
[
'ID'
]
.
']" value="1" /></td>'
;
}
while
(
false
!==
(
$curr_field
=
current
(
$curr_row
)))
{
echo
"<td>"
;
echo
$curr_field
.
" "
;
...
...
@@ -31,18 +64,24 @@ function array2table($arr,$width = "100%")
next
(
$curr_row
);
$col
++
;
}
while
(
$col
<=
$num
){
echo
"<td> </td>
\n
"
;
$col
++
;
}
echo
"</tr>
\n
"
;
$wi
++
;
next
(
$arr
);
}
echo
"</tbody>
\n
"
;
echo
"</table>
\n
"
;
if
(
$with_form
)
{
echo
'</form>'
;
}
}
}
function
CSVExport
(
$arr
)
{
$out
=
""
;
...
...
Please
register
or
sign in
to post a comment