| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Modules\Gateways\Export; |
| 5 |
|
| 6 |
use JFB_Modules\Gateways\Query_Views\Payment_For_Export_View; |
| 7 |
|
| 8 |
// If this file is called directly, abort. |
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
class Single_Controller extends Base_Export_Controller { |
| 15 |
|
| 16 |
/** |
| 17 |
* @throws \Exception |
| 18 |
*/ |
| 19 |
public function do_export() { |
| 20 |
$payment_id = $this->get_payment_id(); |
| 21 |
$payment_view = Payment_For_Export_View::find( array( 'id' => $payment_id ) ); |
| 22 |
$payment_view->set_select( array_keys( $this->columns ) ); |
| 23 |
|
| 24 |
$payment = $payment_view->set_limit( array( 1 ) )->query()->query_one(); |
| 25 |
|
| 26 |
$this->get_exporter()->set_title( |
| 27 |
/* translators: %d - record ID */ |
| 28 |
sprintf( __( 'JFB Payment %d', 'jet-form-builder' ), $payment_id ) |
| 29 |
); |
| 30 |
$this->get_exporter()->open(); |
| 31 |
|
| 32 |
// headings |
| 33 |
$this->get_exporter()->add_row( |
| 34 |
$this->prepare_row( |
| 35 |
$this->columns, |
| 36 |
$this->record_columns, |
| 37 |
$this->payers_columns, |
| 38 |
$this->shipping_columns |
| 39 |
) |
| 40 |
); |
| 41 |
|
| 42 |
$this->add_row( $payment ); |
| 43 |
$this->get_exporter()->close(); |
| 44 |
die; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* @return int |
| 49 |
* @throws \Exception |
| 50 |
*/ |
| 51 |
protected function get_payment_id(): int { |
| 52 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 53 |
$payment_id = absint( $_GET['id'] ?? '' ); |
| 54 |
|
| 55 |
if ( ! $payment_id ) { |
| 56 |
throw new \Exception( |
| 57 |
esc_html__( 'Payment ID is empty', 'jet-form-builder' ) |
| 58 |
); |
| 59 |
} |
| 60 |
|
| 61 |
return $payment_id; |
| 62 |
} |
| 63 |
} |
| 64 |
|