Add global totals to page
This commit is contained in:
parent
fc03aaabc8
commit
c36e901dd3
4 changed files with 135 additions and 99 deletions
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Creates the submenu item for the plugin.
|
||||
*
|
||||
* Registers a new menu item under 'Admin' group and uses the dependency passed into
|
||||
* the constructor in order to display the page corresponding to this menu item.
|
||||
*
|
||||
* @package ZGo-Payments
|
||||
*/
|
||||
class Submenu {
|
||||
|
||||
/**
|
||||
* A reference the class responsible for rendering the submenu page.
|
||||
*
|
||||
* @var Submenu_Page
|
||||
* @access private
|
||||
*/
|
||||
private $submenu_page;
|
||||
|
||||
/**
|
||||
* Initializes all of the partial classes.
|
||||
*
|
||||
* @param Submenu_Page $submenu_page A reference to the class that renders the
|
||||
* page for the plugin.
|
||||
*/
|
||||
public function __construct( $submenu_page ) {
|
||||
$this->submenu_page = $submenu_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a submenu for this plugin to the 'Tools' menu.
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'admin_menu', array( $this, 'add_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the submenu item and calls on the Submenu Page object to render
|
||||
* the actual contents of the page.
|
||||
*/
|
||||
public function add_options_page() {
|
||||
|
||||
add_options_page(
|
||||
'ZGo Payment Gateway Support',
|
||||
'ZGo Payments',
|
||||
'manage_options',
|
||||
'zgopmtlist',
|
||||
array( $this->submenu_page, 'render' )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Creates the submenu page for the plugin.
|
||||
*
|
||||
* Provides the functionality necessary for rendering the page corresponding
|
||||
* to the submenu with which this page is associated.
|
||||
*
|
||||
* @package ZGo-Payments
|
||||
*/
|
||||
* Creates the submenu page for the plugin.
|
||||
*
|
||||
* Provides the functionality necessary for rendering the page corresponding
|
||||
* to the submenu with which this page is associated.
|
||||
**/
|
||||
|
||||
class Submenu_Page {
|
||||
|
||||
/**
|
||||
* This function renders the contents of the page associated with the Submenu
|
||||
* that invokes the render method. In the context of this plugin, this is the
|
||||
* Submenu class.
|
||||
*/
|
||||
* This function renders the contents of the page associated with the Submenu
|
||||
* that invokes the render method. In the context of this plugin, this is the
|
||||
* Submenu class.
|
||||
**/
|
||||
public $_limit;
|
||||
public $_offset;
|
||||
public $_npages;
|
||||
|
@ -323,6 +321,7 @@ class Submenu_Page {
|
|||
|
||||
<?php
|
||||
$this->render_stats();
|
||||
$this->render_totals();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,8 +333,8 @@ class Submenu_Page {
|
|||
$result = $wpdb->get_row($sql,OBJECT);
|
||||
?>
|
||||
<div style="margin-top: 25px;
|
||||
margin-bottom: 20px;
|
||||
padding-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
padding-right: 20px;
|
||||
font-family: 'Noto Sans';
|
||||
font-size: 20px;
|
||||
font-weight: 900;
|
||||
|
@ -349,22 +348,22 @@ class Submenu_Page {
|
|||
<tr>
|
||||
<td width="10%"></td>
|
||||
<td width="80%">
|
||||
<table width="100%" >
|
||||
<tr style="font-family: Noto Sans;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
vertical-align: center;
|
||||
height: 20px;
|
||||
background-color: #ff5722;
|
||||
color: white;">
|
||||
<table width="100%" >
|
||||
<tr style="font-family: Noto Sans;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
vertical-align: center;
|
||||
height: 20px;
|
||||
background-color: #ff5722;
|
||||
color: white;">
|
||||
<td width="35%">Payments received</td>
|
||||
<td width="35%">Description</td>
|
||||
<td width="30%">Value</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td width="10%"></td>
|
||||
</tr>
|
||||
<td width="10%"></td>
|
||||
|
@ -538,4 +537,56 @@ class Submenu_Page {
|
|||
<?php
|
||||
}
|
||||
|
||||
public function render_totals() {
|
||||
global $wpdb;
|
||||
|
||||
$sql = 'select ifnull(sum(a.pmt_amount),0) as gTotalAmount, ' .
|
||||
'ifnull(count(*),0) as gTotalPmts, ' .
|
||||
'ifnull(sum(a.pmt_zec),0) as gTotalZec ' .
|
||||
'from zgo_payments a ' .
|
||||
'where a.pmt_wc_paid = 1;' ;
|
||||
$result = $wpdb->get_row($sql,OBJECT);
|
||||
if ( $result ) {
|
||||
if ($result->gTotalPmts > 0) {
|
||||
?>
|
||||
<div style="padding-right: 20px;
|
||||
font-family: 'Noto Sans';
|
||||
font-size: 15px;
|
||||
font-weight: 900;
|
||||
text-align: center;
|
||||
color: navy;">
|
||||
Global Totals
|
||||
</div>
|
||||
<table width="100%"
|
||||
style="padding-right: 20px;">
|
||||
<tr>
|
||||
<td width="10%"></td>
|
||||
<td width="80%">
|
||||
<table width="100%" >
|
||||
<tr style="font-family: Noto Sans;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
vertical-align: center;
|
||||
height: 20px;
|
||||
background-color: #ff5722;
|
||||
color: white;">
|
||||
<td width="12%">Payments:</td>
|
||||
<td width="23%"><?php echo $result->gTotalPmts ?></td>
|
||||
<td width="12%">Total Amount:</td>
|
||||
<td width="23%"><?php echo number_format($result->gTotalAmount,2) ?></td>
|
||||
<td width="12%">Total ZEC:</td>
|
||||
<td width="23%"><?php echo number_format($result->gTotalZec,8) ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<td width="10%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
44
assets/class-submenu.php
Normal file
44
assets/class-submenu.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* Creates the submenu item for the plugin.
|
||||
*
|
||||
* Registers a new menu item under 'Admin' group and uses the dependency passed into
|
||||
* the constructor in order to display the page corresponding to this menu item.
|
||||
**/
|
||||
class Submenu {
|
||||
|
||||
/**
|
||||
* A reference the class responsible for rendering the submenu page.
|
||||
**/
|
||||
private $submenu_page;
|
||||
|
||||
/**
|
||||
* Initializes all of the partial classes.
|
||||
**/
|
||||
public function __construct( $submenu_page ) {
|
||||
$this->submenu_page = $submenu_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a submenu for this plugin to the 'Tools' menu.
|
||||
**/
|
||||
public function init() {
|
||||
add_action( 'admin_menu', array( $this, 'add_options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the submenu item and calls on the Submenu Page object to render
|
||||
* the actual contents of the page.
|
||||
**/
|
||||
public function add_options_page() {
|
||||
|
||||
add_options_page(
|
||||
'ZGo Payment Gateway Support',
|
||||
'ZGo Payments',
|
||||
'manage_options',
|
||||
'zgopmtlist',
|
||||
array( $this->submenu_page, 'render' )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* The plugin bootstrap file
|
||||
*
|
||||
* This file is read by WordPress to generate the plugin information in the
|
||||
* plugin admin area. This file also defines a function that starts the plugin.
|
||||
*
|
||||
* @package ZGo-Payments
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: ZGo Payment Database
|
||||
* Plugin URI: http://vergara.tech
|
||||
* Description: Display payments processed using ZGo Payment Gateway.
|
||||
* Version: 1.0.0
|
||||
* Author: Vergara Tech
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
*/
|
||||
* Plugin Name: ZGo Payment Database
|
||||
* Plugin URI: http://vergara.tech
|
||||
* Description: Display payments processed using ZGo Payment Gateway.
|
||||
* Version: 0.8
|
||||
* Requires at least: 5.2
|
||||
* Requires PHP: 7.2
|
||||
* Author: Vergara Tech LLC
|
||||
* Author URI: https://vergara.tech
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
**/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
|
@ -23,17 +18,15 @@ if ( ! defined( 'WPINC' ) ) {
|
|||
}
|
||||
|
||||
// Include the dependencies needed to instantiate the plugin.
|
||||
foreach ( glob( plugin_dir_path( __FILE__ ) . 'admin/*.php' ) as $file ) {
|
||||
foreach ( glob( plugin_dir_path( __FILE__ ) . 'assets/*.php' ) as $file ) {
|
||||
include_once $file;
|
||||
}
|
||||
|
||||
add_action( 'plugins_loaded', 'zgopmtlist_plugin' );
|
||||
|
||||
/**
|
||||
* Starts the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
* Starts the plugin.
|
||||
**/
|
||||
function zgopmtlist_plugin() {
|
||||
|
||||
$path = str_replace('zgopmtlist/','',plugin_dir_path( __FILE__ ));
|
||||
|
|
Loading…
Reference in a new issue