Version Description
- Fixed the known issue where the print button stopped working becuse of SSL
- Fixed an issue where the print page was redirected to the account page
Download this release
Release Info
Developer | chabis |
Plugin | ![]() |
Version | 3.0.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 3.0.6
- classes/class-wcdn-print.php +0 -210
- classes/class-wcdn-settings.php +0 -364
- classes/class-wcdn-writepanel.php +0 -113
- css/admin.css +101 -0
- css/style.css +0 -40
- fonts/icons.eot +0 -0
- fonts/icons.svg +13 -0
- fonts/icons.ttf +0 -0
- fonts/icons.woff +0 -0
- images/print-delivery-note.png +0 -0
- images/print-invoice.png +0 -0
- includes/class-wcdn-print.php +310 -0
- includes/class-wcdn-settings.php +350 -0
- includes/class-wcdn-theme.php +88 -0
- includes/class-wcdn-writepanel.php +200 -0
- includes/wcdn-template-functions.php +340 -0
- includes/wcdn-template-hooks.php +20 -0
- js/admin.js +108 -0
- js/jquery.print-link.js +57 -0
- js/script.js +0 -97
- js/theme.js +8 -0
- languages/woocommerce-delivery-notes-de_DE.mo +0 -0
- languages/woocommerce-delivery-notes-de_DE.po +198 -228
- languages/woocommerce-delivery-notes.mo +0 -0
- languages/woocommerce-delivery-notes.po +0 -280
- languages/woocommerce-delivery-notes.pot +230 -171
- readme.md +17 -0
- readme.txt +190 -197
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- templates/print-order/print-content.php +170 -0
- templates/print-order/print-footer.php +22 -0
- templates/print-order/print-header.php +33 -0
- templates/print-order/print-order.php +49 -0
- templates/print-order/style.css +288 -0
- templates/print/print-delivery-note.php +0 -119
- templates/print/print-invoice.php +0 -1
- templates/print/style.css +0 -257
- woocommerce-delivery-notes.php +74 -491
classes/class-wcdn-print.php
DELETED
@@ -1,210 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Print class
|
5 |
-
*/
|
6 |
-
if ( ! class_exists( 'WooCommerce_Delivery_Notes_Print' ) ) {
|
7 |
-
|
8 |
-
class WooCommerce_Delivery_Notes_Print {
|
9 |
-
|
10 |
-
private $template_directory_name;
|
11 |
-
private $template_path;
|
12 |
-
private $template_default_path;
|
13 |
-
private $template_default_uri;
|
14 |
-
|
15 |
-
private $order;
|
16 |
-
|
17 |
-
public $template_type;
|
18 |
-
public $order_id;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Constructor
|
22 |
-
*/
|
23 |
-
public function __construct() {
|
24 |
-
global $woocommerce;
|
25 |
-
$this->order = new WC_Order();
|
26 |
-
$this->template_directory_name = 'print';
|
27 |
-
$this->template_path = $woocommerce->template_url . $this->template_directory_name . '/';
|
28 |
-
$this->template_default_path = WooCommerce_Delivery_Notes::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
29 |
-
$this->template_default_uri = WooCommerce_Delivery_Notes::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Load the class
|
34 |
-
*/
|
35 |
-
public function load() {
|
36 |
-
add_action( 'admin_init', array( $this, 'load_hooks' ) );
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Load the admin hooks
|
41 |
-
*/
|
42 |
-
public function load_hooks() {
|
43 |
-
add_action('wp_ajax_generate_print_content', array($this, 'generate_print_content_ajax'));
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Generate the template output
|
48 |
-
*/
|
49 |
-
public function generate_print_content( $template_type, $order_id ) {
|
50 |
-
$this->template_type = $template_type;
|
51 |
-
$this->order_id = $order_id;
|
52 |
-
$this->order->get_order( $this->order_id );
|
53 |
-
$this->get_template( apply_filters( 'wcdn_template_file_name', 'print-' . $this->template_type . '.php', $template_type, $order_id, $this ) );
|
54 |
-
do_action( 'wcdn_generate_print_content' );
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Load and generate the template output with ajax
|
59 |
-
*/
|
60 |
-
public function generate_print_content_ajax() {
|
61 |
-
// Let the backend only access the page
|
62 |
-
if( !is_admin() ) {
|
63 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
64 |
-
}
|
65 |
-
|
66 |
-
// Check the user privileges
|
67 |
-
if( !current_user_can( 'manage_woocommerce_orders' ) && !current_user_can( 'edit_shop_orders' ) ) {
|
68 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
69 |
-
}
|
70 |
-
|
71 |
-
// Check the nonce
|
72 |
-
if( empty( $_GET['action'] ) || !check_admin_referer( $_GET['action'] ) ) {
|
73 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
74 |
-
}
|
75 |
-
|
76 |
-
// Check if all parameters are set
|
77 |
-
if( empty( $_GET['template_type'] ) || empty( $_GET['order_id'] ) ) {
|
78 |
-
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
79 |
-
}
|
80 |
-
|
81 |
-
// Generate the output
|
82 |
-
$this->generate_print_content( $_GET['template_type'], $_GET['order_id'] );
|
83 |
-
|
84 |
-
exit;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get the template url for a file. locate by file existience
|
89 |
-
* and then return the corresponding url.
|
90 |
-
*/
|
91 |
-
public function get_template_url( $name ) {
|
92 |
-
global $woocommerce;
|
93 |
-
|
94 |
-
$uri = $this->template_default_uri . $name;
|
95 |
-
$child_theme_path = get_stylesheet_directory() . '/' . $this->template_path;
|
96 |
-
$child_theme_uri = get_stylesheet_directory_uri() . '/' . $this->template_path;
|
97 |
-
$theme_path = get_template_directory() . '/' . $this->template_path;
|
98 |
-
$theme_uri = get_template_directory_uri() . '/' . $this->template_path;
|
99 |
-
|
100 |
-
if( file_exists( $child_theme_path . $name ) ) {
|
101 |
-
$uri = $child_theme_uri . $name;
|
102 |
-
} elseif( file_exists( $theme_path . $name ) ) {
|
103 |
-
$uri = $theme_uri . $name;
|
104 |
-
}
|
105 |
-
|
106 |
-
return $uri;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Load the template file content
|
111 |
-
*/
|
112 |
-
public function get_template( $name ) {
|
113 |
-
woocommerce_get_template( $name, null, $this->template_path, $this->template_default_path );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Get the current order
|
118 |
-
*/
|
119 |
-
public function get_order() {
|
120 |
-
return $this->order;
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get the current order items
|
125 |
-
*/
|
126 |
-
public function get_order_items() {
|
127 |
-
global $woocommerce;
|
128 |
-
global $_product;
|
129 |
-
|
130 |
-
$items = $this->order->get_items();
|
131 |
-
$data_list = array();
|
132 |
-
|
133 |
-
if( sizeof( $items ) > 0 ) {
|
134 |
-
foreach ( $items as $item ) {
|
135 |
-
// Array with data for the printing template
|
136 |
-
$data = array();
|
137 |
-
|
138 |
-
// Set the id
|
139 |
-
$data['product_id'] = $item['product_id'];
|
140 |
-
$data['variation_id'] = $item['variation_id'];
|
141 |
-
|
142 |
-
// Set item name
|
143 |
-
$data['name'] = $item['name'];
|
144 |
-
|
145 |
-
// Set item quantity
|
146 |
-
$data['quantity'] = $item['qty'];
|
147 |
-
|
148 |
-
// Set the subtotal for the number of products
|
149 |
-
$data['line_total'] = $item['line_total'];
|
150 |
-
$data['line_tax'] = $item['line_tax'];
|
151 |
-
|
152 |
-
// Set the final subtotal for all products
|
153 |
-
$data['line_subtotal'] = $item['line_subtotal'];
|
154 |
-
$data['line_subtotal_tax'] = $item['line_subtotal_tax'];
|
155 |
-
$data['formatted_line_subtotal'] = $this->order->get_formatted_line_subtotal( $item );
|
156 |
-
$data['price'] = $data['formatted_line_subtotal'];
|
157 |
-
|
158 |
-
// Set item meta and replace it when it is empty
|
159 |
-
$meta = new WC_Order_Item_Meta( $item['item_meta'] );
|
160 |
-
$data['meta'] = $meta->display( false, true );
|
161 |
-
|
162 |
-
// Pass complete item array
|
163 |
-
$data['item'] = $item;
|
164 |
-
|
165 |
-
// Create the product to display more info
|
166 |
-
$data['product'] = null;
|
167 |
-
|
168 |
-
$product = $this->order->get_product_from_item( $item );
|
169 |
-
|
170 |
-
// Checking fo existance, thanks to MDesigner0
|
171 |
-
if(!empty($product)) {
|
172 |
-
// Set the single price
|
173 |
-
$data['single_price'] = $product->get_price();
|
174 |
-
|
175 |
-
// Set item SKU
|
176 |
-
$data['sku'] = $product->get_sku();
|
177 |
-
|
178 |
-
// Set item weight
|
179 |
-
$data['weight'] = $product->get_weight();
|
180 |
-
|
181 |
-
|
182 |
-
// Set item dimensions
|
183 |
-
$data['dimensions'] = $product->get_dimensions();
|
184 |
-
|
185 |
-
// Pass complete product object
|
186 |
-
$data['product'] = $product;
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
$data_list[] = apply_filters( 'wcdn_order_item_data', $data );
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return apply_filters( 'wcdn_order_items_data', $data_list );
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Get order custom field
|
199 |
-
*/
|
200 |
-
public function get_order_field( $field ) {
|
201 |
-
if( isset( $this->get_order()->order_custom_fields[$field] ) ) {
|
202 |
-
return $this->get_order()->order_custom_fields[$field][0];
|
203 |
-
}
|
204 |
-
return;
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class-wcdn-settings.php
DELETED
@@ -1,364 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Settings class
|
5 |
-
*/
|
6 |
-
if ( ! class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
|
7 |
-
|
8 |
-
class WooCommerce_Delivery_Notes_Settings {
|
9 |
-
|
10 |
-
public $tab_name;
|
11 |
-
public $hidden_submit;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Constructor
|
15 |
-
*/
|
16 |
-
public function __construct() {
|
17 |
-
$this->tab_name = 'woocommerce-delivery-notes';
|
18 |
-
$this->hidden_submit = WooCommerce_Delivery_Notes::$plugin_prefix . 'submit';
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Load the class
|
23 |
-
*/
|
24 |
-
public function load() {
|
25 |
-
add_action( 'admin_init', array( $this, 'load_hooks' ) );
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Load the admin hooks
|
30 |
-
*/
|
31 |
-
public function load_hooks() {
|
32 |
-
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ) );
|
33 |
-
add_action( 'woocommerce_settings_tabs_' . $this->tab_name, array( $this, 'create_settings_page' ) );
|
34 |
-
add_action( 'woocommerce_update_options_' . $this->tab_name, array( $this, 'save_settings_page' ) );
|
35 |
-
add_action( 'current_screen', array( $this, 'load_screen_hooks' ) );
|
36 |
-
add_action( 'wp_ajax_load_thumbnail', array( $this, 'load_thumbnail_ajax' ) );
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Add the scripts
|
41 |
-
*/
|
42 |
-
public function load_screen_hooks() {
|
43 |
-
$screen = get_current_screen();
|
44 |
-
|
45 |
-
if( $this->is_settings_page() ) {
|
46 |
-
add_action( 'admin_print_styles', array( $this, 'add_styles' ) );
|
47 |
-
add_action( 'admin_print_scripts', array( $this, 'add_scripts' ) );
|
48 |
-
add_action( 'load-' . $screen->id, array( $this, 'add_help_tabs' ) );
|
49 |
-
}
|
50 |
-
|
51 |
-
if( $this->is_media_uploader_page() ) {
|
52 |
-
add_filter( 'media_upload_tabs', array( $this, 'remove_media_tabs' ) );
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Add the styles
|
58 |
-
*/
|
59 |
-
public function add_styles() {
|
60 |
-
wp_enqueue_style( 'thickbox' );
|
61 |
-
wp_enqueue_style( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'css/style.css' );
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Add the scripts
|
66 |
-
*/
|
67 |
-
public function add_scripts() {
|
68 |
-
?>
|
69 |
-
<script type="text/javascript">
|
70 |
-
var show_print_preview = 'yes';
|
71 |
-
</script>
|
72 |
-
<?php
|
73 |
-
wp_enqueue_script( 'media-upload' );
|
74 |
-
wp_enqueue_script( 'thickbox' );
|
75 |
-
wp_enqueue_script( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'js/script.js', array( 'jquery', 'media-upload', 'thickbox' ) );
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Check if we are on settings page
|
80 |
-
*/
|
81 |
-
public function is_settings_page() {
|
82 |
-
if( isset( $_GET['page'] ) && isset( $_GET['tab'] ) && $_GET['tab'] == $this->tab_name ) {
|
83 |
-
return true;
|
84 |
-
} else {
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Check if we are on media uploader page
|
91 |
-
*/
|
92 |
-
public function is_media_uploader_page() {
|
93 |
-
if( isset( $_GET['post_id'] ) && isset( $_GET['company_logo_image'] ) && $_GET['post_id'] == '0' && $_GET['company_logo_image'] == 'true' ) {
|
94 |
-
return true;
|
95 |
-
} else {
|
96 |
-
return false;
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Check if sequential order plugin is activated
|
102 |
-
*/
|
103 |
-
public function is_woocommerce_sequential_order_numbers_activated() {
|
104 |
-
if ( in_array( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
105 |
-
return true;
|
106 |
-
} else {
|
107 |
-
return false;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Remove the media uploader tabs
|
113 |
-
*/
|
114 |
-
public function remove_media_tabs( $tabs ) {
|
115 |
-
unset( $tabs['type_url'] );
|
116 |
-
return $tabs;
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Add the help tabs
|
121 |
-
*/
|
122 |
-
public function add_help_tabs() {
|
123 |
-
// Check current admin screen
|
124 |
-
$screen = get_current_screen();
|
125 |
-
|
126 |
-
// Remove all existing tabs
|
127 |
-
$screen->remove_help_tabs();
|
128 |
-
|
129 |
-
// Create arrays with help tab titles
|
130 |
-
$screen->add_help_tab(array(
|
131 |
-
'id' => 'woocommerce-delivery-notes-usage',
|
132 |
-
'title' => __( 'About the Plugin', 'woocommerce-delivery-notes' ),
|
133 |
-
'content' =>
|
134 |
-
'<h3>' . __( 'Plugin: WooCommerce Print Invoices & Delivery Notes', 'woocommerce-delivery-notes' ) . '</h3>' .
|
135 |
-
'<h4>' . __( 'About the Plugin', 'woocommerce-delivery-notes' ) . '</h4>' .
|
136 |
-
'<p>' . __( 'This plugin enables you to add a Invoice or simple Delivery Note page for printing for your orders in WooCommerce shop plugin. You can add your company postal address, further add personal notes, refund or other policies and a footer note/branding. This helps speed up your daily shop and order management. In some countries (e.g. in the European Union) it is also required to advice the customer with proper refund policies so this little plugin might help you a bit with that too.', 'woocommerce-delivery-notes' ) . '</p>' .
|
137 |
-
'<p>' . sprintf( __( 'Just look under <a href="%1$s">WooCommerce > Orders</a> and there go to a single order view. On the right side you will see the Order Print meta box. Click one of the buttons and you get the invoice or delivery note printing page. Yes, it is that easy :-).', 'woocommerce-delivery-notes' ), admin_url( 'edit.php?post_type=shop_order' ) ) . '</p>'
|
138 |
-
) );
|
139 |
-
|
140 |
-
// Create help sidebar
|
141 |
-
$screen->set_help_sidebar(
|
142 |
-
'<p><strong>' . __( 'For more information:', 'woocommerce-delivery-notes' ) . '</strong></p>'.
|
143 |
-
'<p><a href="http://wordpress.org/extend/plugins/woocommerce-delivery-notes/faq/" target="_blank">' . __( 'Frequently Asked Questions', 'woocommerce-delivery-notes' ) . '</a></p>' .
|
144 |
-
'<p><a href="http://wordpress.org/support/plugin/woocommerce-delivery-notes" target="_blank">' . __( 'Get Community Support', 'woocommerce-delivery-notes' ) . '</a></p>' .
|
145 |
-
'<p><a href="http://wordpress.org/extend/plugins/woocommerce-delivery-notes/" target="_blank">' . __( 'Project on WordPress.org', 'woocommerce-delivery-notes' ) . '</a></p>' .
|
146 |
-
'<p><a href="https://github.com/deckerweb/woocommerce-delivery-notes" target="_blank">' . __( 'Project on GitHub', 'woocommerce-delivery-notes' ) . '</a></p>'
|
147 |
-
);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Add a tab to the settings page
|
152 |
-
*/
|
153 |
-
public function add_settings_tab($tabs) {
|
154 |
-
$tabs[$this->tab_name] = __( 'Print', 'woocommerce-delivery-notes' );
|
155 |
-
|
156 |
-
return $tabs;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Load thumbnail with ajax
|
161 |
-
*/
|
162 |
-
public function load_thumbnail_ajax() {
|
163 |
-
$attachment_id = (int)$_POST['attachment_id'];
|
164 |
-
|
165 |
-
// Verify the id
|
166 |
-
if( !$attachment_id ) {
|
167 |
-
die();
|
168 |
-
}
|
169 |
-
|
170 |
-
// create the thumbnail
|
171 |
-
$this->create_thumbnail( $attachment_id );
|
172 |
-
|
173 |
-
exit;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Create the thumbnail
|
178 |
-
*/
|
179 |
-
public function create_thumbnail( $attachment_id ) {
|
180 |
-
$attachment_src = wp_get_attachment_image_src( $attachment_id, 'full', false );
|
181 |
-
|
182 |
-
// resize the image to a 1/4 of the original size
|
183 |
-
// to have a printing point density of about 288ppi.
|
184 |
-
?>
|
185 |
-
<img src="<?php echo $attachment_src[0]; ?>" width="<?php echo $attachment_src[1] / 4; ?>" height="<?php echo $attachment_src[2] / 4; ?>" alt="" />
|
186 |
-
<?php
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Create the settings page content
|
191 |
-
*/
|
192 |
-
public function create_settings_page() {
|
193 |
-
?>
|
194 |
-
<h3><?php _e( 'Invoices and Delivery Notes', 'woocommerce-delivery-notes' ); ?></h3>
|
195 |
-
<table class="form-table">
|
196 |
-
<tbody>
|
197 |
-
<tr class="hide-if-no-js">
|
198 |
-
<?php
|
199 |
-
$attachment_id = get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'company_logo_image_id' );
|
200 |
-
?>
|
201 |
-
<th>
|
202 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_logo_image_id"><?php _e( 'Company/Shop Logo', 'woocommerce-delivery-notes' ); ?></label>
|
203 |
-
</th>
|
204 |
-
<td>
|
205 |
-
<input id="company-logo-image-id" type="hidden" name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_logo_image_id" rows="2" class="regular-text" value="<?php echo $attachment_id ?>" />
|
206 |
-
<span id="company-logo-placeholder"><?php if( !empty( $attachment_id ) ) : ?><?php $this->create_thumbnail( $attachment_id ); ?><?php endif; ?></span>
|
207 |
-
<a href="#" id="company-logo-remove-button" <?php if( empty( $attachment_id ) ) : ?>style="display: none;"<?php endif; ?>><?php _e( 'Remove Logo', 'woocommerce-delivery-notes' ); ?></a>
|
208 |
-
<a href="#" <?php if( !empty( $attachment_id ) ) : ?>style="display: none;"<?php endif; ?> id="company-logo-add-button"><?php _e( 'Set Logo', 'woocommerce-delivery-notes' ); ?></a>
|
209 |
-
<span class="description">
|
210 |
-
<?php _e( 'A company/shop logo representing your business.', 'woocommerce-delivery-notes' ); ?>
|
211 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
212 |
-
<?php _e( 'When the image is printed, its pixel density will automatically be eight times higher than the original. This means, 1 printed inch will correspond to about 288 pixels on the screen. Example: an image with a width of 576 pixels and a height of 288 pixels will have a printed size of about 2 inches to 1 inch.', 'woocommerce-delivery-notes' ); ?>
|
213 |
-
</span>
|
214 |
-
</td>
|
215 |
-
</tr>
|
216 |
-
<tr>
|
217 |
-
<th>
|
218 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>custom_company_name"><?php _e( 'Company/Shop Name', 'woocommerce-delivery-notes' ); ?></label>
|
219 |
-
</th>
|
220 |
-
<td>
|
221 |
-
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>custom_company_name" rows="2" class="large-text"><?php echo wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'custom_company_name' ) ); ?></textarea>
|
222 |
-
<span class="description">
|
223 |
-
<?php _e( 'Your company/shop name for the Delivery Note.', 'woocommerce-delivery-notes' ); ?>
|
224 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
225 |
-
<?php _e( 'Leave blank to use the default Website/ Blog title defined in WordPress settings.', 'woocommerce-delivery-notes' ); ?>
|
226 |
-
</span>
|
227 |
-
</td>
|
228 |
-
</tr>
|
229 |
-
<tr>
|
230 |
-
<th>
|
231 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_address"><?php _e( 'Company/Shop Address', 'woocommerce-delivery-notes' ); ?></label>
|
232 |
-
</th>
|
233 |
-
<td>
|
234 |
-
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_address" rows="5" class="large-text"><?php echo wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'company_address' ) ); ?></textarea>
|
235 |
-
<span class="description">
|
236 |
-
<?php _e( 'The postal address of the company/shop, which gets printed right of the company/shop name, above the order listings.', 'woocommerce-delivery-notes' ); ?>
|
237 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
238 |
-
<?php _e('Leave blank to not print an address.', 'woocommerce-delivery-notes' ); ?>
|
239 |
-
</span>
|
240 |
-
</td>
|
241 |
-
</tr>
|
242 |
-
<tr>
|
243 |
-
<th>
|
244 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>personal_notes"><?php _e( 'Personal Notes', 'woocommerce-delivery-notes' ); ?></label>
|
245 |
-
</th>
|
246 |
-
<td>
|
247 |
-
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>personal_notes" rows="5" class="large-text"><?php echo wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'personal_notes' ) ); ?></textarea>
|
248 |
-
<span class="description">
|
249 |
-
<?php _e( 'Add some personal notes, or season greetings or whatever (e.g. Thank You for Your Order!, Merry Christmas!, etc.).', 'woocommerce-delivery-notes' ); ?>
|
250 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
251 |
-
<?php _e('Leave blank to not print any personal notes.', 'woocommerce-delivery-notes' ); ?>
|
252 |
-
</span>
|
253 |
-
</td>
|
254 |
-
</tr>
|
255 |
-
<tr>
|
256 |
-
<th>
|
257 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>policies_conditions"><?php _e( 'Returns Policy, Conditions, etc.:', 'woocommerce-delivery-notes' ); ?></label>
|
258 |
-
</th>
|
259 |
-
<td>
|
260 |
-
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>policies_conditions" rows="5" class="large-text"><?php echo wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'policies_conditions' ) ); ?></textarea>
|
261 |
-
<span class="description">
|
262 |
-
<?php _e( 'Here you can add some more policies, conditions etc. For example add a returns policy in case the client would like to send back some goods. In some countries (e.g. in the European Union) this is required so please add any required info in accordance with the statutory regulations.', 'woocommerce-delivery-notes' ); ?>
|
263 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
264 |
-
<?php _e('Leave blank to not print any policies or conditions.', 'woocommerce-delivery-notes' ); ?>
|
265 |
-
</span>
|
266 |
-
</td>
|
267 |
-
</tr>
|
268 |
-
<tr>
|
269 |
-
<th>
|
270 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>footer_imprint"><?php _e( 'Footer Imprint', 'woocommerce-delivery-notes' ); ?></label>
|
271 |
-
</th>
|
272 |
-
<td>
|
273 |
-
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>footer_imprint" rows="5" class="large-text"><?php echo wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'footer_imprint' ) ); ?></textarea>
|
274 |
-
<span class="description">
|
275 |
-
<?php _e( 'Add some further footer imprint, copyright notes etc. to get the printed sheets a bit more branded to your needs.', 'woocommerce-delivery-notes' ); ?>
|
276 |
-
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
277 |
-
<?php _e('Leave blank to not print a footer.', 'woocommerce-delivery-notes' ); ?>
|
278 |
-
</span>
|
279 |
-
</td>
|
280 |
-
</tr>
|
281 |
-
<tr>
|
282 |
-
<th>
|
283 |
-
</th>
|
284 |
-
<td>
|
285 |
-
<?php
|
286 |
-
// show template preview links when an order is available
|
287 |
-
$args = array(
|
288 |
-
'post_type' => 'shop_order',
|
289 |
-
'posts_per_page' => 1
|
290 |
-
);
|
291 |
-
$query = new WP_Query( $args );
|
292 |
-
|
293 |
-
if($query->have_posts()) : ?>
|
294 |
-
<?php
|
295 |
-
$results = $query->get_posts();
|
296 |
-
$test_id = $results[0]->ID;
|
297 |
-
$invoice_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $test_id ), 'generate_print_content' );
|
298 |
-
$note_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=delivery-note&order_id=' . $test_id ), 'generate_print_content' );
|
299 |
-
?>
|
300 |
-
<span class="description">
|
301 |
-
<?php printf( __( 'You can <a href="%1$s" target="%3$s" class="%4$s">preview the invoice template</a> or <a href="%2$s" target="%3$s" class="%4$s">the delivery note template</a>.', 'woocommerce-delivery-notes' ), $invoice_url, $note_url, '_blank', 'print-preview-button' ); ?>
|
302 |
-
<?php _e( 'For more advanced control copy <code>woocommerce-delivery-notes/templates/print/style.css</code> to <code>your-theme-name/woocommerce/print/style.css</code>.', 'woocommerce-delivery-notes' ); ?>
|
303 |
-
</span>
|
304 |
-
<?php endif; ?>
|
305 |
-
</td>
|
306 |
-
</tr>
|
307 |
-
</tbody>
|
308 |
-
</table>
|
309 |
-
<h3><?php _e( 'Order Numbering Options', 'woocommerce-delivery-notes' ); ?></h3>
|
310 |
-
<table class="form-table">
|
311 |
-
<tbody>
|
312 |
-
<tr>
|
313 |
-
<th>
|
314 |
-
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>order_number_offset"><?php _e( 'Sequential order number', 'woocommerce-delivery-notes' ); ?></label>
|
315 |
-
</th>
|
316 |
-
<td>
|
317 |
-
<?php if( $this->is_woocommerce_sequential_order_numbers_activated() ) : ?>
|
318 |
-
<?php _e( 'Sequential numbering is enabled.', 'woocommerce-delivery-notes' ); ?>
|
319 |
-
<?php else : ?>
|
320 |
-
<?php printf( __( 'Install and activate the free <a href="%s">WooCommerce Sequential Order Numbers</a> Plugin.', 'woocommerce-delivery-notes' ), 'http://wordpress.org/extend/plugins/woocommerce-sequential-order-numbers/' ); ?>
|
321 |
-
<?php endif; ?>
|
322 |
-
</td>
|
323 |
-
</tr>
|
324 |
-
</tbody>
|
325 |
-
</table>
|
326 |
-
|
327 |
-
<input type="hidden" name="<?php echo $this->hidden_submit; ?>" value="submitted">
|
328 |
-
<?php
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Get the content for an option
|
333 |
-
*/
|
334 |
-
public function get_setting( $name ) {
|
335 |
-
return get_option( WooCommerce_Delivery_Notes::$plugin_prefix . $name );
|
336 |
-
}
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Save all settings
|
340 |
-
*/
|
341 |
-
public function save_settings_page() {
|
342 |
-
if ( isset( $_POST[ $this->hidden_submit ] ) && $_POST[ $this->hidden_submit ] == 'submitted' ) {
|
343 |
-
foreach ( $_POST as $key => $value ) {
|
344 |
-
if ( $key != $this->hidden_submit && strpos( $key, WooCommerce_Delivery_Notes::$plugin_prefix ) !== false ) {
|
345 |
-
if ( empty( $value ) ) {
|
346 |
-
delete_option( $key );
|
347 |
-
} else {
|
348 |
-
if ( get_option( $key ) && get_option( $key ) != $value ) {
|
349 |
-
update_option( $key, $value );
|
350 |
-
}
|
351 |
-
else {
|
352 |
-
add_option( $key, $value );
|
353 |
-
}
|
354 |
-
}
|
355 |
-
}
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
}
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class-wcdn-writepanel.php
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Writepanel class
|
5 |
-
*/
|
6 |
-
if ( !class_exists( 'WooCommerce_Delivery_Notes_Writepanel' ) ) {
|
7 |
-
|
8 |
-
class WooCommerce_Delivery_Notes_Writepanel {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Constructor
|
12 |
-
*/
|
13 |
-
public function __construct() {
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Load the class
|
18 |
-
*/
|
19 |
-
public function load() {
|
20 |
-
add_action( 'admin_init', array( $this, 'load_hooks' ) );
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Load the admin hooks
|
25 |
-
*/
|
26 |
-
public function load_hooks() {
|
27 |
-
add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
|
28 |
-
add_action( 'add_meta_boxes_shop_order', array( $this, 'add_box' ) );
|
29 |
-
add_action( 'admin_print_scripts', array( $this, 'add_scripts' ) );
|
30 |
-
add_action( 'admin_print_styles', array( $this, 'add_styles' ) );
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Add the styles
|
35 |
-
*/
|
36 |
-
public function add_styles() {
|
37 |
-
if( $this->is_order_edit_page() ) {
|
38 |
-
wp_enqueue_style( 'thickbox' );
|
39 |
-
wp_enqueue_style( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'css/style.css' );
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Add the scripts
|
45 |
-
*/
|
46 |
-
public function add_scripts() {
|
47 |
-
if( $this->is_order_edit_page() ) {
|
48 |
-
?>
|
49 |
-
<script type="text/javascript">
|
50 |
-
var show_print_preview = 'no';
|
51 |
-
</script>
|
52 |
-
<?php
|
53 |
-
wp_enqueue_script( 'media-upload' );
|
54 |
-
wp_enqueue_script( 'thickbox' );
|
55 |
-
wp_enqueue_script( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'js/script.js', array( 'jquery', 'media-upload', 'thickbox' ) );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Is order page
|
61 |
-
*/
|
62 |
-
public function is_order_edit_page() {
|
63 |
-
global $post_type;
|
64 |
-
if( $post_type == 'shop_order' ) {
|
65 |
-
return true;
|
66 |
-
} else {
|
67 |
-
return false;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Add print actions to the orders listing
|
73 |
-
*/
|
74 |
-
public function add_listing_actions( $order ) {
|
75 |
-
?>
|
76 |
-
<a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $order->id ), 'generate_print_content' ); ?>" class="button tips print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>">
|
77 |
-
<span><?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?></span>
|
78 |
-
<img src="<?php echo WooCommerce_Delivery_Notes::$plugin_url . 'images/print-invoice.png'; ?>" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" width="14">
|
79 |
-
</a>
|
80 |
-
<a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=delivery-note&order_id=' . $order->id ), 'generate_print_content' ); ?>" class="button tips print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>">
|
81 |
-
<span><?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?></span>
|
82 |
-
<img src="<?php echo WooCommerce_Delivery_Notes::$plugin_url . 'images/print-delivery-note.png'; ?>" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" width="14">
|
83 |
-
</a>
|
84 |
-
<img src="<?php echo admin_url( 'images/wpspin_light.gif' ); ?>" class="loading" alt="">
|
85 |
-
<?php
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Add the meta box on the single order page
|
90 |
-
*/
|
91 |
-
public function add_box() {
|
92 |
-
add_meta_box( 'woocommerce-delivery-notes-box', __( 'Order Print', 'woocommerce-delivery-notes' ), array( $this, 'create_box_content' ), 'shop_order', 'side', 'default' );
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Create the meta box content on the single order page
|
97 |
-
*/
|
98 |
-
public function create_box_content() {
|
99 |
-
global $post_id;
|
100 |
-
?>
|
101 |
-
<ul class="woocommerce-delivery-notes-actions">
|
102 |
-
<li><a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $post_id ), 'generate_print_content' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?></a></li>
|
103 |
-
<li><a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=delivery-note&order_id=' . $post_id ), 'generate_print_content' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?></a></li>
|
104 |
-
</ul>
|
105 |
-
<img src="<?php echo admin_url( 'images/wpspin_light.gif' ); ?>" class="loading" alt="">
|
106 |
-
<?php
|
107 |
-
}
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/admin.css
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Icons */
|
2 |
+
|
3 |
+
@font-face {
|
4 |
+
font-family: 'icons';
|
5 |
+
src: url('../fonts/icons.eot?99179621');
|
6 |
+
src: url('../fonts/icons.eot?99179621#iefix') format('embedded-opentype'),
|
7 |
+
url('../fonts/icons.woff?99179621') format('woff'),
|
8 |
+
url('../fonts/icons.ttf?99179621') format('truetype'),
|
9 |
+
url('../fonts/icons.svg?99179621#icons') format('svg');
|
10 |
+
font-weight: normal;
|
11 |
+
font-style: normal;
|
12 |
+
}
|
13 |
+
|
14 |
+
/* Edit order */
|
15 |
+
|
16 |
+
#woocommerce-delivery-notes-box .button {
|
17 |
+
overflow: hidden;
|
18 |
+
max-width: 100%;
|
19 |
+
text-overflow: ellipsis;
|
20 |
+
margin-top: 0.65em;
|
21 |
+
margin-bottom: 0.35em;
|
22 |
+
}
|
23 |
+
|
24 |
+
#woocommerce-delivery-notes-box span.print-preview-loading {
|
25 |
+
position: absolute;
|
26 |
+
right: 2.5em;
|
27 |
+
top: -2.8em;
|
28 |
+
}
|
29 |
+
|
30 |
+
#woocommerce-delivery-notes-box span.print-preview-loading,
|
31 |
+
.type-shop_order .column-order_actions span.print-preview-loading {
|
32 |
+
display: none;
|
33 |
+
vertical-align: middle;
|
34 |
+
}
|
35 |
+
|
36 |
+
/* All orders */
|
37 |
+
.type-shop_order .column-order_actions .print-preview-button {
|
38 |
+
display: block;
|
39 |
+
text-indent: -9999px;
|
40 |
+
position: relative;
|
41 |
+
height: 1em;
|
42 |
+
width: 1em;
|
43 |
+
padding: 0 !important;
|
44 |
+
height: 2em !important;
|
45 |
+
width: 2em;
|
46 |
+
}
|
47 |
+
|
48 |
+
.type-shop_order .column-order_actions .print-preview-button:before {
|
49 |
+
font-family: "icons";
|
50 |
+
speak: none;
|
51 |
+
font-weight: normal;
|
52 |
+
font-variant: normal;
|
53 |
+
text-transform: none;
|
54 |
+
-webkit-font-smoothing: antialiased;
|
55 |
+
margin: 0;
|
56 |
+
text-indent: 0;
|
57 |
+
position: absolute;
|
58 |
+
top: 0;
|
59 |
+
left: 0;
|
60 |
+
width: 100%;
|
61 |
+
height: 100%;
|
62 |
+
text-align: center;
|
63 |
+
content: "";
|
64 |
+
line-height: 1.85;
|
65 |
+
}
|
66 |
+
|
67 |
+
.type-shop_order .column-order_actions .print-preview-button.invoice:before {
|
68 |
+
content: "\e801";
|
69 |
+
}
|
70 |
+
|
71 |
+
.type-shop_order .column-order_actions .print-preview-button.delivery-note:before {
|
72 |
+
content: "\e800";
|
73 |
+
}
|
74 |
+
|
75 |
+
.type-shop_order .column-order_actions span.print-preview-loading {
|
76 |
+
float: left;
|
77 |
+
margin-top: 3px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.type-shop_order .column-order_actions .print-preview-button span {
|
81 |
+
display: none;
|
82 |
+
}
|
83 |
+
|
84 |
+
/* Settings */
|
85 |
+
|
86 |
+
#company-logo-placeholder {
|
87 |
+
}
|
88 |
+
|
89 |
+
#company-logo-placeholder img {
|
90 |
+
cursor: pointer;
|
91 |
+
max-width: 200px;
|
92 |
+
height: auto;
|
93 |
+
}
|
94 |
+
|
95 |
+
#company-logo-loader.spinner {
|
96 |
+
float: none;
|
97 |
+
}
|
98 |
+
|
99 |
+
#company-logo-loader.print-preview-loading {
|
100 |
+
display: inline-block;
|
101 |
+
}
|
css/style.css
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
#woocommerce-delivery-notes-box .inside {
|
2 |
-
text-align: left;
|
3 |
-
position: relative;
|
4 |
-
}
|
5 |
-
#woocommerce-delivery-notes-box .inside ul {
|
6 |
-
overflow: hidden;
|
7 |
-
margin: 0px;
|
8 |
-
}
|
9 |
-
#woocommerce-delivery-notes-box .inside ul li {
|
10 |
-
float: left;
|
11 |
-
margin: 3px;
|
12 |
-
}
|
13 |
-
#woocommerce-delivery-notes-box .inside img.loading {
|
14 |
-
position: absolute;
|
15 |
-
right: 7px;
|
16 |
-
top: 0px;
|
17 |
-
}
|
18 |
-
#woocommerce-delivery-notes-box .inside img.loading,
|
19 |
-
.type-shop_order .column-order_actions img.loading {
|
20 |
-
display: none;
|
21 |
-
vertical-align: middle;
|
22 |
-
}
|
23 |
-
.type-shop_order .column-order_actions img.loading {
|
24 |
-
float: left;
|
25 |
-
margin-top: 3px;
|
26 |
-
}
|
27 |
-
.type-shop_order .column-order_actions .print-preview-button span {
|
28 |
-
display: none;
|
29 |
-
}
|
30 |
-
#company-logo-placeholder {
|
31 |
-
display: block;
|
32 |
-
}
|
33 |
-
#company-logo-placeholder.loading {
|
34 |
-
background-image: url("../../../../wp-admin/images/wpspin_light.gif");
|
35 |
-
background-repeat: no-repeat;
|
36 |
-
height: 20px;
|
37 |
-
}
|
38 |
-
#company-logo-placeholder img {
|
39 |
-
cursor: pointer;
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fonts/icons.eot
ADDED
Binary file
|
fonts/icons.svg
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
+
<metadata>Copyright (C) 2014 by original authors @ fontello.com</metadata>
|
5 |
+
<defs>
|
6 |
+
<font id="icons" horiz-adv-x="1000" >
|
7 |
+
<font-face font-family="icons" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
8 |
+
<missing-glyph horiz-adv-x="1000" />
|
9 |
+
<glyph glyph-name="delivery-note" unicode="" d="m701 850h-581v-1000h760v825l-179 175z m119-940h-640v880h490v-150h150v-730z m-540 500h440v60h-440v-60z m0-160h440v60h-440v-60z m0-160h440v60h-440v-60z" horiz-adv-x="1000" />
|
10 |
+
<glyph glyph-name="invoice" unicode="" d="m701 850h-581v-1000h760v825l-179 175z m119-940h-640v880h490v-150h150v-730z m-310 449v164c30-9 51-24 66-52l55 32c-26 47-61 76-121 81v66h-30v-66c-70-5-127-69-127-138c0-68 46-100 101-128l26-13v-210c-60 8-89 40-101 99l-63-13c13-81 84-146 164-147v-64h30v64c80 10 137 88 137 164c0 86-67 130-137 161z m-30 16c-40 14-65 35-65 76c0 37 25 67 65 72v-148z m30-275v189c40-20 74-47 74-94c0-45-24-86-74-95z" horiz-adv-x="1000" />
|
11 |
+
</font>
|
12 |
+
</defs>
|
13 |
+
</svg>
|
fonts/icons.ttf
ADDED
Binary file
|
fonts/icons.woff
ADDED
Binary file
|
images/print-delivery-note.png
DELETED
Binary file
|
images/print-invoice.png
DELETED
Binary file
|
includes/class-wcdn-print.php
ADDED
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Print class
|
5 |
+
*/
|
6 |
+
if ( ! class_exists( 'WooCommerce_Delivery_Notes_Print' ) ) {
|
7 |
+
|
8 |
+
class WooCommerce_Delivery_Notes_Print {
|
9 |
+
|
10 |
+
public $template_directory_name;
|
11 |
+
public $template_path_theme;
|
12 |
+
public $template_path_plugin;
|
13 |
+
public $template_url_plugin;
|
14 |
+
|
15 |
+
public $api_endpoints;
|
16 |
+
public $query_vars;
|
17 |
+
public $template_types;
|
18 |
+
public $template_type;
|
19 |
+
|
20 |
+
public $order_ids;
|
21 |
+
public $order_email;
|
22 |
+
public $orders;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Constructor
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
// Set the default variables
|
29 |
+
$this->template_types = array(
|
30 |
+
'invoice',
|
31 |
+
'delivery-note',
|
32 |
+
'order'
|
33 |
+
);
|
34 |
+
|
35 |
+
$this->api_endpoints = array(
|
36 |
+
'print-order' => get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_order_page_endpoint', 'print-order' )
|
37 |
+
|
38 |
+
);
|
39 |
+
|
40 |
+
$this->query_vars = array(
|
41 |
+
'print-order-type',
|
42 |
+
'print-order-email'
|
43 |
+
);
|
44 |
+
|
45 |
+
// Load the hooks
|
46 |
+
add_action( 'init', array( $this, 'load_hooks' ) );
|
47 |
+
add_filter( 'query_vars', array( $this, 'add_query_vars' ) );
|
48 |
+
add_action( 'parse_request', array( $this, 'parse_request' ) );
|
49 |
+
add_action( 'template_redirect', array( $this, 'template_redirect_theme' ) );
|
50 |
+
add_action( 'wp_ajax_print_order', array( $this, 'template_redirect_admin' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Load the init hooks
|
55 |
+
*/
|
56 |
+
public function load_hooks() {
|
57 |
+
// Define default variables
|
58 |
+
$this->template_directory_name = 'print-order';
|
59 |
+
$this->template_path_theme = WC_TEMPLATE_PATH . $this->template_directory_name . '/';
|
60 |
+
$this->template_path_plugin = WooCommerce_Delivery_Notes::$plugin_path . 'templates/' . $this->template_directory_name . '/';
|
61 |
+
$this->template_url_plugin = WooCommerce_Delivery_Notes::$plugin_url . 'templates/' . $this->template_directory_name . '/';
|
62 |
+
|
63 |
+
// Add the endpoints
|
64 |
+
$this->add_endpoints();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Add endpoints for query vars.
|
69 |
+
* the endpoint is used in the front-end to
|
70 |
+
* generate the print template and link.
|
71 |
+
*/
|
72 |
+
public function add_endpoints() {
|
73 |
+
foreach( $this->api_endpoints as $var ) {
|
74 |
+
add_rewrite_endpoint( $var, EP_PAGES );
|
75 |
+
}
|
76 |
+
|
77 |
+
// Flush the rules when the transient is set.
|
78 |
+
// This is important to make the endpoint work.
|
79 |
+
if( get_transient( WooCommerce_Delivery_Notes::$plugin_prefix . 'flush_rewrite_rules' ) == true ) {
|
80 |
+
delete_transient( WooCommerce_Delivery_Notes::$plugin_prefix . 'flush_rewrite_rules' );
|
81 |
+
flush_rewrite_rules();
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add the query vars when no permalink structures aren't supported.
|
87 |
+
*/
|
88 |
+
public function add_query_vars( $vars ) {
|
89 |
+
foreach( $this->query_vars as $var ) {
|
90 |
+
$vars[] = $var;
|
91 |
+
}
|
92 |
+
return $vars;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Parse the query variables
|
97 |
+
*/
|
98 |
+
public function parse_request( $wp ) {
|
99 |
+
// Map endpoint keys to their query var keys, or get them if there is no permalink structure.
|
100 |
+
foreach( $this->api_endpoints as $key => $var ) {
|
101 |
+
if( isset( $_GET[$var] ) ) {
|
102 |
+
$wp->query_vars[$key] = $_GET[$var];
|
103 |
+
} elseif ( isset( $wp->query_vars[$var] ) ) {
|
104 |
+
$wp->query_vars[$key] = $wp->query_vars[$var];
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Template handling in the front-end
|
111 |
+
*/
|
112 |
+
public function template_redirect_theme() {
|
113 |
+
global $wp;
|
114 |
+
// Check the page url and display the template when on my-account page
|
115 |
+
if( !empty( $wp->query_vars['print-order'] ) && is_account_page() ) {
|
116 |
+
$type = !empty( $wp->query_vars['print-order-type'] ) ? $wp->query_vars['print-order-type'] : null;
|
117 |
+
$email = !empty( $wp->query_vars['print-order-email'] ) ? $wp->query_vars['print-order-email'] : null;
|
118 |
+
$this->generate_template( $wp->query_vars['print-order'], $type, $email );
|
119 |
+
exit;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Template handling in the back-end
|
125 |
+
*/
|
126 |
+
public function template_redirect_admin() {
|
127 |
+
// Let the backend only access the page
|
128 |
+
if( is_admin() && !empty( $_REQUEST['print-order'] ) && !empty( $_REQUEST['action'] ) ) {
|
129 |
+
$type = !empty( $_REQUEST['print-order-type'] ) ? $_REQUEST['print-order-type'] : null;
|
130 |
+
$email = !empty( $_REQUEST['print-order-email'] ) ? $_REQUEST['print-order-email'] : null;
|
131 |
+
$this->generate_template( $_GET['print-order'], $type, $email );
|
132 |
+
exit;
|
133 |
+
}
|
134 |
+
exit;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Generate the template
|
139 |
+
*/
|
140 |
+
public function generate_template( $order_ids, $template_type = 'order', $order_email = null ) {
|
141 |
+
global $post, $wp;
|
142 |
+
|
143 |
+
// Explode the ids when needed
|
144 |
+
if( !is_array( $order_ids ) ) {
|
145 |
+
$this->order_ids = array_filter( explode('-', $order_ids ) );
|
146 |
+
}
|
147 |
+
|
148 |
+
// Default type
|
149 |
+
if( empty( $template_type ) || !in_array( $template_type, $this->template_types ) ) {
|
150 |
+
$this->template_type = 'order';
|
151 |
+
} else {
|
152 |
+
$this->template_type = $template_type;
|
153 |
+
}
|
154 |
+
|
155 |
+
// Default email
|
156 |
+
if( empty( $order_email ) ) {
|
157 |
+
$this->order_email = null;
|
158 |
+
} else {
|
159 |
+
$this->order_email = strtolower( $order_email );
|
160 |
+
}
|
161 |
+
|
162 |
+
// Create the orders and check permissions
|
163 |
+
$populated = $this->populate_orders();
|
164 |
+
|
165 |
+
// Only continue if the orders are populated
|
166 |
+
if( !$populated ) {
|
167 |
+
die();
|
168 |
+
}
|
169 |
+
|
170 |
+
// Load the print template html
|
171 |
+
wc_get_template( 'print-order.php', null, $this->template_path_theme, $this->template_path_plugin );
|
172 |
+
exit;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Get print page url
|
177 |
+
*/
|
178 |
+
public function get_print_page_url( $order_ids, $template_type = 'order', $order_email = null ) {
|
179 |
+
// Explode the ids when needed
|
180 |
+
if( !is_array( $order_ids ) ) {
|
181 |
+
$order_ids = array_filter( explode( '-', $order_ids ) );
|
182 |
+
}
|
183 |
+
|
184 |
+
// Default args
|
185 |
+
$args = array();
|
186 |
+
|
187 |
+
if( in_array( $template_type, $this->template_types ) && $template_type != 'order' ) {
|
188 |
+
$args = wp_parse_args( array( 'print-order-type' => $template_type ), $args );
|
189 |
+
}
|
190 |
+
|
191 |
+
if( !empty( $order_email ) ) {
|
192 |
+
$args = wp_parse_args( array( 'print-order-email' => $order_email ), $args );
|
193 |
+
}
|
194 |
+
|
195 |
+
// Generate the url
|
196 |
+
$order_ids_slug = implode( '-', $order_ids );
|
197 |
+
|
198 |
+
// Create another url depending on where the user prints. This
|
199 |
+
// prevents some issues with ssl when the my-account page is
|
200 |
+
// secured with ssl but the admin isn't.
|
201 |
+
// wp_nonce_url( admin_url( 'admin-ajax.php?action=print_order_admin&template_type=invoice&order_id=' . $post_id ), 'generate_print_content' );
|
202 |
+
if( is_admin() ) {
|
203 |
+
// For the admin
|
204 |
+
$args = wp_parse_args( array( 'action' => 'print_order' ), $args );
|
205 |
+
$base_url = admin_url( 'admin-ajax.php' );
|
206 |
+
$endpoint = 'print-order';
|
207 |
+
|
208 |
+
// Add the order ids and create the url
|
209 |
+
$url = add_query_arg( $endpoint, $order_ids_slug, $base_url );
|
210 |
+
} else {
|
211 |
+
// For the theme
|
212 |
+
$base_url = get_permalink( wc_get_page_id( 'myaccount' ) );
|
213 |
+
$endpoint = $this->api_endpoints['print-order'];
|
214 |
+
|
215 |
+
// Add the order ids and create the url
|
216 |
+
if( get_option( 'permalink_structure' ) ) {
|
217 |
+
$url = trailingslashit( trailingslashit( $base_url ) . $endpoint . '/' . $order_ids_slug );
|
218 |
+
} else {
|
219 |
+
$url = add_query_arg( $endpoint, $order_ids_slug, $base_url );
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
// Add all other args
|
224 |
+
$url = add_query_arg( $args, $url );
|
225 |
+
|
226 |
+
return $url;
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Get the template url for a file. locate by file existence
|
231 |
+
* and then return the corresponding url.
|
232 |
+
*/
|
233 |
+
public function get_template_url( $name ) {
|
234 |
+
$child_theme_path = get_stylesheet_directory() . '/' . $this->template_path_theme;
|
235 |
+
$child_theme_uri = get_stylesheet_directory_uri() . '/' . $this->template_path_theme;
|
236 |
+
$theme_path = get_template_directory() . '/' . $this->template_path_theme;
|
237 |
+
$theme_uri = get_template_directory_uri() . '/' . $this->template_path_theme;
|
238 |
+
|
239 |
+
// buld the url depenind on where the file is
|
240 |
+
if( file_exists( $child_theme_path . $name ) ) {
|
241 |
+
$uri = $child_theme_uri . $name;
|
242 |
+
} elseif( file_exists( $theme_path . $name ) ) {
|
243 |
+
$uri = $theme_uri . $name;
|
244 |
+
} else {
|
245 |
+
$uri = $this->template_url_plugin . $name;
|
246 |
+
}
|
247 |
+
|
248 |
+
return $uri;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Create the orders list and check the permissions
|
253 |
+
*/
|
254 |
+
private function populate_orders() {
|
255 |
+
$this->orders = array();
|
256 |
+
|
257 |
+
// Get the orders
|
258 |
+
$args = array(
|
259 |
+
'posts_per_page' => -1,
|
260 |
+
'post_type' => 'shop_order',
|
261 |
+
'post_status' => 'publish',
|
262 |
+
'post__in' => $this->order_ids,
|
263 |
+
'orderby' => 'post__in'
|
264 |
+
);
|
265 |
+
$posts = get_posts( $args );
|
266 |
+
|
267 |
+
// All orders should exist
|
268 |
+
if( count( $posts ) !== count( $this->order_ids ) ) {
|
269 |
+
$this->orders = null;
|
270 |
+
return false;
|
271 |
+
}
|
272 |
+
|
273 |
+
// Check permissons of the user to determine
|
274 |
+
// if the orders should be populated.
|
275 |
+
foreach( $posts as $post ) {
|
276 |
+
$order = new WC_Order( $post->ID );
|
277 |
+
|
278 |
+
// Logged in users
|
279 |
+
if( is_user_logged_in() && ( !current_user_can( 'edit_shop_orders' ) && !current_user_can( 'view_order', $order->id ) ) ) {
|
280 |
+
$this->orders = null;
|
281 |
+
return false;
|
282 |
+
}
|
283 |
+
|
284 |
+
// An email is required for not logged in users
|
285 |
+
if( !is_user_logged_in() && ( empty( $this->order_email ) || strtolower( $order->billing_email ) != $this->order_email ) ) {
|
286 |
+
$this->orders = null;
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
// Save the order to get it without an additional database call
|
291 |
+
$this->orders[$post->ID] = $order;
|
292 |
+
}
|
293 |
+
return true;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Get the order
|
298 |
+
*/
|
299 |
+
public function get_order( $order_id ) {
|
300 |
+
if( isset( $this->orders[$order_id] ) ) {
|
301 |
+
return $this->orders[$order_id];
|
302 |
+
}
|
303 |
+
return;
|
304 |
+
}
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
?>
|
includes/class-wcdn-settings.php
ADDED
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Settings class
|
5 |
+
*/
|
6 |
+
if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
|
7 |
+
|
8 |
+
class WooCommerce_Delivery_Notes_Settings {
|
9 |
+
|
10 |
+
public $tab_name;
|
11 |
+
public $hidden_submit;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Constructor
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
// Define default variables
|
18 |
+
$this->tab_name = 'woocommerce-delivery-notes';
|
19 |
+
$this->hidden_submit = WooCommerce_Delivery_Notes::$plugin_prefix . 'submit';
|
20 |
+
|
21 |
+
// Load the hooks
|
22 |
+
add_action( 'admin_init', array( $this, 'load_admin_hooks' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Load the admin hooks
|
27 |
+
*/
|
28 |
+
public function load_admin_hooks() {
|
29 |
+
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ), 100 );
|
30 |
+
add_action( 'woocommerce_settings_tabs_' . $this->tab_name, array( $this, 'create_settings_page' ) );
|
31 |
+
add_action( 'woocommerce_update_options_' . $this->tab_name, array( $this, 'save_settings_page' ) );
|
32 |
+
add_action( 'current_screen', array( $this, 'load_screen_hooks' ) );
|
33 |
+
add_action( 'wp_ajax_load_thumbnail', array( $this, 'load_thumbnail_ajax' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Add the scripts
|
38 |
+
*/
|
39 |
+
public function load_screen_hooks() {
|
40 |
+
$screen = get_current_screen();
|
41 |
+
|
42 |
+
if( $this->is_settings_page() ) {
|
43 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) );
|
44 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_styles' ) );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Add the styles
|
50 |
+
*/
|
51 |
+
public function add_styles() {
|
52 |
+
wp_enqueue_style( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'css/admin.css' );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add the scripts
|
57 |
+
*/
|
58 |
+
public function add_scripts() {
|
59 |
+
wp_enqueue_media();
|
60 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-print-link', WooCommerce_Delivery_Notes::$plugin_url . 'js/jquery.print-link.js', array( 'jquery' ) );
|
61 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'js/admin.js', array( 'jquery', 'custom-header', 'woocommerce-delivery-notes-print-link' ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Check if we are on settings page
|
66 |
+
*/
|
67 |
+
public function is_settings_page() {
|
68 |
+
if( isset( $_GET['page'] ) && isset( $_GET['tab'] ) && $_GET['tab'] == $this->tab_name ) {
|
69 |
+
return true;
|
70 |
+
} else {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Check if sequential order plugin is activated
|
77 |
+
*/
|
78 |
+
public function is_woocommerce_sequential_order_numbers_activated() {
|
79 |
+
if ( in_array( 'woocommerce-sequential-order-numbers/woocommerce-sequential-order-numbers.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
80 |
+
return true;
|
81 |
+
} else {
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Add a tab to the settings page
|
88 |
+
*/
|
89 |
+
public function add_settings_tab( $tabs ) {
|
90 |
+
$tabs[$this->tab_name] = __( 'Print', 'woocommerce-delivery-notes' );
|
91 |
+
|
92 |
+
return $tabs;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Load thumbnail with ajax
|
97 |
+
*/
|
98 |
+
public function load_thumbnail_ajax() {
|
99 |
+
$attachment_id = (int)$_POST['attachment_id'];
|
100 |
+
|
101 |
+
// Verify the id
|
102 |
+
if( !$attachment_id ) {
|
103 |
+
die();
|
104 |
+
}
|
105 |
+
|
106 |
+
// create the thumbnail
|
107 |
+
$this->create_thumbnail( $attachment_id );
|
108 |
+
|
109 |
+
exit;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Create the thumbnail
|
114 |
+
*/
|
115 |
+
public function create_thumbnail( $attachment_id ) {
|
116 |
+
$attachment_src = wp_get_attachment_image_src( $attachment_id, 'medium', false );
|
117 |
+
|
118 |
+
?>
|
119 |
+
<img src="<?php echo $attachment_src[0]; ?>" alt="" />
|
120 |
+
<?php
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Create the settings page content
|
125 |
+
*/
|
126 |
+
public function create_settings_page() {
|
127 |
+
?>
|
128 |
+
<h3><?php _e( 'Print Order', 'woocommerce-delivery-notes' ); ?></h3>
|
129 |
+
<p>
|
130 |
+
<?php
|
131 |
+
// show template preview links when an order is available
|
132 |
+
$args = array(
|
133 |
+
'post_type' => 'shop_order',
|
134 |
+
'posts_per_page' => 1
|
135 |
+
);
|
136 |
+
$query = new WP_Query( $args );
|
137 |
+
|
138 |
+
if($query->have_posts()) : ?>
|
139 |
+
<?php
|
140 |
+
$results = $query->get_posts();
|
141 |
+
$test_id = $results[0]->ID;
|
142 |
+
$invoice_url = wcdn_get_print_link( $test_id, 'invoice' );
|
143 |
+
$note_url = wcdn_get_print_link( $test_id, 'delivery-note' );
|
144 |
+
?>
|
145 |
+
<input type="hidden" id="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>show_print_preview" />
|
146 |
+
<span class="description">
|
147 |
+
<?php printf( __( 'You can preview the <a href="%1$s" target="%3$s" class="%4$s">invoice template</a> or <a href="%2$s" target="%3$s" class="%4$s">delivery note template</a>.', 'woocommerce-delivery-notes' ), $invoice_url, $note_url, '_blank', '' ); ?>
|
148 |
+
<?php _e( 'With the FAQ in the readme file you can learn how to customize the template.', 'woocommerce-delivery-notes' ); ?>
|
149 |
+
</span>
|
150 |
+
<?php endif; ?>
|
151 |
+
</p>
|
152 |
+
<table class="form-table">
|
153 |
+
<tbody>
|
154 |
+
<tr class="hide-if-no-js">
|
155 |
+
<?php
|
156 |
+
$attachment_id = get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'company_logo_image_id' );
|
157 |
+
?>
|
158 |
+
<th>
|
159 |
+
<label><?php _e( 'Company/Shop Logo', 'woocommerce-delivery-notes' ); ?></label>
|
160 |
+
</th>
|
161 |
+
<td>
|
162 |
+
<input id="company-logo-image-id" type="hidden" name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_logo_image_id" class="regular-text" value="<?php echo $attachment_id ?>" />
|
163 |
+
<div id="company-logo-placeholder"><?php if( !empty( $attachment_id ) ) : ?><?php $this->create_thumbnail( $attachment_id ); ?><?php endif; ?></div>
|
164 |
+
<div id="company-logo-buttons">
|
165 |
+
<a href="#" id="company-logo-remove-button" class="button" <?php if( empty( $attachment_id ) ) : ?>style="display: none;"<?php endif; ?>><?php _e( 'Remove Logo', 'woocommerce-delivery-notes' ); ?></a>
|
166 |
+
<a href="#" id="company-logo-add-button" class="button" <?php if( !empty( $attachment_id ) ) : ?>style="display: none;"<?php endif; ?> data-uploader-title="<?php echo esc_attr( __( 'Set Logo', 'woocommerce-delivery-notes' ) ); ?>" data-uploader-button-title="<?php echo esc_attr( __( 'Set Logo', 'woocommerce-delivery-notes' ) ); ?>"><?php _e( 'Set Logo', 'woocommerce-delivery-notes' ); ?></a>
|
167 |
+
<span id="company-logo-loader" class="spinner"></span>
|
168 |
+
</div>
|
169 |
+
<span class="description">
|
170 |
+
<?php _e( 'A company/shop logo representing your business.', 'woocommerce-delivery-notes' ); ?>
|
171 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
172 |
+
<?php _e( 'When the image is printed, its pixel density will automatically be eight times higher than the original. This means, 1 printed inch will correspond to about 288 pixels on the screen. Example: an image with a width of 576 pixels and a height of 288 pixels will have a printed size of about 2 inches to 1 inch.', 'woocommerce-delivery-notes' ); ?>
|
173 |
+
</span>
|
174 |
+
</td>
|
175 |
+
</tr>
|
176 |
+
<tr>
|
177 |
+
<th>
|
178 |
+
<label><?php _e( 'Company/Shop Name', 'woocommerce-delivery-notes' ); ?></label>
|
179 |
+
</th>
|
180 |
+
<td>
|
181 |
+
<input type="text" name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>custom_company_name" class="large-text" value="<?php echo stripslashes( wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'custom_company_name' ) ) ); ?>" />
|
182 |
+
<span class="description">
|
183 |
+
<?php _e( 'Your company/shop name for the Delivery Note.', 'woocommerce-delivery-notes' ); ?>
|
184 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
185 |
+
<?php _e( 'Leave blank to use the default Website/Blog title defined in WordPress settings. The name will be ignored when a Logo is set.', 'woocommerce-delivery-notes' ); ?>
|
186 |
+
</span>
|
187 |
+
</td>
|
188 |
+
</tr>
|
189 |
+
<tr>
|
190 |
+
<th>
|
191 |
+
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_address"><?php _e( 'Company/Shop Address', 'woocommerce-delivery-notes' ); ?></label>
|
192 |
+
</th>
|
193 |
+
<td>
|
194 |
+
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>company_address" rows="5" class="large-text"><?php echo stripslashes( wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'company_address' ) ) ); ?></textarea>
|
195 |
+
<span class="description">
|
196 |
+
<?php _e( 'The postal address of the company/shop or even e-mail or telephone, which gets printed right after the company/shop name.', 'woocommerce-delivery-notes' ); ?>
|
197 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
198 |
+
<?php _e('Leave blank to not print an address.', 'woocommerce-delivery-notes' ); ?>
|
199 |
+
</span>
|
200 |
+
</td>
|
201 |
+
</tr>
|
202 |
+
<tr>
|
203 |
+
<th>
|
204 |
+
<label><?php _e( 'Complimentary close', 'woocommerce-delivery-notes' ); ?></label>
|
205 |
+
</th>
|
206 |
+
<td>
|
207 |
+
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>personal_notes" rows="5" class="large-text"><?php echo stripslashes( wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'personal_notes' ) ) ); ?></textarea>
|
208 |
+
<span class="description">
|
209 |
+
<?php _e( 'Add some personal notes, or season greetings or whatever (e.g. Thank You for Your Order!, Merry Christmas!, etc.).', 'woocommerce-delivery-notes' ); ?>
|
210 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
211 |
+
<?php _e('Leave blank to not print any personal notes.', 'woocommerce-delivery-notes' ); ?>
|
212 |
+
</span>
|
213 |
+
</td>
|
214 |
+
</tr>
|
215 |
+
<tr>
|
216 |
+
<th>
|
217 |
+
<label><?php _e( 'Returns Policy, Conditions, etc', 'woocommerce-delivery-notes' ); ?></label>
|
218 |
+
</th>
|
219 |
+
<td>
|
220 |
+
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>policies_conditions" rows="5" class="large-text"><?php echo stripslashes( wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'policies_conditions' ) ) ); ?></textarea>
|
221 |
+
<span class="description">
|
222 |
+
<?php _e( 'Here you can add some more policies, conditions etc. For example add a returns policy in case the client would like to send back some goods. In some countries (e.g. in the European Union) this is required so please add any required info in accordance with the statutory regulations.', 'woocommerce-delivery-notes' ); ?>
|
223 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
224 |
+
<?php _e('Leave blank to not print any policies or conditions.', 'woocommerce-delivery-notes' ); ?>
|
225 |
+
</span>
|
226 |
+
</td>
|
227 |
+
</tr>
|
228 |
+
<tr>
|
229 |
+
<th>
|
230 |
+
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>footer_imprint"><?php _e( 'Footer', 'woocommerce-delivery-notes' ); ?></label>
|
231 |
+
</th>
|
232 |
+
<td>
|
233 |
+
<textarea name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>footer_imprint" rows="5" class="large-text"><?php echo stripslashes( wp_kses_stripslashes( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'footer_imprint' ) ) ); ?></textarea>
|
234 |
+
<span class="description">
|
235 |
+
<?php _e( 'Add some further footer imprint, e-mail, telephone, copyright notes etc. This makes the printed sheets a bit more branded.', 'woocommerce-delivery-notes' ); ?>
|
236 |
+
<strong><?php _e( 'Note:', 'woocommerce-delivery-notes' ); ?></strong>
|
237 |
+
<?php _e('Leave blank to not print a footer.', 'woocommerce-delivery-notes' ); ?>
|
238 |
+
</span>
|
239 |
+
</td>
|
240 |
+
</tr>
|
241 |
+
</tbody>
|
242 |
+
</table>
|
243 |
+
|
244 |
+
<h3><?php _e( 'Options', 'woocommerce-delivery-notes' ); ?></h3>
|
245 |
+
<table class="form-table">
|
246 |
+
<tbody>
|
247 |
+
<tr>
|
248 |
+
<th>
|
249 |
+
<label><?php _e( 'Print Page Endpoint', 'woocommerce-delivery-notes' ); ?></label>
|
250 |
+
</th>
|
251 |
+
<td>
|
252 |
+
<p>
|
253 |
+
<input type="text" name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>print_order_page_endpoint" value="<?php echo get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_order_page_endpoint' ); ?>" />
|
254 |
+
</p>
|
255 |
+
<span class="description">
|
256 |
+
<?php _e( 'The endpoint is appended to the accounts page URL to print the order. It should be unique.', 'woocommerce-delivery-notes' ); ?>
|
257 |
+
</span>
|
258 |
+
</td>
|
259 |
+
</tr>
|
260 |
+
<tr>
|
261 |
+
<th>
|
262 |
+
<?php _e( 'Theme Print Buttons', 'woocommerce-delivery-notes' ); ?>
|
263 |
+
</th>
|
264 |
+
<td>
|
265 |
+
<fieldset>
|
266 |
+
<label>
|
267 |
+
<input name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>print_button_on_view_order_page" type="hidden" value="" />
|
268 |
+
<input name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>print_button_on_view_order_page" type="checkbox" value="1" <?php checked( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_view_order_page' ), 1 ); ?> />
|
269 |
+
<?php _e( 'Show print button on the "View Order" page', 'woocommerce-delivery-notes' ); ?>
|
270 |
+
</label>
|
271 |
+
</fieldset>
|
272 |
+
<fieldset>
|
273 |
+
<label>
|
274 |
+
<input name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>print_button_on_my_account_page" type="hidden" value="" />
|
275 |
+
<input name="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>print_button_on_my_account_page" type="checkbox" value="1" <?php checked( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_my_account_page' ), 1 ); ?> />
|
276 |
+
<?php _e( 'Show print buttons on the "My Account" page', 'woocommerce-delivery-notes' ); ?>
|
277 |
+
</label>
|
278 |
+
</fieldset>
|
279 |
+
</td>
|
280 |
+
</tr>
|
281 |
+
</tbody>
|
282 |
+
</table>
|
283 |
+
|
284 |
+
<h3><?php _e( 'Order Numbering', 'woocommerce-delivery-notes' ); ?></h3>
|
285 |
+
<table class="form-table">
|
286 |
+
<tbody>
|
287 |
+
<tr>
|
288 |
+
<th>
|
289 |
+
<label for="<?php echo WooCommerce_Delivery_Notes::$plugin_prefix; ?>order_number_offset"><?php _e( 'Sequential order number', 'woocommerce-delivery-notes' ); ?></label>
|
290 |
+
</th>
|
291 |
+
<td>
|
292 |
+
<?php if( $this->is_woocommerce_sequential_order_numbers_activated() ) : ?>
|
293 |
+
<?php _e( 'Sequential numbering is enabled.', 'woocommerce-delivery-notes' ); ?>
|
294 |
+
<?php else : ?>
|
295 |
+
<?php printf( __( 'Install and activate the free <a href="%s">WooCommerce Sequential Order Numbers</a> Plugin.', 'woocommerce-delivery-notes' ), 'http://wordpress.org/extend/plugins/woocommerce-sequential-order-numbers/' ); ?>
|
296 |
+
<?php endif; ?>
|
297 |
+
</td>
|
298 |
+
</tr>
|
299 |
+
</tbody>
|
300 |
+
</table>
|
301 |
+
|
302 |
+
<input type="hidden" name="<?php echo $this->hidden_submit; ?>" value="submitted">
|
303 |
+
<?php
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Save all settings
|
308 |
+
*/
|
309 |
+
public function save_settings_page() {
|
310 |
+
if ( isset( $_POST[ $this->hidden_submit ] ) && $_POST[ $this->hidden_submit ] == 'submitted' ) {
|
311 |
+
|
312 |
+
// Save settings
|
313 |
+
foreach ( $_POST as $key => $value ) {
|
314 |
+
if ( $key != $this->hidden_submit && strpos( $key, WooCommerce_Delivery_Notes::$plugin_prefix ) !== false ) {
|
315 |
+
// set a default values
|
316 |
+
if ( empty( $value ) ) {
|
317 |
+
if ( $key == WooCommerce_Delivery_Notes::$plugin_prefix . 'print_order_page_endpoint' ) {
|
318 |
+
$value = 'print-order';
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
// sanitize values
|
323 |
+
if ( $key == WooCommerce_Delivery_Notes::$plugin_prefix . 'print_order_page_endpoint' ) {
|
324 |
+
$value = sanitize_title( $value );
|
325 |
+
}
|
326 |
+
|
327 |
+
// update the value
|
328 |
+
if ( empty( $value ) ) {
|
329 |
+
delete_option( $key );
|
330 |
+
} else {
|
331 |
+
if ( get_option( $key ) && get_option( $key ) != $value ) {
|
332 |
+
update_option( $key, $value );
|
333 |
+
}
|
334 |
+
else {
|
335 |
+
add_option( $key, $value );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
// Flush permalink structs with
|
342 |
+
set_transient( WooCommerce_Delivery_Notes::$plugin_prefix . 'flush_rewrite_rules', true );
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
?>
|
includes/class-wcdn-theme.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Frontend Theme class
|
5 |
+
*/
|
6 |
+
if ( !class_exists( 'WooCommerce_Delivery_Notes_Theme' ) ) {
|
7 |
+
|
8 |
+
class WooCommerce_Delivery_Notes_Theme {
|
9 |
+
|
10 |
+
public $template_type;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Constructor
|
14 |
+
*/
|
15 |
+
public function __construct() {
|
16 |
+
// Load the hooks
|
17 |
+
add_action( 'wp_loaded', array( $this, 'load_hooks' ) );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Load the hooks at the end when
|
22 |
+
* the theme and plugins are ready.
|
23 |
+
*/
|
24 |
+
public function load_hooks() {
|
25 |
+
// Define defaults
|
26 |
+
$this->template_type = apply_filters( 'wcdn_theme_print_button_template_type', 'invoice' );
|
27 |
+
|
28 |
+
// hooks
|
29 |
+
add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'create_print_button_account_page' ), 10, 2 );
|
30 |
+
add_action( 'woocommerce_view_order', array( $this, 'create_print_button_order_page' ) );
|
31 |
+
add_action( 'woocommerce_thankyou', array( $this, 'create_print_button_order_page' ) );
|
32 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Add the scripts
|
37 |
+
*/
|
38 |
+
public function add_scripts() {
|
39 |
+
if ( is_account_page() || is_order_received_page() || $this->is_woocommerce_tracking_page() ) {
|
40 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-print-link', WooCommerce_Delivery_Notes::$plugin_url . 'js/jquery.print-link.js', array( 'jquery' ) );
|
41 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-theme', WooCommerce_Delivery_Notes::$plugin_url . 'js/theme.js', array( 'jquery', 'woocommerce-delivery-notes-print-link' ) );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Create a print button for the 'My Account' page
|
47 |
+
*/
|
48 |
+
public function create_print_button_account_page( $actions, $order ) {
|
49 |
+
if( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_my_account_page' ) ) {
|
50 |
+
$actions['print'] = array(
|
51 |
+
'url' => wcdn_get_print_link( $order->id, $this->template_type ),
|
52 |
+
'name' => __( 'Print', 'woocommerce-delivery-notes' )
|
53 |
+
);
|
54 |
+
}
|
55 |
+
return $actions;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Create a print button for the 'View Order' page
|
60 |
+
*/
|
61 |
+
public function create_print_button_order_page( $order_id ) {
|
62 |
+
if( get_option( WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_view_order_page' ) ) {
|
63 |
+
$print_url = wcdn_get_print_link( $order_id, $this->template_type );
|
64 |
+
|
65 |
+
// use a different url for the tracking page
|
66 |
+
if( $this->is_woocommerce_tracking_page() ) {
|
67 |
+
$print_url = wcdn_get_print_link( $order_id, $this->template_type, $_REQUEST['order_email'] );
|
68 |
+
}
|
69 |
+
?>
|
70 |
+
<p class="order-print">
|
71 |
+
<a href="<?php echo $print_url; ?>" class="button print"><?php _e( 'Print', 'woocommerce-delivery-notes' ); ?></a>
|
72 |
+
</p>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Is WooCommerce 'Order Tracking' page
|
79 |
+
*/
|
80 |
+
public function is_woocommerce_tracking_page() {
|
81 |
+
return ( is_page( wc_get_page_id( 'order_tracking' ) ) && isset( $_REQUEST['order_email'] ) ) ? true : false;
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
?>
|
includes/class-wcdn-writepanel.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Writepanel class
|
5 |
+
*/
|
6 |
+
if ( !class_exists( 'WooCommerce_Delivery_Notes_Writepanel' ) ) {
|
7 |
+
|
8 |
+
class WooCommerce_Delivery_Notes_Writepanel {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
*/
|
13 |
+
public function __construct() {
|
14 |
+
// Load the hooks
|
15 |
+
add_action( 'admin_init', array( $this, 'load_admin_hooks' ) );
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Load the admin hooks
|
20 |
+
*/
|
21 |
+
public function load_admin_hooks() {
|
22 |
+
add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) );
|
23 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) );
|
24 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'add_styles' ) );
|
25 |
+
|
26 |
+
add_action( 'add_meta_boxes_shop_order', array( $this, 'add_box' ) );
|
27 |
+
|
28 |
+
add_action( 'admin_footer-edit.php', array( $this, 'add_bulk_actions' ) );
|
29 |
+
add_action( 'load-edit.php', array( $this, 'load_bulk_actions' ) );
|
30 |
+
add_action( 'admin_notices', array( $this, 'confirm_bulk_actions' ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Add the styles
|
35 |
+
*/
|
36 |
+
public function add_styles() {
|
37 |
+
if( $this->is_order_edit_page() || $this->is_order_post_page() ) {
|
38 |
+
wp_enqueue_style('thickbox');
|
39 |
+
wp_enqueue_style( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'css/admin.css' );
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Add the scripts
|
45 |
+
*/
|
46 |
+
public function add_scripts() {
|
47 |
+
if( $this->is_order_edit_page() || $this->is_order_post_page() ) {
|
48 |
+
wp_enqueue_script( 'thickbox' );
|
49 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-print-link', WooCommerce_Delivery_Notes::$plugin_url . 'js/jquery.print-link.js', array( 'jquery' ) );
|
50 |
+
wp_enqueue_script( 'woocommerce-delivery-notes-admin', WooCommerce_Delivery_Notes::$plugin_url . 'js/admin.js', array( 'jquery', 'woocommerce-delivery-notes-print-link', 'thickbox' ) );
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Is order edit page
|
56 |
+
*/
|
57 |
+
public function is_order_edit_page() {
|
58 |
+
global $typenow, $pagenow;
|
59 |
+
if( $typenow == 'shop_order' && $pagenow == 'edit.php' ) {
|
60 |
+
return true;
|
61 |
+
} else {
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Is order edit page
|
68 |
+
*/
|
69 |
+
public function is_order_post_page() {
|
70 |
+
global $typenow, $pagenow;
|
71 |
+
if( $typenow == 'shop_order' && ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) {
|
72 |
+
return true;
|
73 |
+
} else {
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Add print actions to the orders listing
|
80 |
+
*/
|
81 |
+
public function add_listing_actions( $order ) {
|
82 |
+
?>
|
83 |
+
<a href="<?php echo wcdn_get_print_link( $order->id, 'invoice' ); ?>" class="button tips print-preview-button invoice" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>">
|
84 |
+
<?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>
|
85 |
+
</a>
|
86 |
+
<a href="<?php echo wcdn_get_print_link( $order->id, 'delivery-note' ); ?>" class="button tips print-preview-button delivery-note" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>">
|
87 |
+
<?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>
|
88 |
+
</a>
|
89 |
+
<span class="print-preview-loading spinner"></span>
|
90 |
+
<?php
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Add bulk actions with javascript to the dropdown.
|
95 |
+
* This is not so pretty but WordPress does not yet
|
96 |
+
* offer any better solution. The JS code is inline
|
97 |
+
* because we can't determine the page without
|
98 |
+
* checking the post_type.
|
99 |
+
* https://core.trac.wordpress.org/ticket/16031
|
100 |
+
*/
|
101 |
+
public function add_bulk_actions() {
|
102 |
+
if( $this->is_order_edit_page() ) : ?>
|
103 |
+
<script type="text/javascript">
|
104 |
+
jQuery(document).ready(function($) {
|
105 |
+
$('<option>').val('wcdn_print_invoice').attr('title', 'invoice').text('<?php echo esc_js( __( 'Print Invoice', 'woocommerce-delivery-notes' ) ); ?>').appendTo('select[name="action"]');
|
106 |
+
$('<option>').val('wcdn_print_invoice').attr('title', 'invoice').text('<?php echo esc_js( __( 'Print Invoice', 'woocommerce-delivery-notes' ) ); ?>').appendTo('select[name="action2"]');
|
107 |
+
|
108 |
+
$('<option>').val('wcdn_print_delivery_note').attr('title', 'delivery-note').text('<?php echo esc_js( __( 'Print Delivery Note', 'woocommerce-delivery-notes' ) ); ?>').appendTo('select[name="action"]');
|
109 |
+
$('<option>').val('wcdn_print_delivery_note').attr('title', 'delivery-note').text('<?php echo esc_js( __( 'Print Delivery Note', 'woocommerce-delivery-notes' ) ); ?>').appendTo('select[name="action2"]');
|
110 |
+
});
|
111 |
+
</script>
|
112 |
+
<?php endif;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Add bulk print actions to the orders listing
|
117 |
+
*/
|
118 |
+
public function load_bulk_actions() {
|
119 |
+
if( $this->is_order_edit_page() ) {
|
120 |
+
// get the action staht should be started
|
121 |
+
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
122 |
+
$action = $wp_list_table->current_action();
|
123 |
+
|
124 |
+
// stop if there are no post ids
|
125 |
+
if( !isset( $_REQUEST['post'] ) ) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
// only for specified actions
|
130 |
+
switch ( $action ) {
|
131 |
+
case 'wcdn_print_invoice':
|
132 |
+
$template_type = 'invoice';
|
133 |
+
$report_action = 'printed_invoice';
|
134 |
+
break;
|
135 |
+
case 'wcdn_print_delivery_note':
|
136 |
+
$template_type = 'delivery-note';
|
137 |
+
$report_action = 'printed_delivery_note';
|
138 |
+
break;
|
139 |
+
default:
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
// do the action
|
144 |
+
$post_ids = array_map( 'absint', (array) $_REQUEST['post'] );
|
145 |
+
$total = count( $post_ids );
|
146 |
+
$url = wcdn_get_print_link( $post_ids , $template_type );
|
147 |
+
$sendback = add_query_arg( array( 'post_type' => 'shop_order', $report_action => true, 'total' => $total, 'print_url' => urlencode( $url ) ), '' );
|
148 |
+
|
149 |
+
wp_redirect( $sendback );
|
150 |
+
exit;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Show confirmation message that orders are printed
|
156 |
+
*/
|
157 |
+
public function confirm_bulk_actions() {
|
158 |
+
if( $this->is_order_edit_page() ) {
|
159 |
+
if ( isset( $_REQUEST['printed_delivery_note'] ) || isset( $_REQUEST['printed_invoice'] ) ) {
|
160 |
+
$total = isset( $_REQUEST['total'] ) ? absint( $_REQUEST['total'] ) : 0;
|
161 |
+
|
162 |
+
// Confirmation message
|
163 |
+
if( isset( $_REQUEST['printed_invoice'] ) ) {
|
164 |
+
$message = sprintf( _n( 'Invoice created.', '%s invoices created.', $total, 'woocommerce-delivery-notes' ), number_format_i18n( $total ) );
|
165 |
+
} elseif( isset( $_REQUEST['printed_delivery_note'] ) ) {
|
166 |
+
$message = sprintf( _n( 'Delivery note created.', '%s delivery notes created.', $total, 'woocommerce-delivery-notes' ), number_format_i18n( $total ) );
|
167 |
+
}
|
168 |
+
?>
|
169 |
+
<div id="woocommerce-delivery-notes-bulk-print-message" class="updated">
|
170 |
+
<p><?php echo $message; ?> <a href="<?php echo urldecode( $_REQUEST['print_url'] ); ?>" target="_blank" class="print-preview-button" id="woocommerce-delivery-notes-bulk-print-button"><?php _e( 'Print now', 'woocommerce-delivery-notes' ) ?></a> <span class="print-preview-loading spinner"></span></p>
|
171 |
+
</div>
|
172 |
+
<?php
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Add the meta box on the single order page
|
179 |
+
*/
|
180 |
+
public function add_box() {
|
181 |
+
add_meta_box( 'woocommerce-delivery-notes-box', __( 'Order Printing', 'woocommerce-delivery-notes' ), array( $this, 'create_box_content' ), 'shop_order', 'side', 'low' );
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Create the meta box content on the single order page
|
186 |
+
*/
|
187 |
+
public function create_box_content() {
|
188 |
+
global $post_id;
|
189 |
+
?>
|
190 |
+
<a href="<?php echo wcdn_get_print_link( $post_id, 'invoice' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?></a>
|
191 |
+
<a href="<?php echo wcdn_get_print_link( $post_id, 'delivery-note' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?></a>
|
192 |
+
<span class="print-preview-loading spinner"></span>
|
193 |
+
<?php
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
?>
|
includes/wcdn-template-functions.php
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|