/**
  * Ouput custom columns for products
  *
  * @param   string $column
  * @version 2.3.0
  */
 public function render_order_columns($column)
 {
     $invoice_types_ids = wcj_get_enabled_invoice_types_ids();
     if (!in_array($column, $invoice_types_ids)) {
         return;
     }
     $order_id = get_the_ID();
     $invoice_type_id = $column;
     $html = '';
     if (wcj_is_invoice_created($order_id, $invoice_type_id)) {
         $the_invoice = wcj_get_invoice($order_id, $invoice_type_id);
         $the_number = $the_invoice->get_invoice_number();
         //			$the_url     = $the_invoice->get_invoice_url();
         //			$the_link    = $the_invoice->get_invoice_link();
         //$html .= ' ';
         $query_args = array('order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1');
         if ('yes' === get_option('wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no')) {
             $query_args['save_pdf_invoice'] = '1';
         }
         $html .= '<a href="' . add_query_arg($query_args) . '">' . $the_number . '</a>';
         $html .= ' ';
         $html .= '<a href="';
         $html .= add_query_arg(array('delete_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id), remove_query_arg('create_invoice_for_order_id'));
         $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . __('Delete', 'woocommerce-jetpack') . '</span></a>';
         //$html .= '">' . '<img src="http://icons.iconarchive.com/icons/double-j-design/origami-colored-pencil/16/red-cross-icon.png">' . '</a>';
     } else {
         $html .= '<a href="';
         $html .= add_query_arg(array('create_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id), remove_query_arg('delete_invoice_for_order_id'));
         $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . __('Create', 'woocommerce-jetpack') . '</span></a>';
         //$html .= '">' . '<img src="http://icons.iconarchive.com/icons/double-j-design/origami-colored-pencil/16/blue-plus-icon.png">' . '</a>';
     }
     echo $html;
 }
 /**
  * add_pdf_invoice_email_attachment.
  */
 function add_pdf_invoice_email_attachment($attachments, $status, $order)
 {
     $invoice_types_ids = wcj_get_enabled_invoice_types_ids();
     foreach ($invoice_types_ids as $invoice_type_id) {
         if (false === $this->do_attach_for_payment_method($invoice_type_id, $order->payment_method)) {
             continue;
         }
         $send_on_statuses = get_option('wcj_invoicing_' . $invoice_type_id . '_attach_to_emails', array());
         if ('' == $send_on_statuses) {
             $send_on_statuses = array();
         }
         if (in_array($status, $send_on_statuses)) {
             $the_invoice = wcj_get_pdf_invoice($order->id, $invoice_type_id);
             $file_name = $the_invoice->get_pdf('F');
             if ('' != $file_name) {
                 $attachments[] = $file_name;
             }
         }
     }
     return $attachments;
 }
 /**
 * do_attach_for_payment_method.
 *
 	function do_attach_for_payment_method( $payment_method ) {
 		return ( 'no' === get_option( 'wcj_gateways_attach_invoice_' . $payment_method, 'yes' ) ) ? false : true;
 	}
 
 	/**
 * add_pdf_invoice_email_attachment.
 */
 function add_pdf_invoice_email_attachment($attachments, $status, $order)
 {
     $invoice_types_ids = wcj_get_enabled_invoice_types_ids();
     foreach ($invoice_types_ids as $invoice_type_id) {
         //if ( 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( 'wcj_invoicing_' . $invoice_type_id . '_attach_to_email_enabled' ) ) ) {
         //if ( isset( $status ) && 'customer_completed_order' === $status && isset( $order ) && true === $this->do_attach_for_payment_method( $order->payment_method ) ) {
         //if ( 'customer_completed_order' === $status ) {
         $send_on_statuses = get_option('wcj_invoicing_' . $invoice_type_id . '_attach_to_emails', array());
         if ('' == $send_on_statuses) {
             $send_on_statuses = array();
         }
         if (in_array($status, $send_on_statuses)) {
             $the_invoice = wcj_get_pdf_invoice($order->id, $invoice_type_id);
             $file_name = $the_invoice->get_pdf('F');
             if ('' != $file_name) {
                 $attachments[] = $file_name;
             }
         }
     }
     return $attachments;
 }
 /**
  * Ouput custom columns for products
  * @param  string $column
  */
 public function render_order_columns($column)
 {
     $invoice_types_ids = wcj_get_enabled_invoice_types_ids();
     if (!in_array($column, $invoice_types_ids)) {
         return;
     }
     $order_id = get_the_ID();
     $invoice_type_id = $column;
     if (!wcj_is_invoice_created($order_id, $invoice_type_id)) {
         return;
     }
     $the_invoice = wcj_get_invoice($order_id, $invoice_type_id);
     $the_number = $the_invoice->get_invoice_number();
     //$the_url = $the_invoice->get_invoice_url();
     //$the_link = $the_invoice->get_invoice_link();
     $query_args = array('order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1');
     if ('yes' === get_option('wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no')) {
         $query_args['save_pdf_invoice'] = '1';
     }
     $the_link = '<a href="' . add_query_arg($query_args) . '">' . $the_number . '</a>';
     echo $the_link;
 }
 /**
  * Ouput custom columns for products
  *
  * @param   string $column
  * @version 2.3.10
  */
 public function render_order_columns($column)
 {
     $invoice_types_ids = wcj_get_enabled_invoice_types_ids();
     if (!in_array($column, $invoice_types_ids)) {
         return;
     }
     $order_id = get_the_ID();
     $invoice_type_id = $column;
     $html = '';
     if (wcj_is_invoice_created($order_id, $invoice_type_id)) {
         $the_invoice = wcj_get_invoice($order_id, $invoice_type_id);
         $the_number = $the_invoice->get_invoice_number();
         // Document Link
         $query_args = array('order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1');
         if ('yes' === get_option('wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no')) {
             $query_args['save_pdf_invoice'] = '1';
         }
         $html .= '<a href="' . add_query_arg($query_args, remove_query_arg(array('create_invoice_for_order_id', 'delete_invoice_for_order_id'))) . '">' . $the_number . '</a>';
         // Delete button
         $delete_button_label = get_option('wcj_invoicing_' . $invoice_type_id . '_admin_column_delete_btn', __('Delete', 'woocommerce-jetpack'));
         if ('' != $delete_button_label) {
             $html .= ' ';
             $html .= '<a href="';
             $html .= add_query_arg(array('delete_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id), remove_query_arg('create_invoice_for_order_id'));
             $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . $delete_button_label . '</span></a>';
         }
     } else {
         // Create Button
         $create_button_label = get_option('wcj_invoicing_' . $invoice_type_id . '_admin_column_create_btn', __('Create', 'woocommerce-jetpack'));
         if ('' != $create_button_label) {
             $html .= '<a href="';
             $html .= add_query_arg(array('create_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id), remove_query_arg('delete_invoice_for_order_id'));
             $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . $create_button_label . '</span></a>';
         }
     }
     echo $html;
 }