|
1
|
|
|
<?php |
|
2
|
|
|
// MUST have WordPress. |
|
3
|
|
|
if ( !defined( 'WPINC' ) ) { |
|
4
|
|
|
exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
5
|
|
|
} |
|
6
|
|
|
|
|
7
|
|
|
class WPInv_Meta_Box_Details { |
|
8
|
|
|
|
|
9
|
|
|
public static function resend_invoice( $post ) { |
|
10
|
|
|
global $wpi_mb_invoice; |
|
11
|
|
|
|
|
12
|
|
|
if ( empty( $wpi_mb_invoice ) ) { |
|
13
|
|
|
return; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
$text = array( |
|
17
|
|
|
'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
18
|
|
|
'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
$text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
|
22
|
|
|
do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
23
|
|
|
|
|
24
|
|
|
if ( $email = $wpi_mb_invoice->get_email() ) { |
|
|
|
|
|
|
25
|
|
|
$email_actions = array(); |
|
26
|
|
|
$email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
27
|
|
|
$email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
28
|
|
|
|
|
29
|
|
|
$email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
30
|
|
|
?> |
|
31
|
|
|
<p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
|
32
|
|
|
<p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
33
|
|
|
<?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
|
|
|
|
|
34
|
|
|
<p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
35
|
|
|
<?php } ?> |
|
36
|
|
|
<?php |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public static function subscriptions( $post ) { |
|
43
|
|
|
$invoice = wpinv_get_invoice( $post->ID ); |
|
44
|
|
|
|
|
45
|
|
|
if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
46
|
|
|
$subscription = wpinv_get_subscription( $invoice ); |
|
47
|
|
|
|
|
48
|
|
|
if ( empty( $subscription ) ) { |
|
49
|
|
|
?> |
|
50
|
|
|
<p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
51
|
|
|
<?php |
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
|
|
|
|
|
55
|
|
|
$billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
56
|
|
|
$initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
57
|
|
|
$payments = $subscription->get_child_payments(); |
|
58
|
|
|
?> |
|
59
|
|
|
<p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
|
60
|
|
|
<?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
61
|
|
|
<p class="wpi-meta-row wpi-sub-id"> |
|
62
|
|
|
<label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
63
|
|
|
<?php } ?> |
|
64
|
|
|
<p class="wpi-meta-row wpi-bill-cycle"> |
|
65
|
|
|
<label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
66
|
|
|
</p> |
|
67
|
|
|
<p class="wpi-meta-row wpi-billed-times"> |
|
68
|
|
|
<label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
69
|
|
|
</p> |
|
70
|
|
|
<p class="wpi-meta-row wpi-start-date"> |
|
71
|
|
|
<label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
|
|
|
|
|
72
|
|
|
</p> |
|
73
|
|
|
<p class="wpi-meta-row wpi-end-date"> |
|
74
|
|
|
<label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
75
|
|
|
</p> |
|
76
|
|
|
<?php if ( $subscription->status ) { ?> |
|
77
|
|
|
<p class="wpi-meta-row wpi-sub-status"> |
|
78
|
|
|
<label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
79
|
|
|
</p> |
|
80
|
|
|
<?php } ?> |
|
81
|
|
|
<?php if ( !empty( $payments ) ) { ?> |
|
82
|
|
|
<p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
83
|
|
|
<ul id="wpi-sub-payments"> |
|
84
|
|
|
<?php foreach ( $payments as $payment ) { |
|
85
|
|
|
$invoice_id = $payment->ID; |
|
86
|
|
|
?> |
|
87
|
|
|
<li> |
|
88
|
|
|
<a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
89
|
|
|
<span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
90
|
|
|
<span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
91
|
|
|
</li> |
|
92
|
|
|
<?php } ?> |
|
93
|
|
|
</ul> |
|
94
|
|
|
<?php } |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public static function renewals( $post ) { |
|
99
|
|
|
$invoice = wpinv_get_invoice( $post->ID ); |
|
100
|
|
|
|
|
101
|
|
|
if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
102
|
|
|
$parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
|
|
|
|
|
103
|
|
|
$parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
104
|
|
|
$subscription = wpinv_get_subscription( $invoice ); |
|
105
|
|
|
?> |
|
106
|
|
|
<?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
107
|
|
|
<p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
108
|
|
|
<?php |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
} |
|
113
|
|
|
|