function paid_amount() { global $invoice, $wpi_settings; $currency_symbol = !empty($wpi_settings['currency']['symbol'][$invoice['default_currency_code']]) ? $wpi_settings['currency']['symbol'][$invoice['default_currency_code']] : "\$"; echo $currency_symbol . wp_invoice_currency_format(!empty($invoice['total_payments']) ? $invoice['total_payments'] : 0); }
/** Formats it for the trial line */ function get_trial_line($product) { if (!$product->trial_interval) { return __('N/A', WPI); } else { return '$' . wp_invoice_currency_format($product->trial_price_in_cents / 100) . ' for ' . $product->trial_interval . ' ' . $product->trial_interval_unit . '(s)'; } }
<option><?php _e('-- Select Invoice --', WPI) ?></option> <?php foreach ($all_invoices as $invoice) { $invoice_id = wpi_post_id_to_invoice_id($invoice->ID); $invoice_obj = new WPI_Invoice(); $invoice_obj->load_invoice("id=".$invoice_id); //print_r( $invoice_obj ); if ( $invoice_obj->data['type'] != 'single_payment' ) : ?> <option value="<?php echo $invoice_id; ?>"> <?php if( $invoice_obj->data['type'] == 'recurring' ) { ?> <?php _e('[Recurring]', WPI) ?> <?php } ?> <?php echo $invoice_obj->data['post_title'] . " - " .$wpi_settings['currency']['symbol'][$invoice_obj->data['default_currency_code']] . wp_invoice_currency_format($invoice_obj->data['subtotal']); ?> <?php if ( !empty( $invoice_obj->data['total_discount'] ) && $invoice_obj->data['total_discount'] > 0 ) { echo " (".$wpi_settings['currency']['symbol'][$invoice_obj->data['default_currency_code']].$invoice_obj->data['total_discount']." of discount)"; } ?> </option> <?php endif; } ?> </select> <input type="submit" class="button" value="<?php esc_attr(_e('New Invoice from Template', WPI)) ?>"> <span id="wp_invoice_copy_invoice_cancel" class="wp_invoice_click_me">cancel</span> </div> <?php } ?> </td> </tr>
/** * Returns notification email based on pased values * * @global object $wpdb * @global array $wpi_settings */ function get_notification_email() { global $wpdb, $wpi_settings, $invoice; require_once WPI_Path.'/core/wpi_template_functions.php'; $template_id = intval($_REQUEST['template_id']); $invoice_id = intval($_REQUEST['wpi_invoiceid']); $invoice = get_invoice(wpi_invoice_id_to_post_id($invoice_id)); $currency_symbol = (!empty($wpi_settings['currency']['symbol'][$invoice['default_currency_code']]) ? $wpi_settings['currency']['symbol'][$invoice['default_currency_code']] : "$"); $invoice_id = (!empty($invoice['meta']['custom_id']) ? $invoice['meta']['custom_id'] : $invoice['invoice_id']); //** Get creator user data */ $creator = get_userdata( $invoice['post_author'] ); //** Due Date */ $due_date = get_due_date( $invoice ); $due_date = $due_date ? $due_date : __('Due date is not set', WPI); //** Load Templates */ $template_array = apply_filters('wpi_email_templates', $wpi_settings['notification']); $ary['NotificationContent'] = $template_array[$template_id]['content']; //** // Tags which can be used in Content of notification email //*/ //** Invoice ID */ $ary['NotificationContent'] = str_replace("%invoice_id%", $invoice_id, $ary['NotificationContent']); //** Format description */ $desc = (!empty($invoice['post_content']) ? strip_tags( $invoice['post_content'] ) : __("No description given.", WPI)); $ary['NotificationContent'] = str_replace("%description%", $desc, $ary['NotificationContent']); //** Recipient name */ $ary['NotificationContent'] = str_replace("%recipient%", recipients_name(array('return'=>true)), $ary['NotificationContent']); //** Invoice link */ $ary['NotificationContent'] = str_replace("%link%", get_invoice_permalink($invoice['invoice_id']), $ary['NotificationContent']); //** Invoice balance */ $ary['NotificationContent'] = str_replace("%amount%", $currency_symbol . wp_invoice_currency_format($invoice['net']), $ary['NotificationContent']); //** Invoice subject/title */ $ary['NotificationContent'] = str_replace("%subject%", $invoice['post_title'], $ary['NotificationContent']); //** Business name according to business settings */ $ary['NotificationContent'] = str_replace("%business_name%", $wpi_settings['business_name'], $ary['NotificationContent']); //** Business email according to business settings */ $ary['NotificationContent'] = str_replace("%business_email%", $wpi_settings['email_address'], $ary['NotificationContent']); //** Invoice creator name */ $ary['NotificationContent'] = str_replace("%creator_name%", $creator->display_name, $ary['NotificationContent']); //** Invoice creator email */ $ary['NotificationContent'] = str_replace("%creator_email%", $creator->user_email, $ary['NotificationContent']); //** Invoice Due Date */ $ary['NotificationContent'] = str_replace("%due_date%", $due_date, $ary['NotificationContent']); //** @todo: Recurring */ $ary['NotificationContent'] = str_replace("%recurring%", '', $ary['NotificationContent']); $ary['NotificationSubject'] = $template_array[$template_id]['subject']; //** // Tags which can be used in Subject of notification email //*/ //** Invoice ID */ $ary['NotificationSubject'] = str_replace("%invoice_id%",$invoice_id,$ary['NotificationSubject']); //** Recipients name */ $ary['NotificationSubject'] = str_replace("%recipient%",$invoice['user_data']['display_name'],$ary['NotificationSubject']); //** Invoice balance */ $ary['NotificationSubject'] = str_replace("%amount%",$invoice['net'],$ary['NotificationSubject']); //** Invoice subject/title */ $ary['NotificationSubject'] = str_replace("%subject%",$invoice['post_title'],$ary['NotificationSubject']); $aryJson = array(); //** Filter data before using. korotkov@ud */ $aryJson['wpi_content'] = apply_filters('wpi_notification_content', $ary['NotificationContent'], $invoice); $aryJson['wpi_subject'] = apply_filters('wpi_notification_subject', $ary['NotificationSubject'], $invoice); die(json_encode($aryJson)); }
/** * Collected column * * @param $post * @return string */ public function column_collected($post) { global $wpi_settings; $r = ''; $post = $this->get_invoice_object($post); if (!empty($post->subtotal)) { if ($post->type == 'single_payment') { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code]) ? $wpi_settings['currency']['symbol'][$post->default_currency_code] : '$') . wp_invoice_currency_format(!empty($post->total_payments) ? $post->total_payments : 0); } elseif ($post->type == 'recurring') { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code]) ? $wpi_settings['currency']['symbol'][$post->default_currency_code] : '$') . wp_invoice_currency_format(!empty($post->total_payments) ? $post->total_payments : 0); } else { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code]) ? $wpi_settings['currency']['symbol'][$post->default_currency_code] : '$') . wp_invoice_currency_format(!empty($post->adjustments) ? abs($post->adjustments) : 0) . " <span style='color:#aaaaaa;'>" . __('of', WPI) . " " . (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code]) ? $wpi_settings['currency']['symbol'][$post->default_currency_code] : '$') . wp_invoice_currency_format($post->subtotal - (!empty($post->total_discount) ? $post->total_discount : 0) + (!empty($post->total_tax) ? $post->total_tax : 0)) . "</span>"; } } else { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code]) ? $wpi_settings['currency']['symbol'][$post->default_currency_code] : '$') . wp_invoice_currency_format(0); } return $r; }
<div class="<?php echo apply_filters('wpi_spc::form_actions_class', 'form-actions', 'wpi_authorize'); ?> "> <?php $checkout_button_classes = implode(' ', apply_filters('wpi_spc::checkout_button_classes', array("btn", "btn-success", "wpi_checkout_process_payment", "wpi_authorize"))); ?> <input type="submit" class="wpi_checkout_submit_btn <?php echo $checkout_button_classes; ?> " value="<?php esc_attr(_e('Process Payment', WPI)); ?> " /> <span class="total_price">of <span class="wpi_checkout_final_price"><?php echo $wpi_settings['currency']['symbol'][$wpi_settings['currency']['default_currency_code']]; ?> <span class="wpi_price"><?php echo wp_invoice_currency_format((double) $total); ?> </span> <span class="wpi_fee_amount"></span> </span> </span> </div> <div class="<?php echo apply_filters('wpi_spc::response_box_class', 'wpi_checkout_payment_response hidden'); ?> "></div> </form>
/** * Generate HTML for a single row on the users.php admin panel. * */ function single_row( $object ) { global $wpi_settings, $post; $object = (array) $object; $post = new WPI_Invoice(); $post->load_invoice("id={$object['ID']}"); $post = (object)$post->data; $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); $edit_link = admin_url("admin.php?page=wpi_page_manage_invoice&wpi[existing_invoice][invoice_id]={$post->ID}"); $title = _draft_or_post_title($post->ID); $post_type_object = get_post_type_object( $post->post_type ); $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID ); $result = "<tr id='object-{$object['ID']}' class='wpi_parent_element'>"; list( $columns, $hidden ) = $this->get_column_info(); foreach ( $columns as $column => $column_display_name ) { $class = "class=\"$column column-$column\""; $style = ''; if ( in_array( $column, $hidden ) ) { $style = ' style="display:none;"'; } $attributes = "$class$style"; $result .= "<td {$attributes}>"; $r = ""; switch($column) { case 'cb': if ( $can_edit_post ) { $r .= '<input type="checkbox" name="post[]" value="'. get_the_ID() . '"/>'; } else { $r .= ' '; } break; case 'post_title': $attributes = 'class="post-title page-title column-title"' . $style; if ( $can_edit_post && $post->post_status != 'trash' && $post->post_status != 'archived' ) { $r .= '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”', WPI ), $title ) ) . '">' . $title . '</a>'; } else { $r .= $title; } $r .= (isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''); $actions = array(); if ( $can_edit_post && 'trash' != $post->post_status && 'archived' != $post->post_status ) { $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item', WPI ) ) . '">' . __( 'Edit', WPI ) . '</a>'; } if ( 'archived' == $post->post_status ) { $actions['unarchive'] = '<a href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=unarchive', $post->ID ) ), 'unarchive-' . $post->post_type . '_' . $post->ID ) . '" title="' . esc_attr( __( 'Un-Archive this item', WPI ) ) . '">' . __( 'Un-Archive', WPI ) . '</a>'; } else if ( 'trash' != $post->post_status && 'pending' != $post->post_status ) { $actions['archive'] = '<a href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=archive', $post->ID ) ), 'archive-' . $post->post_type . '_' . $post->ID ) . '" title="' . esc_attr( __( 'Archive this item', WPI ) ) . '">' . __( 'Archive', WPI ) . '</a>'; } if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) { if ( 'trash' == $post->post_status ) { $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash', WPI ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore', WPI ) . "</a>"; } elseif ( EMPTY_TRASH_DAYS && 'pending' != $post->post_status ) { $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash', WPI ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash', WPI ) . "</a>"; } if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) { $actions['delete'] = "<a class='submitdelete permanently' title='" . esc_attr( __( 'Delete this item permanently', WPI ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently', WPI ) . "</a>"; } } if ( 'trash' != $post->post_status && 'archived' != $post->post_status ) { $actions['view'] = '<a target="_blank" href="' . get_invoice_permalink( $post->invoice_id ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', WPI ), $title ) ) . '" rel="permalink">' . __( 'View', WPI ) . '</a>'; } $actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post ); $r .= $this->row_actions( $actions ); break; case 'post_modified': if ( !empty( $post->post_status ) ) { if ( $post->post_status == 'paid' ) { $r .= get_post_status_object($post->post_status)->label.' '.human_time_diff(strtotime($post->post_modified), (time() + get_option('gmt_offset')*60*60)).' ago'; } else { $r .= human_time_diff(strtotime($post->post_modified), (time() + get_option('gmt_offset')*60*60)).' ago'; } } else { $r .= date(get_option('date_format'), strtotime($post->post_date)); } break; case 'invoice_id': $invoice_id = $post->{$column}; /* If custom_id exists we use it as invoice_id */ if(!empty($post->custom_id)) { $invoice_id = $post->custom_id; } $r .= '<a href="' . get_invoice_permalink($post->{$column}) . '" target="_blank">'.apply_filters("wpi_attribute_{$column}", $invoice_id ,$post).'</a>'; break; case 'post_status': $r .= get_post_status_object($post->post_status)->label; break; case 'user_email': //** Get User Edit Link */ if(class_exists('WP_CRM_Core')) { $edit_user_url = admin_url("admin.php?page=wp_crm_add_new&user_id={$post->user_data['ID']}"); } else { $edit_user_url = admin_url("user-edit.php?user_id={$post->user_data['ID']}"); } $r .= '<ul>'; $r .= '<li><a href="'.$edit_user_url.'">' . $post->user_data['display_name'] . '</a></li>'; $r .= '<li>' . $post->user_data['user_email'] . '</li>'; $r .= '</ul>'; break; case 'type': $r .= $wpi_settings['types'][$post->type]['label']; break; case 'total': if ( !empty( $post->subtotal ) ) { if ( $post->type != 'single_payment' ) { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code])?$wpi_settings['currency']['symbol'][$post->default_currency_code]:'$') . wp_invoice_currency_format( !empty( $post->total_payments )?$post->total_payments:0 ) ." <span style='color:#aaaaaa;'>" . __('of', WPI) ." ". (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code])?$wpi_settings['currency']['symbol'][$post->default_currency_code]:'$') . wp_invoice_currency_format($post->subtotal-(!empty($post->total_discount)?$post->total_discount:0)+(!empty($post->total_tax)?$post->total_tax:0)) ."</span>"; } else { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code])?$wpi_settings['currency']['symbol'][$post->default_currency_code]:'$') . wp_invoice_currency_format( !empty( $post->total_payments )?$post->total_payments:0 ); } } else { $r .= (!empty($wpi_settings['currency']['symbol'][$post->default_currency_code])?$wpi_settings['currency']['symbol'][$post->default_currency_code]:'$') . wp_invoice_currency_format(0); } break; default: $r .= apply_filters("wpi_attribute_{$column}", $post->{$column}, $post); break; } //** Need to insert some sort of space in there to avoid DataTable error that occures when "null" is returned */ $ajax_cells[] = $r; $result .= $r; $result .= "</td>"; } $result .= '</tr>'; if($this->_args['ajax']) { return $ajax_cells; } return $result; }