/**
         * Create a print button for the 'View Order' page
         */
        public function create_print_button_order_page($order_id)
        {
            $order = new WC_Order($order_id);
            // Output the button only when the option is enabled
            if (get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_view_order_page')) {
                // Default button for all pages and logged in users
                $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order));
                // Pass the email to the url for the tracking
                // and thank you page. This allows to view the
                // print page without logging in.
                if ($this->is_woocommerce_tracking_page()) {
                    $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order), $_REQUEST['order_email']);
                }
                // Thank you page
                if (is_order_received_page() && !is_user_logged_in()) {
                    // Don't output the butten when there is no email
                    if (!$order->billing_email) {
                        return;
                    }
                    $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order), $order->billing_email);
                }
                ?>
				<p class="order-print">
					<a href="<?php 
                echo $print_url;
                ?>
" class="button print"><?php 
                _e('Print', 'woocommerce-delivery-notes');
                ?>
</a>
				</p>
				<?php 
            }
        }
 /**
  * Generate the description for the template settings
  */
 public function get_template_description()
 {
     $description = '';
     $args = array('post_type' => 'shop_order', 'post_status' => array('wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-cancelled', 'wc-refunded', 'wc-failed'), 'posts_per_page' => 1);
     $query = new WP_Query($args);
     // show template preview links when an order is available
     if ($query->have_posts()) {
         $results = $query->get_posts();
         $test_id = $results[0]->ID;
         $invoice_url = wcdn_get_print_link($test_id, 'invoice');
         $delivery_note_url = wcdn_get_print_link($test_id, 'delivery-note');
         $receipt_url = wcdn_get_print_link($test_id, 'receipt');
         $description = sprintf(__('This section lets you customise the content. You can preview the <a href="%1$s" target="%4$s" class="%5$s">invoice</a>, <a href="%2$s" target="%4$s" class="%5$s">delivery note</a> or <a href="%3$s" target="%4$s" class="%5$s">receipt</a> template.', 'woocommerce-delivery-notes'), $invoice_url, $delivery_note_url, $receipt_url, '_blank', '');
     }
     return $description;
 }
        /**
         * Add a print url to the emails that are sent to the customer
         */
        public function add_email_print_url($order, $sent_to_admin = true, $plain_text = false)
        {
            if (get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'email_print_link')) {
                if ($order->billing_email && !$sent_to_admin) {
                    $url = wcdn_get_print_link($order->id, $this->get_template_type($order), $order->billing_email, true);
                    if ($plain_text) {
                        echo __('Print your order', 'woocommerce-delivery-notes') . "\n\n";
                        echo $url . "\n";
                        echo "\n****************************************************\n\n";
                    } else {
                        ?>
						<p><strong><?php 
                        _e('Print:', 'woocommerce-delivery-notes');
                        ?>
</strong> <a href="<?php 
                        echo $url;
                        ?>
"><?php 
                        _e('Open print view in browser', 'woocommerce-delivery-notes');
                        ?>
</a></p>
					<?php 
                    }
                }
            }
        }
        /**
         * Create the meta box content on the single order page
         */
        public function create_box_content()
        {
            global $post_id, $wcdn;
            ?>
			<div class="print-actions">
				<?php 
            foreach (WooCommerce_Delivery_Notes_Print::$template_registrations as $template_registration) {
                ?>
					<?php 
                if (get_option('wcdn_template_type_' . $template_registration['type']) == 'yes' && $template_registration['type'] !== 'order') {
                    ?>
					
						<a href="<?php 
                    echo wcdn_get_print_link($post_id, $template_registration['type']);
                    ?>
" class="button print-preview-button <?php 
                    echo $template_registration['type'];
                    ?>
" target="_blank" alt="<?php 
                    esc_attr_e(__($template_registration['labels']['print'], 'woocommerce-delivery-notes'));
                    ?>
"><?php 
                    _e($template_registration['labels']['print'], 'woocommerce-delivery-notes');
                    ?>
</a>
					
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				<span class="print-preview-loading spinner"></span>
			</div>
			<div class="print-status"> <!-- added on 2015-12-08 by Fuyuko Gratton -->
				<input type="checkbox" name="printed" value="printed"> Invoice printed
			</div>
			<?php 
            $create_invoice_number = get_option('wcdn_create_invoice_number');
            $has_invoice_number = get_post_meta($post_id, '_wcdn_invoice_number', true);
            if (!empty($create_invoice_number) && $create_invoice_number == 'yes' && $has_invoice_number) {
                $invoice_number = wcdn_get_order_invoice_number($post_id);
                $invoice_date = wcdn_get_order_invoice_date($post_id);
                ?>
				
				<ul class="print-info">
					<li><strong><?php 
                _e('Invoice number: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_number;
                ?>
</li>
					<li><strong><?php 
                _e('Invoice date: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_date;
                ?>
</li>
				</ul>
				
			<?php 
            }
            ?>
			<?php 
        }
        /**
         * Create the settings page content
         */
        public function create_settings_page()
        {
            wp_nonce_field(WooCommerce_Delivery_Notes::$plugin_prefix . 'settings_nonce', 'settings-nonce');
            ?>
			<h3><?php 
            _e('Print Order', 'woocommerce-delivery-notes');
            ?>
</h3>
			<p>
				<?php 
            // show template preview links when an order is available
            $args = array('post_type' => 'shop_order', 'posts_per_page' => 1);
            $query = new WP_Query($args);
            if ($query->have_posts()) {
                ?>
					<?php 
                $results = $query->get_posts();
                $test_id = $results[0]->ID;
                $invoice_url = wcdn_get_print_link($test_id, 'invoice');
                $delivery_note_url = wcdn_get_print_link($test_id, 'delivery-note');
                $receipt_url = wcdn_get_print_link($test_id, 'receipt');
                ?>
					<span class="description">
						<?php 
                printf(__('You can preview the <a href="%1$s" target="%4$s" class="%5$s">invoice</a>, <a href="%2$s" target="%4$s" class="%5$s">delivery note</a> or <a href="%3$s" target="%4$s" class="%5$s">receipt</a> template.', 'woocommerce-delivery-notes'), $invoice_url, $delivery_note_url, $receipt_url, '_blank', '');
                ?>
						<?php 
                _e('With the FAQ in the readme file you can learn how to customize the template.', 'woocommerce-delivery-notes');
                ?>
					</span>
				<?php 
            }
            ?>
			</p>
			<table class="form-table">
				<tbody>
					<tr class="hide-if-no-js">
						<?php 
            $attachment_id = get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'company_logo_image_id');
            ?>
						<th>
							<label><?php 
            _e('Company/Shop Logo', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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;
            ?>
" />
							<div id="company-logo-placeholder"><?php 
            if (!empty($attachment_id)) {
                $this->create_thumbnail($attachment_id);
            }
            ?>
</div>
							<div id="company-logo-buttons">
								<a href="#" id="company-logo-remove-button" class="button" <?php 
            if (empty($attachment_id)) {
                ?>
style="display: none;"<?php 
            }
            ?>
><?php 
            _e('Remove Logo', 'woocommerce-delivery-notes');
            ?>
</a>
								<a href="#" id="company-logo-add-button" class="button" <?php 
            if (!empty($attachment_id)) {
                ?>
style="display: none;"<?php 
            }
            ?>
 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>
								<span id="company-logo-loader" class="spinner"></span>
							</div>
							<span class="description">
								<?php 
            _e('A company/shop logo representing your business.', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?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');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<label><?php 
            _e('Company/Shop Name', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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')));
            ?>
" />
							<span class="description">
								<?php 
            _e('Your company/shop name for the Delivery Note.', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?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');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<label for="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
company_address"><?php 
            _e('Company/Shop Address', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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>
							<span class="description">
								<?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');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?php 
            _e('Leave blank to not print an address.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<label><?php 
            _e('Complimentary Close', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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>
							<span class="description">
								<?php 
            _e('Add some personal notes, or season greetings or whatever (e.g. Thank You for Your Order!, Merry Christmas!, etc.).', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?php 
            _e('Leave blank to not print any personal notes.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<label><?php 
            _e('Returns Policy, Conditions, etc', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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>
							<span class="description">
								<?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');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong> 
								<?php 
            _e('Leave blank to not print any policies or conditions.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<label for="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
footer_imprint"><?php 
            _e('Footer', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<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>
							<span class="description">
								<?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');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong> 
								<?php 
            _e('Leave blank to not print a footer.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<?php 
            _e('Types', 'woocommerce-delivery-notes');
            ?>
						</th>
						<td>
							<fieldset>
								<label>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_invoice" type="hidden" value="" />
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_invoice" type="checkbox" value="1" <?php 
            checked(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'template_type_invoice'), 1);
            ?>
 />
									<?php 
            _e('Enable Invoices', 'woocommerce-delivery-notes');
            ?>
								</label>
							</fieldset>
							<fieldset>
								<label>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_delivery_note" type="hidden" value="" />
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_delivery_note" type="checkbox" value="1" <?php 
            checked(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'template_type_delivery_note'), 1);
            ?>
 />
									<?php 
            _e('Enable Delivery Notes', 'woocommerce-delivery-notes');
            ?>
								</label>
							</fieldset>
							<fieldset>
								<label>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_receipt" type="hidden" value="" />
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
template_type_receipt" type="checkbox" value="1" <?php 
            checked(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'template_type_receipt'), 1);
            ?>
 />
									<?php 
            _e('Enable Receipts', 'woocommerce-delivery-notes');
            ?>
								</label>
							</fieldset>
						</td>
					</tr>
				</tbody>
			</table>

			<h3><?php 
            _e('Front-end Options', 'woocommerce-delivery-notes');
            ?>
</h3>
			<table class="form-table">
				<tbody>	
					<tr>
						<th>
							<label><?php 
            _e('Print Page Endpoint', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
								<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', 'print-order');
            ?>
" />
							</p>
							<span class="description">
								<?php 
            _e('The endpoint is appended to the accounts page URL to print the order. It should be unique.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr>
						<th>
							<?php 
            _e('Print Buttons', 'woocommerce-delivery-notes');
            ?>
						</th>
						<td>
							<fieldset>
								<label>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
print_button_on_view_order_page" type="hidden" value="" />
									<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);
            ?>
 />
									<?php 
            _e('Show print button on the "View Order" page', 'woocommerce-delivery-notes');
            ?>
								</label>
							</fieldset>
							<fieldset>
								<label>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
print_button_on_my_account_page" type="hidden" value="" />
									<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);
            ?>
 />
									<?php 
            _e('Show print buttons on the "My Account" page', 'woocommerce-delivery-notes');
            ?>
								</label>
							</fieldset>
						</td>
					</tr>
				</tbody>
			</table>
			
			<h3><?php 
            _e('Order Numbering', 'woocommerce-delivery-notes');
            ?>
</h3>
			<table class="form-table">
				<tbody>
					<tr>
						<th>
							<?php 
            _e('Invoice Number', 'woocommerce-delivery-notes');
            ?>
						</th>
						<td>
							<p>
								<label>
									<?php 
            $create_invoice_number = get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'create_invoice_number');
            ?>
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
create_invoice_number" type="hidden" value="" />
									<input name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
create_invoice_number" id="create-invoice-number" type="checkbox" value="1" <?php 
            checked($create_invoice_number, 1);
            ?>
 />
									<?php 
            _e('Create invoice numbers', 'woocommerce-delivery-notes');
            ?>
								</label>
							</p>
						</td>
					</tr>
					<tr class="invoice-number-row" <?php 
            if (empty($create_invoice_number)) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
						<th>
							<label><?php 
            _e('Invoice Number Start', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
								<input type="number" name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
invoice_number_start" value="<?php 
            echo stripslashes(wp_kses_stripslashes(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number_start', 1)));
            ?>
" />
							</p>
							<span class="description">
								<?php 
            _e('Start the numbering at the specified number.', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?php 
            _e('Use only integers.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr class="invoice-number-row" <?php 
            if (empty($create_invoice_number)) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
						<th>
							<label><?php 
            _e('Invoice Number Prefix', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
								<input type="text" name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
invoice_number_prefix" value="<?php 
            echo stripslashes(wp_kses_stripslashes(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number_prefix')));
            ?>
" />
							</p>
							<span class="description">
								<?php 
            _e('This text will be prepended to the invoice number.', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?php 
            _e('Leave blank to not add a prefix.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr class="invoice-number-row" <?php 
            if (empty($create_invoice_number)) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
						<th>
							<label><?php 
            _e('Invoice Number Suffix', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
								<input type="text" name="<?php 
            echo WooCommerce_Delivery_Notes::$plugin_prefix;
            ?>
invoice_number_suffix" value="<?php 
            echo stripslashes(wp_kses_stripslashes(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number_suffix')));
            ?>
" />
							</p>
							<span class="description">
								<?php 
            _e('This text will be appended to the invoice number.', 'woocommerce-delivery-notes');
            ?>
								<strong><?php 
            _e('Note:', 'woocommerce-delivery-notes');
            ?>
</strong>
								<?php 
            _e('Leave blank to not add a suffix.', 'woocommerce-delivery-notes');
            ?>
							</span>
						</td>
					</tr>
					<tr class="invoice-number-row" <?php 
            if (empty($create_invoice_number)) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
						<th>
							<label><?php 
            _e('Invoice Number Counter', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
								<?php 
            $invoice_start = intval(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number_start', 1));
            $invoice_counter = intval(get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number_counter', 0));
            ?>
								<span id="invoice-counter-value"><?php 
            echo $invoice_counter;
            ?>
</span>
								<a href="#" id="reset-invoice-counter" class="button"><?php 
            _e('Reset Counter', 'woocommerce-delivery-notes');
            ?>
</a>
							</p>
						</td>
					</tr>
					<tr>
						<th>
							<label><?php 
            _e('Sequential Order Number', 'woocommerce-delivery-notes');
            ?>
</label>
						</th>
						<td>
							<p>
							<?php 
            if ($this->is_woocommerce_sequential_order_numbers_activated()) {
                ?>
								<?php 
                _e('Sequential numbering is enabled.', 'woocommerce-delivery-notes');
                ?>
							<?php 
            } else {
                ?>
								<?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/');
                ?>
							<?php 
            }
            ?>
							</p>
						</td>
					</tr>
				</tbody>
			</table>
			
			<input type="hidden" name="<?php 
            echo $this->hidden_submit;
            ?>
" value="submitted">
			<?php 
        }
        /**
         * Create the meta box content on the single order page
         */
        public function create_box_content()
        {
            global $post_id, $wcdn;
            ?>
			<div class="print-actions">
				<?php 
            foreach (WooCommerce_Delivery_Notes_Print::$templates as $template) {
                ?>
					<?php 
                $option = get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'template_type_' . $template['type']);
                if ($option) {
                    ?>
					
						<a href="<?php 
                    echo wcdn_get_print_link($post_id, $template['type']);
                    ?>
" class="button print-preview-button <?php 
                    echo $template['type'];
                    ?>
" target="_blank" alt="<?php 
                    esc_attr_e(__($template['labels']['print'], 'woocommerce-delivery-notes'));
                    ?>
"><?php 
                    _e($template['labels']['print'], 'woocommerce-delivery-notes');
                    ?>
</a>
					
					<?php 
                }
                ?>
				<?php 
            }
            ?>
				<span class="print-preview-loading spinner"></span>
			</div>
			<?php 
            $create_invoice_number = get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'create_invoice_number');
            $has_invoice_number = get_post_meta($post_id, '_' . WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number', true);
            if (!empty($create_invoice_number) && $has_invoice_number) {
                $invoice_number = wcdn_get_order_invoice_number($post_id);
                $invoice_date = wcdn_get_order_invoice_date($post_id);
                ?>
				
				<ul class="print-info">
					<li><strong><?php 
                _e('Invoice number: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_number;
                ?>
</li>
					<li><strong><?php 
                _e('Invoice date: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_date;
                ?>
</li>
				</ul>
				
			<?php 
            }
            ?>
			<?php 
        }
        /**
         * Create the meta box content on the single order page
         */
        public function create_box_content()
        {
            global $post_id;
            ?>
			<div class="print-actions">
				<a href="<?php 
            echo wcdn_get_print_link($post_id, 'invoice');
            ?>
" class="button print-preview-button invoice" target="_blank" alt="<?php 
            esc_attr_e('Print Invoice', 'woocommerce-delivery-notes');
            ?>
"><?php 
            _e('Print Invoice', 'woocommerce-delivery-notes');
            ?>
</a>
				<a href="<?php 
            echo wcdn_get_print_link($post_id, 'delivery-note');
            ?>
" class="button print-preview-button delivery-note" target="_blank" alt="<?php 
            esc_attr_e('Print Delivery Note', 'woocommerce-delivery-notes');
            ?>
"><?php 
            _e('Print Delivery Note', 'woocommerce-delivery-notes');
            ?>
</a>
				<!-- <a href="<?php 
            echo wcdn_get_print_link($post_id, 'receipt');
            ?>
" class="button print-preview-button receipt" target="_blank" alt="<?php 
            esc_attr_e('Print Receipt', 'woocommerce-delivery-notes');
            ?>
"><?php 
            _e('Print Receipt', 'woocommerce-delivery-notes');
            ?>
</a> -->
				<span class="print-preview-loading spinner"></span>
			</div>
			<?php 
            $create_invoice_number = get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'create_invoice_number');
            $has_invoice_number = get_post_meta($post_id, '_' . WooCommerce_Delivery_Notes::$plugin_prefix . 'invoice_number', true);
            if (!empty($create_invoice_number) && $has_invoice_number) {
                $invoice_number = wcdn_get_order_invoice_number($post_id);
                $invoice_date = wcdn_get_order_invoice_date($post_id);
                ?>
				<ul class="print-info">
					<li><strong><?php 
                _e('Invoice number: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_number;
                ?>
</li>
					<li><strong><?php 
                _e('Invoice date: ', 'woocommerce-delivery-notes');
                ?>
</strong> <?php 
                echo $invoice_date;
                ?>
</li>
				</ul>
			<?php 
            }
            ?>
			<?php 
        }