diff --git a/plugin/BTCPayments/BTCPayments.php b/plugin/BTCPayments/BTCPayments.php index 2518f0a949..915fe022a5 100644 --- a/plugin/BTCPayments/BTCPayments.php +++ b/plugin/BTCPayments/BTCPayments.php @@ -310,4 +310,13 @@ class BTCPayments extends PluginAbstract $resp->error = false; return $resp; } + + public function getHeadCode() + { + global $global, $config; + $js = ''; + + $js .= ''; + return $js; + } } diff --git a/plugin/BTCPayments/Objects/Btc_invoices.php b/plugin/BTCPayments/Objects/Btc_invoices.php index 0cf9b6c684..41db5b2535 100644 --- a/plugin/BTCPayments/Objects/Btc_invoices.php +++ b/plugin/BTCPayments/Objects/Btc_invoices.php @@ -151,18 +151,42 @@ class Btc_invoices extends ObjectYPT return 0; } - public static function getAll() + public static function getAllFromUser($users_id) { global $global; if (!static::isTableInstalled()) { return false; } - $sql = "SELECT p.*, i.* FROM " . static::getTableName() . " i LEFT JOIN btc_payments p ON i.id = btc_invoices_id WHERE 1=1 "; + $sql = "SELECT p.*, i.* FROM " . static::getTableName() . " i LEFT JOIN btc_payments p ON i.id = btc_invoices_id WHERE i.users_id = ? "; $sql .= self::getSqlFromPost('i.'); - $res = sqlDAL::readSql($sql); + $res = sqlDAL::readSql($sql, 'i', [$users_id]); $fullData = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); return $fullData; } + + public static function getTotalFromUser($users_id) + { + //will receive + //current=1&rowCount=10&sort[sender]=asc&searchPhrase= + global $global; + if (!static::isTableInstalled()) { + return 0; + } + $sql = "SELECT id FROM " . static::getTableName() . " WHERE users_id = ? "; + $sql .= self::getSqlSearchFromPost(); + $res = sqlDAL::readSql($sql, 'i', [$users_id]); + $countRow = sqlDAL::num_rows($res); + sqlDAL::close($res); + return $countRow; + } + + public function save($notifySocket = false){ + $save = parent::save(); + if($save && $notifySocket){ + sendSocketMessageToUsers_id(json_decode($this->json), $this->users_id,'BTCPayments'); + } + return $save; + } } diff --git a/plugin/BTCPayments/View/Btc_invoices/list.json.php b/plugin/BTCPayments/View/Btc_invoices/list.json.php index 24f4954780..d0f8a52584 100644 --- a/plugin/BTCPayments/View/Btc_invoices/list.json.php +++ b/plugin/BTCPayments/View/Btc_invoices/list.json.php @@ -3,8 +3,13 @@ require_once '../../../../videos/configuration.php'; require_once $global['systemRootPath'] . 'plugin/BTCPayments/Objects/Btc_invoices.php'; header('Content-Type: application/json'); -$rows = Btc_invoices::getAll(); -$total = Btc_invoices::getTotal(); +if (!User::isLogged()) { + forbiddenPage(__("You cannot do this")); + exit; +} + +$rows = Btc_invoices::getAllFromUser(User::getId()); +$total = Btc_invoices::getTotalFromUser(User::getId()); foreach ($rows as $key => $value) { $rows[$key]['json_object'] = json_decode($value['json']); diff --git a/plugin/BTCPayments/View/payments.php b/plugin/BTCPayments/View/payments.php new file mode 100644 index 0000000000..b4d3ae6c88 --- /dev/null +++ b/plugin/BTCPayments/View/payments.php @@ -0,0 +1,42 @@ +setExtraScripts(array('view/css/DataTables/datatables.min.js')); +$_page->setExtraStyles(array('view/css/DataTables/datatables.min.css')); + +?> + +
# | -Invoice | -Description | + + +Description | BTC Amount | Amount | Created Date | -Paid Date | -Status | + +Action |
---|