_path = $path; $this->console_log('$_path -> '. $this->_path); $this->_nrows = $this->getPmtsCount(); // // Create zgo_pmtlst if does not exist // $sql = 'create table if not exists zgo_pmtlst (' . 'pg_ix integer ,' . 'pg_page integer not null default 0,' . 'pg_npages integer not null default 0,' . 'pg_offset integer not null default 0,' . 'pg_limit integer not null default 0,' . 'pg_dt datetime default current_timestamp, '. 'unique lstix (pg_ix) );'; $GLOBALS['wpdb']->query($sql); if ( ! $this->pmtLstRdy() ) { // // Calculate first time pagination paramters // $this->_limit = 10; $this->_page = 1; $this->_offset = 0; $this->_npages = intdiv($this->_nrows,$this->_limit); if ( $this->_nrows > ($this->_npages*$this->_limit) ) { $this->_npages++; } $sql = 'insert into zgo_pmtlst (pg_ix,pg_page,pg_npages,pg_offset,pg_limit) values (1,' . $this->_page . ',' . $this->_npages . ',' . $this->_offset . ',' . $this->_limit .')'; $GLOBALS['wpdb']->query($sql); } else { // Load last state $params = $this->pmtLstParams(); $this->_page = $params->pg_page; $this->_offset = $params->pg_offset; $this->_limit = $params->pg_limit; $this->_npages = $params->pg_npages; if ( $this->_nrows > ($this->_npages*$this->_limit) ) { // // Calc new number of pages // $this->_npages = intdiv($this->_npages,$this->_limit); if ( $this->_nrows > ($this->_npages*$this->_limit) ) { $this->_npages++; } $sql = 'update zgo_pmtlst set pg_npages=' . $this->_npages . ' where pg_ix=1'; $GLOBALS['wpdb']->query($sql); } } } public function getPmtsCount() { global $wpdb; $sql = "select count(*) as npmts from zgo_payments"; $result = $wpdb->get_var($sql); $this->console_log('getPmtsCount() -> ' . $result); return $result; } public function pmtLstRdy() { global $wpdb; $sql = 'select count(*) as nrecs from zgo_pmtlst;'; $result = $wpdb->get_var($sql); $this->console_log("pmtLstRdy() -> " . $result); return $result; } public function pmtLstParams() { global $wpdb; $sql = 'select * from zgo_pmtlst where pg_ix=1;'; $result = $wpdb->get_row($sql,OBJECT); $this->console_log('Params -> ' . json_encode($result) ); $this->console_log('pg_ix -> ' . $result->pg_ix ); $this->console_log('pg_page -> ' . $result->pg_page ); $this->console_log('pg_offset -> ' . $result->pg_offset ); return $result; } public function console_log($data) { $file = $this->_path . 'zgopmtgwy/assets/console.log'; file_put_contents($file, 'LST::' . $data . chr(0x0D) . chr(0x0A), FILE_TEXT | FILE_APPEND | LOCK_EX ); } public function render() { global $wpdb; $currentDate = date('Y-m-d H:i:s'); if ($_SERVER['REQUEST_METHOD'] === 'POST') { // // Navigation button pressed // $sql = 'select * from zgo_pmtlst where pg_ix=1;'; $result = $wpdb->get_row($sql,OBJECT); $this->_page = $result->pg_page; $this->console_log("_page -> " . $this->_page); $this->_limit = $result->pg_limit; $this->console_log("_limit -> " . $this->_limit); $this->_npages = $result->pg_npages; $this->console_log("_npages -> " . $this->_npages); $this->_nrows = $this->getPmtsCount(); $this->console_log("_nrows -> " . $this->_nrows); if ( $this->_nrows > ($this->_npages*$this->_limit) ) { $this->console_log('_nrows > ' . ($this->_npages*$this->_limit)); $this->_npages = intdiv($this->_nrows,$this->_limit); $this->console_log('_npages > ' . $this->_npages ); if ( $this->_nrows > ($this->_npages*$this->_limit) ) { $this->_npages++; $this->console_log('Page number increased to ' . $this->_npages); } } if ( isset($_POST['First'])) { $this->_page = 1; $this->_offset = 0; } if ( isset($_POST['Previous'])) { if ($this->_page > 1) { $this->_page--; } $this->_offset = $this->_limit*($this->_page-1); } if ( isset($_POST['Next'])) { if ($this->_page < $this->_npages ) { $this->_page++; } $this->_offset = $this->_limit*($this->_page-1); } if ( isset($_POST['Last'])) { $this->_page = $this->_npages; $this->_offset = $this->_limit*($this->_page-1); } // // Save new list state // $sql = 'update zgo_pmtlst set pg_page=' . $this->_page . ', pg_npages=' . $this->_npages . ', pg_offset=' . $this->_offset . ' where pg_ix=1;'; $this->console_log( $sql ); $wpdb->query($sql); } ?>
ZGo Payment Gateway - Received Payments
_page . '/' . $this->_npages; ?>
_offset . "," . $this->_limit; $result = $wpdb->get_results($sql,OBJECT); $npmts = count($result); if ( $npmts > 0 ) { $line = 0; while ( $line < $npmts ) { $row = $result[$line]; if ( fmod($line,2) ) { print ''; } else { print ''; } $line++; print '"; print ""; print ""; print '"; print '"; print '"; print '"; print '"; print '"; } ?>
ZGo Order Id Shop Order Id Customer Accepted Confirmed Order Total Rate Total ZEC Paid?
' . $row->pmt_orderid . "" . $row->pmt_wc_order . "" . $row->pmt_wc_custname . "'. $row->pmt_accepted . "'.$row->pmt_confirmed ."'. number_format($row->pmt_amount,2) . "'. number_format($row->pmt_rate,2) . "'. number_format($row->pmt_zec,8) . "'.$row->pmt_wc_paid ."

render_stats(); } } public function render_stats() { global $wpdb; $sql = "select ifnull(a.dTotalAmount,0) as dTotalAmount, ifnull(a.dTotalZec,0) as dTotalZec, ifnull(a.dTotalPmts,0) as dTotalPmts, ifnull(b.wTotalAmount,0) as wTotalAmount, ifnull(b.wTotalZec,0) as wTotalZec, ifnull(b.wTotalPmts,0) as wTotalPmts, ifnull(c.mTotalAmount,0) as mTotalAmount, ifnull(c.mTotalZec,0) as mTotalZec, ifnull(c.mTotalPmts,0) as mTotalPmts from (select sum(a0.pmt_amount) as dTotalAmount, sum(a0.pmt_zec) as dTotalZec, count(*) as dTotalPmts from zgo_payments a0 where STR_TO_DATE(left(a0.pmt_confirmed,10), '%Y-%m-%d') = CURRENT_DATE ) a join (select sum(aa.pmt_amount) as wTotalAmount, sum(aa.pmt_zec) as wTotalZec, count(*) as wTotalPmts from zgo_payments aa where STR_TO_DATE(aa.pmt_confirmed, '%Y-%m-%d %H:%i:%s') >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) b join (select sum(bb.pmt_amount) as mTotalAmount, sum(bb.pmt_zec) as mTotalZec, count(*) as mTotalPmts from zgo_payments bb where STR_TO_DATE(bb.pmt_confirmed, '%Y-%m-%d %H:%i:%s') >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY)) c where 1;"; $result = $wpdb->get_row($sql,OBJECT); ?>
ZGo Confirmed Payments Statistics
Payments received Description Value
Received Today
Total Amount
Average Rate
Total Zec
Number of payments
dTotalAmount,2);?>
dTotalZec > 0.0) { echo number_format($result->dTotalZec/$result->dTotalAmount,2); } else { echo '0.00'; } ?>
dTotalZec,8);?>
dTotalPmts;?>
Last 7 days
Total Amount
Average Rate
Total Zec
Number of payments
wTotalAmount,2);?>
wTotalZec > 0.0) { echo number_format($result->wTotalAmount/$result->wTotalZec,2); } else { echo '0.00'; } ?>
wTotalZec,8);?>
wTotalPmts;?>
Last 30 days
Total Amount
Average Rate
Total Zec
Number of payments
mTotalAmount,2);?>
mTotalZec> 0.0) { echo number_format($result->mTotalAmount/$result->mTotalZec,2); } else { echo '0.00'; } ?>
mTotalZec,8);?>
mTotalPmts;?>