|
@@ -1,4 +1,4 @@ discard block |
|
|
block discarded – undo |
|
1
|
|
-<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
|
1
|
+<?php if (!defined('ABSPATH')) exit; |
|
2
|
2
|
/** |
|
3
|
3
|
* Billing module bootstrap file |
|
4
|
4
|
* |
|
@@ -9,7 +9,7 @@ discard block |
|
|
block discarded – undo |
|
9
|
9
|
*/ |
|
10
|
10
|
|
|
11
|
11
|
/** Check if billing class does not exist before creating the class */ |
|
12
|
|
-if ( !class_exists("wpshop_modules_billing") ) { |
|
|
12
|
+if (!class_exists("wpshop_modules_billing")) { |
|
13
|
13
|
/** |
|
14
|
14
|
* Billing module utilities definition |
|
15
|
15
|
* |
|
@@ -24,15 +24,15 @@ discard block |
|
|
block discarded – undo |
|
24
|
24
|
*/ |
|
25
|
25
|
function __construct() { |
|
26
|
26
|
/** Add custom template for current module */ |
|
27
|
|
- add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) ); |
|
|
27
|
+ add_filter('wpshop_custom_template', array(&$this, 'custom_template_load')); |
|
28
|
28
|
|
|
29
|
29
|
/** In case wpshop is set on sale mode and not on view catalog only, Ad billign options */ |
|
30
|
|
- if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) { |
|
31
|
|
- $wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
|
32
|
|
- $old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
|
|
30
|
+ if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') { |
|
|
31
|
+ $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
|
32
|
+ $old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : ''; |
|
33
|
33
|
|
|
34
|
|
- if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' ) |
|
35
|
|
- && ( $old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation' ) ) { |
|
|
34
|
+ if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation') |
|
|
35
|
+ && ($old_wpshop_shop_type == '' || $old_wpshop_shop_type != 'presentation')) { |
|
36
|
36
|
/** Add module option to wpshop general options */ |
|
37
|
37
|
add_filter('wpshop_options', array(&$this, 'add_options'), 9); |
|
38
|
38
|
add_action('wsphop_options', array(&$this, 'declare_options'), 8); |
|
@@ -40,7 +40,7 @@ discard block |
|
|
block discarded – undo |
|
40
|
40
|
} |
|
41
|
41
|
|
|
42
|
42
|
// Filter |
|
43
|
|
- add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'force_invoice_generation_on_order'), 50, 2 ); |
|
|
43
|
+ add_filter('wps_order_saving_admin_extra_action', array($this, 'force_invoice_generation_on_order'), 50, 2); |
|
44
|
44
|
} |
|
45
|
45
|
|
|
46
|
46
|
/** |
|
@@ -50,17 +50,17 @@ discard block |
|
|
block discarded – undo |
|
50
|
50
|
* |
|
51
|
51
|
* @return array The template with new elements |
|
52
|
52
|
*/ |
|
53
|
|
- function custom_template_load( $templates ) { |
|
|
53
|
+ function custom_template_load($templates) { |
|
54
|
54
|
include('templates/common/main_elements.tpl.php'); |
|
55
|
55
|
$wpshop_template = $tpl_element; |
|
56
|
56
|
/* Get custom frontend template */ |
|
57
|
|
- if ( is_file(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php') ) { |
|
|
57
|
+ if (is_file(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php')) { |
|
58
|
58
|
require_once(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php'); |
|
59
|
59
|
if (!empty($tpl_element)) |
|
60
|
|
- $wpshop_template['common']['custom'] = ($tpl_element);unset($tpl_element); |
|
|
60
|
+ $wpshop_template['common']['custom'] = ($tpl_element); unset($tpl_element); |
|
61
|
61
|
} |
|
62
|
62
|
$wpshop_display = new wpshop_display(); |
|
63
|
|
- $templates = $wpshop_display->add_modules_template_to_internal( $wpshop_template, $templates ); |
|
|
63
|
+ $templates = $wpshop_display->add_modules_template_to_internal($wpshop_template, $templates); |
|
64
|
64
|
|
|
65
|
65
|
unset($tpl_element); |
|
66
|
66
|
|
|
@@ -70,9 +70,9 @@ discard block |
|
|
block discarded – undo |
|
70
|
70
|
/** |
|
71
|
71
|
* Declare option groups for the module |
|
72
|
72
|
*/ |
|
73
|
|
- function add_options( $option_group ) { |
|
|
73
|
+ function add_options($option_group) { |
|
74
|
74
|
$option_group['wpshop_billing_info'] = |
|
75
|
|
- array( 'label' => __('Billing', 'wpshop'), |
|
|
75
|
+ array('label' => __('Billing', 'wpshop'), |
|
76
|
76
|
'subgroups' => array( |
|
77
|
77
|
'wpshop_billing_info' => array('class' => ' wpshop_admin_box_options_billing'), |
|
78
|
78
|
), |
|
@@ -85,7 +85,7 @@ discard block |
|
|
block discarded – undo |
|
85
|
85
|
* Declare the different options in groups for the module |
|
86
|
86
|
*/ |
|
87
|
87
|
function declare_options() { |
|
88
|
|
- add_settings_section('wpshop_billing_info','<span class="dashicons dashicons-admin-generic"></span>'. __('Billing settings', 'wpshop'), array(&$this, 'billing_options_main_explanation'), 'wpshop_billing_info'); |
|
|
88
|
+ add_settings_section('wpshop_billing_info', '<span class="dashicons dashicons-admin-generic"></span>' . __('Billing settings', 'wpshop'), array(&$this, 'billing_options_main_explanation'), 'wpshop_billing_info'); |
|
89
|
89
|
|
|
90
|
90
|
register_setting('wpshop_options', 'wpshop_billing_number_figures', array(&$this, 'wpshop_options_validate_billing_number_figures')); |
|
91
|
91
|
add_settings_field('wpshop_billing_number_figures', __('Number of figures', 'wpshop'), array(&$this, 'wpshop_billing_number_figures_field'), 'wpshop_billing_info', 'wpshop_billing_info'); |
|
@@ -94,30 +94,30 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
add_settings_field('wpshop_billing_address_choice', __('Billing address choice', 'wpshop'), array(&$this, 'wpshop_billing_address_choice_field'), 'wpshop_billing_info', 'wpshop_billing_info'); |
|
95
|
95
|
add_settings_field('wpshop_billing_address_include_into_register', '', array(&$this, 'wpshop_billing_address_include_into_register_field'), 'wpshop_billing_info', 'wpshop_billing_info'); |
|
96
|
96
|
|
|
97
|
|
- $quotation_option = get_option( 'wpshop_addons' ); |
|
98
|
|
- if ( !empty($quotation_option) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']['activate']) ) { |
|
99
|
|
- add_settings_section('wpshop_quotation_info', '<span class="dashicons dashicons-clipboard"></span>' .__('Quotation settings', 'wpshop'), array(&$this, 'quotation_options_main_explanation'), 'wpshop_billing_info'); |
|
|
97
|
+ $quotation_option = get_option('wpshop_addons'); |
|
|
98
|
+ if (!empty($quotation_option) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']['activate'])) { |
|
|
99
|
+ add_settings_section('wpshop_quotation_info', '<span class="dashicons dashicons-clipboard"></span>' . __('Quotation settings', 'wpshop'), array(&$this, 'quotation_options_main_explanation'), 'wpshop_billing_info'); |
|
100
|
100
|
|
|
101
|
101
|
register_setting('wpshop_options', 'wpshop_quotation_validate_time', array(&$this, 'wpshop_options_validate_quotation_validate_time')); |
|
102
|
102
|
add_settings_field('wpshop_quotation_validate_time', __('Quotation validate time', 'wpshop'), array(&$this, 'wpshop_quotation_validate_time_field'), 'wpshop_billing_info', 'wpshop_quotation_info'); |
|
103
|
103
|
$payment_option = get_option('wps_payment_mode'); |
|
104
|
|
- if ( !empty($payment_option) && !empty($payment_option['mode']) && !empty($payment_option['mode']['banktransfer']) && !empty($payment_option['mode']['banktransfer']['active']) ) { |
|
|
104
|
+ if (!empty($payment_option) && !empty($payment_option['mode']) && !empty($payment_option['mode']['banktransfer']) && !empty($payment_option['mode']['banktransfer']['active'])) { |
|
105
|
105
|
register_setting('wpshop_options', 'wpshop_paymentMethod_options[banktransfer][add_in_quotation]', array(&$this, 'wpshop_options_validate_wpshop_bic_to_quotation')); |
|
106
|
106
|
add_settings_field('wpshop_paymentMethod_options[banktransfer][add_in_quotation]', __('Add your BIC to your quotations', 'wpshop'), array(&$this, 'wpshop_bic_to_quotation_field'), 'wpshop_billing_info', 'wpshop_quotation_info'); |
|
107
|
107
|
} |
|
108
|
108
|
register_setting('wpshop_options', 'wpshop_payment_partial', array(&$this, 'wpshop_quotation_payment_partial_validation')); |
|
109
|
|
- add_settings_field('wpshop_payment_partial', __( 'Quotation partial payment'), array(&$this, 'wpshop_quotation_payment_partial'), 'wpshop_billing_info', 'wpshop_quotation_info'); |
|
|
109
|
+ add_settings_field('wpshop_payment_partial', __('Quotation partial payment'), array(&$this, 'wpshop_quotation_payment_partial'), 'wpshop_billing_info', 'wpshop_quotation_info'); |
|
110
|
110
|
} |
|
111
|
111
|
|
|
112
|
112
|
} |
|
113
|
113
|
|
|
114
|
|
- function wpshop_options_validate_wpshop_bic_to_quotation ($input) { |
|
|
114
|
+ function wpshop_options_validate_wpshop_bic_to_quotation($input) { |
|
115
|
115
|
return $input; |
|
116
|
116
|
} |
|
117
|
117
|
|
|
118
|
|
- function wpshop_bic_to_quotation_field () { |
|
|
118
|
+ function wpshop_bic_to_quotation_field() { |
|
119
|
119
|
$add_quotation_option = get_option('wpshop_paymentMethod_options'); |
|
120
|
|
- $output = '<input type="checkbox" name="wpshop_paymentMethod_options[banktransfer][add_in_quotation]" id="wpshop_paymentMethod_options[banktransfer][add_in_quotation]" ' .( ( !empty($add_quotation_option) && !empty($add_quotation_option['banktransfer']) && !empty($add_quotation_option['banktransfer']['add_in_quotation']) ) ? 'checked="checked"' : ''). ' />'; |
|
|
120
|
+ $output = '<input type="checkbox" name="wpshop_paymentMethod_options[banktransfer][add_in_quotation]" id="wpshop_paymentMethod_options[banktransfer][add_in_quotation]" ' . ((!empty($add_quotation_option) && !empty($add_quotation_option['banktransfer']) && !empty($add_quotation_option['banktransfer']['add_in_quotation'])) ? 'checked="checked"' : '') . ' />'; |
|
121
|
121
|
echo $output; |
|
122
|
122
|
} |
|
123
|
123
|
|
|
@@ -128,44 +128,44 @@ discard block |
|
|
block discarded – undo |
|
128
|
128
|
|
|
129
|
129
|
} |
|
130
|
130
|
|
|
131
|
|
- function wpshop_options_validate_quotation_validate_time ($input) { |
|
|
131
|
+ function wpshop_options_validate_quotation_validate_time($input) { |
|
132
|
132
|
return $input; |
|
133
|
133
|
} |
|
134
|
134
|
|
|
135
|
135
|
function wpshop_billing_number_figures_field() { |
|
136
|
136
|
$wpshop_billing_number_figures = get_option('wpshop_billing_number_figures'); |
|
137
|
|
- $readonly = !empty($wpshop_billing_number_figures) ? 'readonly="readonly"': null; |
|
138
|
|
- if(empty($wpshop_billing_number_figures)) $wpshop_billing_number_figures=5; |
|
|
137
|
+ $readonly = !empty($wpshop_billing_number_figures) ? 'readonly="readonly"' : null; |
|
|
138
|
+ if (empty($wpshop_billing_number_figures)) $wpshop_billing_number_figures = 5; |
|
139
|
139
|
|
|
140
|
|
- echo '<input name="wpshop_billing_number_figures" type="text" value="'.$wpshop_billing_number_figures.'" '.$readonly.' /> |
|
141
|
|
- <a href="#" title="'.__('Number of figures to make appear on invoices','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
|
140
|
+ echo '<input name="wpshop_billing_number_figures" type="text" value="' . $wpshop_billing_number_figures . '" ' . $readonly . ' /> |
|
|
141
|
+ <a href="#" title="'.__('Number of figures to make appear on invoices', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
142
|
142
|
} |
|
143
|
143
|
|
|
144
|
|
- function wpshop_options_validate_billing_number_figures( $input ) { |
|
|
144
|
+ function wpshop_options_validate_billing_number_figures($input) { |
|
145
|
145
|
return $input; |
|
146
|
146
|
} |
|
147
|
147
|
|
|
148
|
|
- function wpshop_billing_address_validator( $input ){ |
|
|
148
|
+ function wpshop_billing_address_validator($input) { |
|
149
|
149
|
global $wpdb; |
|
150
|
|
- $t = wps_address::get_addresss_form_fields_by_type ( $input['choice'] ); |
|
|
150
|
+ $t = wps_address::get_addresss_form_fields_by_type($input['choice']); |
|
151
|
151
|
|
|
152
|
152
|
$the_code = ''; |
|
153
|
|
- foreach( $t[$input['choice']] as $group_id => $group_def ) { |
|
154
|
|
- if ( !empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && array_key_exists( $input['integrate_into_register_form_matching_field']['user_email'], $group_def['content']) ) { |
|
|
153
|
+ foreach ($t[$input['choice']] as $group_id => $group_def) { |
|
|
154
|
+ if (!empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && array_key_exists($input['integrate_into_register_form_matching_field']['user_email'], $group_def['content'])) { |
|
155
|
155
|
$the_code = $group_def['content'][$input['integrate_into_register_form_matching_field']['user_email']]['name']; |
|
156
|
156
|
continue; |
|
157
|
157
|
} |
|
158
|
158
|
} |
|
159
|
159
|
$the_code; |
|
160
|
160
|
|
|
161
|
|
- if ( !empty($input['integrate_into_register_form']) && $input['integrate_into_register_form'] == 'yes' ) { |
|
162
|
|
- if ( !empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && $the_code == 'address_user_email') { |
|
|
161
|
+ if (!empty($input['integrate_into_register_form']) && $input['integrate_into_register_form'] == 'yes') { |
|
|
162
|
+ if (!empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && $the_code == 'address_user_email') { |
|
163
|
163
|
$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('_need_verification' => 'no'), array('code' => $the_code)); |
|
164
|
164
|
} |
|
165
|
165
|
} |
|
166
|
166
|
|
|
167
|
|
- $billing_option = get_option( 'wpshop_billing_address' ); |
|
168
|
|
- if( !empty($billing_option) && !empty( $billing_option['display_model'] ) ) { |
|
|
167
|
+ $billing_option = get_option('wpshop_billing_address'); |
|
|
168
|
+ if (!empty($billing_option) && !empty($billing_option['display_model'])) { |
|
169
|
169
|
$input['display_model'] = $billing_option['display_model']; |
|
170
|
170
|
} |
|
171
|
171
|
|
|
@@ -178,10 +178,10 @@ discard block |
|
|
block discarded – undo |
|
178
|
178
|
|
|
179
|
179
|
$wpshop_billing_address = get_option('wpshop_billing_address'); |
|
180
|
180
|
|
|
181
|
|
- $query = $wpdb->prepare('SELECT ID FROM ' .$wpdb->posts. ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES); |
|
|
181
|
+ $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES); |
|
182
|
182
|
$entity_id = $wpdb->get_var($query); |
|
183
|
183
|
|
|
184
|
|
- $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id); |
|
|
184
|
+ $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
185
|
185
|
$content = $wpdb->get_results($query); |
|
186
|
186
|
|
|
187
|
187
|
/* Field for billing address type choice */ |
|
@@ -190,21 +190,21 @@ discard block |
|
|
block discarded – undo |
|
190
|
190
|
$input_def['possible_value'] = $content; |
|
191
|
191
|
$input_def['type'] = 'select'; |
|
192
|
192
|
$input_def['value'] = $wpshop_billing_address['choice']; |
|
193
|
|
- $output .= '<div>' .wpshop_form::check_input_type($input_def). '</div>'; |
|
|
193
|
+ $output .= '<div>' . wpshop_form::check_input_type($input_def) . '</div>'; |
|
194
|
194
|
|
|
195
|
195
|
/* Field for integrate billign form into register form */ |
|
196
|
196
|
$input_def = array(); |
|
197
|
197
|
$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form]'; |
|
198
|
198
|
$input_def['id'] = 'wpshop_billing_address_integrate_into_register_form'; |
|
199
|
|
- $input_def['possible_value'] = array( 'yes' => __('Integrate billing form into register form', 'wpshop') ); |
|
|
199
|
+ $input_def['possible_value'] = array('yes' => __('Integrate billing form into register form', 'wpshop')); |
|
200
|
200
|
$input_def['valueToPut'] = 'index'; |
|
201
|
201
|
$input_def['options_label']['original'] = true; |
|
202
|
202
|
$input_def['option'] = ' class="wpshop_billing_address_integrate_into_register_form" '; |
|
203
|
203
|
$input_def['type'] = 'checkbox'; |
|
204
|
|
- $input_def['value'] = array( !empty($wpshop_billing_address['integrate_into_register_form']) ? $wpshop_billing_address['integrate_into_register_form'] : '' ); |
|
|
204
|
+ $input_def['value'] = array(!empty($wpshop_billing_address['integrate_into_register_form']) ? $wpshop_billing_address['integrate_into_register_form'] : ''); |
|
205
|
205
|
$output .= ' |
|
206
|
206
|
<div class="wpshop_include_billing_form_into_register_container" > |
|
207
|
|
- ' .wpshop_form::check_input_type($input_def). ' |
|
|
207
|
+ ' .wpshop_form::check_input_type($input_def) . ' |
|
208
|
208
|
<input type="hidden" name="wpshop_ajax_integrate_billin_into_register" id="wpshop_ajax_integrate_billin_into_register" value="' . wp_create_nonce('wpshop_ajax_integrate_billin_into_register') . '" /> |
|
209
|
209
|
<input type="hidden" name="wpshop_include_billing_form_into_register_where_value" id="wpshop_include_billing_form_into_register_where_value" value="' . (!empty($wpshop_billing_address['integrate_into_register_form_after_field']) ? $wpshop_billing_address['integrate_into_register_form_after_field'] : '') . '" /> |
|
210
|
210
|
<div class="wpshop_include_billing_form_into_register_where" ></div> |
|
@@ -217,13 +217,13 @@ discard block |
|
|
block discarded – undo |
|
217
|
217
|
|
|
218
|
218
|
} |
|
219
|
219
|
|
|
220
|
|
- function wpshop_quotation_validate_time_field () { |
|
|
220
|
+ function wpshop_quotation_validate_time_field() { |
|
221
|
221
|
$quotation_option = get_option('wpshop_quotation_validate_time'); |
|
222
|
|
- $output = '<input type="text" name="wpshop_quotation_validate_time[number]" id="wpshop_quotation_validate_time[number]" style="width:50px;" value="' .( ( !empty($quotation_option) && !empty($quotation_option['number']) ) ? $quotation_option['number'] : null ). '" />'; |
|
|
222
|
+ $output = '<input type="text" name="wpshop_quotation_validate_time[number]" id="wpshop_quotation_validate_time[number]" style="width:50px;" value="' . ((!empty($quotation_option) && !empty($quotation_option['number'])) ? $quotation_option['number'] : null) . '" />'; |
|
223
|
223
|
$output .= '<select name="wpshop_quotation_validate_time[time_type]" id="wpshop_quotation_validate_time[time_type]">'; |
|
224
|
|
- $output .= '<option value="day" ' .( ( !empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'day') ? 'selected="selected"' : ''). '>' .__('Days', 'wpshop'). '</option>'; |
|
225
|
|
- $output .= '<option value="month" ' .( ( !empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'month') ? 'selected="selected"' : ''). '>' .__('Months', 'wpshop'). '</option>'; |
|
226
|
|
- $output .= '<option value="year" ' .( ( !empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'year') ? 'selected="selected"' : ''). '>' .__('Years', 'wpshop'). '</option>'; |
|
|
224
|
+ $output .= '<option value="day" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'day') ? 'selected="selected"' : '') . '>' . __('Days', 'wpshop') . '</option>'; |
|
|
225
|
+ $output .= '<option value="month" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'month') ? 'selected="selected"' : '') . '>' . __('Months', 'wpshop') . '</option>'; |
|
|
226
|
+ $output .= '<option value="year" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'year') ? 'selected="selected"' : '') . '>' . __('Years', 'wpshop') . '</option>'; |
|
227
|
227
|
$output .= '</select>'; |
|
228
|
228
|
|
|
229
|
229
|
echo $output; |
|
@@ -236,19 +236,19 @@ discard block |
|
|
block discarded – undo |
|
236
|
236
|
* |
|
237
|
237
|
* @return string The new invoice number |
|
238
|
238
|
*/ |
|
239
|
|
- public static function generate_invoice_number( $order_id ) { |
|
|
239
|
+ public static function generate_invoice_number($order_id) { |
|
240
|
240
|
/** Get configuration about the number of figure dor invoice number */ |
|
241
|
241
|
|
|
242
|
242
|
$number_figures = get_option('wpshop_billing_number_figures', false); |
|
243
|
243
|
|
|
244
|
244
|
/** If the number doesn't exist, we create a default one */ |
|
245
|
|
- if(!$number_figures) { |
|
|
245
|
+ if (!$number_figures) { |
|
246
|
246
|
update_option('wpshop_billing_number_figures', 5); |
|
247
|
247
|
} |
|
248
|
248
|
|
|
249
|
249
|
/** sleep my script, SLEEP I SAY ! **/ |
|
250
|
|
- $rand_time = rand( 1000, 200000 ); |
|
251
|
|
- usleep( $rand_time ); |
|
|
250
|
+ $rand_time = rand(1000, 200000); |
|
|
251
|
+ usleep($rand_time); |
|
252
|
252
|
/** GET UP !! **/ |
|
253
|
253
|
|
|
254
|
254
|
/** Get last invoice number */ |
|
@@ -264,14 +264,14 @@ discard block |
|
|
block discarded – undo |
|
264
|
264
|
|
|
265
|
265
|
/** Check if number exists **/ |
|
266
|
266
|
$billing_current_number_checking = get_option('wpshop_billing_current_number', false); |
|
267
|
|
- if ( $billing_current_number_checking == $billing_current_number ) { |
|
|
267
|
+ if ($billing_current_number_checking == $billing_current_number) { |
|
268
|
268
|
$billing_current_number++; |
|
269
|
269
|
} |
|
270
|
270
|
|
|
271
|
271
|
update_option('wpshop_billing_current_number', $billing_current_number); |
|
272
|
272
|
|
|
273
|
273
|
/** Create the new invoice number with all parameters viewed above */ |
|
274
|
|
- $invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string)sprintf('%0'.$number_figures.'d', $billing_current_number)); |
|
|
274
|
+ $invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string)sprintf('%0' . $number_figures . 'd', $billing_current_number)); |
|
275
|
275
|
|
|
276
|
276
|
return $invoice_ref; |
|
277
|
277
|
} |
|
@@ -285,67 +285,67 @@ discard block |
|
|
block discarded – undo |
|
285
|
285
|
* |
|
286
|
286
|
* @return string The invoice output in case no error is found. The error in other case |
|
287
|
287
|
*/ |
|
288
|
|
- public static function generate_html_invoice( $order_id, $invoice_ref ) { |
|
|
288
|
+ public static function generate_html_invoice($order_id, $invoice_ref) { |
|
289
|
289
|
global $wpdb; |
|
290
|
290
|
|
|
291
|
|
- $date_output_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); |
|
|
291
|
+ $date_output_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
292
|
292
|
$count_products = 0; |
|
293
|
293
|
|
|
294
|
|
- if ( !empty($order_id) ) { |
|
|
294
|
+ if (!empty($order_id)) { |
|
295
|
295
|
$order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
296
|
296
|
|
|
297
|
297
|
$discounts_exists = false; |
|
298
|
298
|
|
|
299
|
|
- $is_quotation = ( empty($order_postmeta['order_key']) && !empty($order_postmeta['order_temporary_key']) && $invoice_ref == null ) ? true : false; |
|
|
299
|
+ $is_quotation = (empty($order_postmeta['order_key']) && !empty($order_postmeta['order_temporary_key']) && $invoice_ref == null) ? true : false; |
|
300
|
300
|
/** Check if it's a partial payment bill **/ |
|
301
|
301
|
$is_partial_payment = false; |
|
302
|
|
- if( isset( $order_postmeta['order_payment']['received'] ) && !empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid' ) { |
|
303
|
|
- foreach( $order_postmeta['order_payment']['received'] as $key => $payment ) { |
|
304
|
|
- if( isset( $payment['invoice_ref'] ) && $payment['invoice_ref'] == $invoice_ref ) { |
|
|
302
|
+ if (isset($order_postmeta['order_payment']['received']) && !empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid') { |
|
|
303
|
+ foreach ($order_postmeta['order_payment']['received'] as $key => $payment) { |
|
|
304
|
+ if (isset($payment['invoice_ref']) && $payment['invoice_ref'] == $invoice_ref) { |
|
305
|
305
|
$is_partial_payment = true; |
|
306
|
306
|
break; |
|
307
|
307
|
} |
|
308
|
308
|
} |
|
309
|
|
- } elseif( !empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_invoice_ref'] != $invoice_ref ) { |
|
|
309
|
+ } elseif (!empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_invoice_ref'] != $invoice_ref) { |
|
310
|
310
|
$is_partial_payment = true; |
|
311
|
|
- } elseif( empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid' ) { |
|
|
311
|
+ } elseif (empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid') { |
|
312
|
312
|
$is_partial_payment = true; |
|
313
|
313
|
} |
|
314
|
314
|
|
|
315
|
315
|
/** Check it is a shipping slip **/ |
|
316
|
|
- $bon_colisage = !empty( $_GET['bon_colisage'] ) ? sanitize_key( $_GET['bon_colisage'] ) : false; |
|
317
|
|
- if ( $bon_colisage ) $bon_colisage = true; |
|
|
316
|
+ $bon_colisage = !empty($_GET['bon_colisage']) ? sanitize_key($_GET['bon_colisage']) : false; |
|
|
317
|
+ if ($bon_colisage) $bon_colisage = true; |
|
318
|
318
|
|
|
319
|
|
- if ( !empty($order_postmeta) ) { |
|
|
319
|
+ if (!empty($order_postmeta)) { |
|
320
|
320
|
$tpl_component = array(); |
|
321
|
321
|
|
|
322
|
322
|
/** Billing Header **/ |
|
323
|
323
|
//Logo |
|
324
|
324
|
$logo_options = get_option('wpshop_logo'); |
|
325
|
|
- $tpl_component['INVOICE_LOGO'] = ( !empty($logo_options) ) ? '<img src="' .str_replace( 'https', 'http', $logo_options ) .'" alt="" />' : ''; |
|
|
325
|
+ $tpl_component['INVOICE_LOGO'] = (!empty($logo_options)) ? '<img src="' . str_replace('https', 'http', $logo_options) . '" alt="" />' : ''; |
|
326
|
326
|
|
|
327
|
327
|
// Title |
|
328
|
|
- $tpl_component['INVOICE_TITLE'] = ($is_partial_payment) ? __('Bill payment', 'wpshop') : ( ( $is_quotation ) ? __('Quotation', 'wpshop') : __('Invoice', 'wpshop') ); |
|
|
328
|
+ $tpl_component['INVOICE_TITLE'] = ($is_partial_payment) ? __('Bill payment', 'wpshop') : (($is_quotation) ? __('Quotation', 'wpshop') : __('Invoice', 'wpshop')); |
|
329
|
329
|
|
|
330
|
330
|
// if ( empty($order_postmeta['order_invoice_ref']) ) { |
|
331
|
331
|
// $tpl_component['INVOICE_TITLE'] = __('Bill payment', 'wpshop'); |
|
332
|
332
|
// $is_partial_payment = true; |
|
333
|
333
|
// } |
|
334
|
334
|
|
|
335
|
|
- if ( $bon_colisage ) { |
|
336
|
|
- $tpl_component['INVOICE_TITLE'] = __( 'Products List', 'wpshop' ); |
|
|
335
|
+ if ($bon_colisage) { |
|
|
336
|
+ $tpl_component['INVOICE_TITLE'] = __('Products List', 'wpshop'); |
|
337
|
337
|
} |
|
338
|
338
|
|
|
339
|
|
- $tpl_component['INVOICE_ORDER_INVOICE_REF'] = ( !empty($invoice_ref) ) ? $invoice_ref : (!empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : null); |
|
340
|
|
- if ( $bon_colisage ) { |
|
|
339
|
+ $tpl_component['INVOICE_ORDER_INVOICE_REF'] = (!empty($invoice_ref)) ? $invoice_ref : (!empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : null); |
|
|
340
|
+ if ($bon_colisage) { |
|
341
|
341
|
$tpl_component['INVOICE_ORDER_INVOICE_REF'] = ''; |
|
342
|
342
|
} |
|
343
|
|
- $tpl_component['INVOICE_ORDER_KEY_INDICATION'] = ( $is_quotation ) ? sprintf( __('Ref. %s', 'wpshop'),$order_postmeta['order_temporary_key']) : sprintf( __('Order n. %s', 'wpshop'), $order_postmeta['order_key'] ); |
|
344
|
|
- $tpl_component['INVOICE_ORDER_DATE_INDICATION'] = ( $is_quotation ) ? sprintf( __('Quotation date %s', 'wpshop'), mysql2date($date_output_format ,$order_postmeta['order_date'], true) ) : sprintf( __('Order date %s', 'wpshop'), mysql2date($date_output_format ,$order_postmeta['order_date'], true) ); |
|
|
343
|
+ $tpl_component['INVOICE_ORDER_KEY_INDICATION'] = ($is_quotation) ? sprintf(__('Ref. %s', 'wpshop'), $order_postmeta['order_temporary_key']) : sprintf(__('Order n. %s', 'wpshop'), $order_postmeta['order_key']); |
|
|
344
|
+ $tpl_component['INVOICE_ORDER_DATE_INDICATION'] = ($is_quotation) ? sprintf(__('Quotation date %s', 'wpshop'), mysql2date($date_output_format, $order_postmeta['order_date'], true)) : sprintf(__('Order date %s', 'wpshop'), mysql2date($date_output_format, $order_postmeta['order_date'], true)); |
|
345
|
345
|
|
|
346
|
346
|
/** Validate period for Quotation **/ |
|
347
|
|
- if ( $is_quotation ) { |
|
348
|
|
- $quotation_validate_period = self::quotation_validate_period( $order_postmeta['order_date'] ); |
|
|
347
|
+ if ($is_quotation) { |
|
|
348
|
+ $quotation_validate_period = self::quotation_validate_period($order_postmeta['order_date']); |
|
349
|
349
|
} |
|
350
|
350
|
else { |
|
351
|
351
|
$tpl_component['INVOICE_VALIDATE_TIME'] = ''; |
|
@@ -353,22 +353,22 @@ discard block |
|
|
block discarded – undo |
|
353
|
353
|
|
|
354
|
354
|
$tpl_component['INVOICE_VALIDATE_TIME'] = empty($tpl_component['INVOICE_VALIDATE_TIME']) ? '' : $tpl_component['INVOICE_VALIDATE_TIME']; |
|
355
|
355
|
|
|
356
|
|
- $tpl_component['AMOUNT_INFORMATION'] = ( !$bon_colisage ) ? sprintf( __('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency( true ) ) : ''; |
|
|
356
|
+ $tpl_component['AMOUNT_INFORMATION'] = (!$bon_colisage) ? sprintf(__('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency(true)) : ''; |
|
357
|
357
|
|
|
358
|
358
|
|
|
359
|
359
|
|
|
360
|
360
|
// Sender & receiver addresses |
|
361
|
361
|
$tpl_component['INVOICE_SENDER'] = self::generate_invoice_sender_part( ); |
|
362
|
|
- $tpl_component['INVOICE_RECEIVER'] = self::generate_receiver_part( $order_id, $bon_colisage ); |
|
|
362
|
+ $tpl_component['INVOICE_RECEIVER'] = self::generate_receiver_part($order_id, $bon_colisage); |
|
363
|
363
|
|
|
364
|
364
|
$tpl_component['INVOICE_TRACKING'] = ''; |
|
365
|
365
|
$first = false; |
|
366
|
|
- if( !empty($order_postmeta['order_trackingNumber']) ) { |
|
|
366
|
+ if (!empty($order_postmeta['order_trackingNumber'])) { |
|
367
|
367
|
$tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingNumber']; |
|
368
|
368
|
$first = true; |
|
369
|
369
|
} |
|
370
|
|
- if( !empty($order_postmeta['order_trackingLink']) ) { |
|
371
|
|
- if( !$first ) { |
|
|
370
|
+ if (!empty($order_postmeta['order_trackingLink'])) { |
|
|
371
|
+ if (!$first) { |
|
372
|
372
|
$tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingLink']; |
|
373
|
373
|
} else { |
|
374
|
374
|
$tpl_component['INVOICE_TRACKING'] .= ' - ' . $order_postmeta['order_trackingLink']; |
|
@@ -378,22 +378,22 @@ discard block |
|
|
block discarded – undo |
|
378
|
378
|
|
|
379
|
379
|
/** Items Tab **/ |
|
380
|
380
|
$order_tva = array(); |
|
381
|
|
- if ( $bon_colisage ) { |
|
|
381
|
+ if ($bon_colisage) { |
|
382
|
382
|
$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('bon_colisage_row_header', array(), array(), 'common'); |
|
383
|
383
|
} |
|
384
|
384
|
else { |
|
385
|
385
|
$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header', array(), array(), 'common'); |
|
386
|
386
|
//if ( !$is_quotation ) { |
|
387
|
387
|
/** Check if products have discounts **/ |
|
388
|
|
- if ( !empty($order_postmeta['order_items']) && !$is_partial_payment ) { |
|
389
|
|
- foreach( $order_postmeta['order_items'] as $item_id => $item ) { |
|
390
|
|
- if ( !empty($item['item_global_discount_value']) || !empty($item['item_unit_discount_value']) ) { |
|
|
388
|
+ if (!empty($order_postmeta['order_items']) && !$is_partial_payment) { |
|
|
389
|
+ foreach ($order_postmeta['order_items'] as $item_id => $item) { |
|
|
390
|
+ if (!empty($item['item_global_discount_value']) || !empty($item['item_unit_discount_value'])) { |
|
391
|
391
|
$discounts_exists = true; |
|
392
|
392
|
} |
|
393
|
393
|
} |
|
394
|
394
|
} |
|
395
|
395
|
|
|
396
|
|
- if ( $discounts_exists ) { |
|
|
396
|
+ if ($discounts_exists) { |
|
397
|
397
|
$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header_with_discount', array(), array(), 'common'); |
|
398
|
398
|
} |
|
399
|
399
|
|
|
@@ -403,119 +403,119 @@ discard block |
|
|
block discarded – undo |
|
403
|
403
|
$total_discounted = 0; |
|
404
|
404
|
$tpl_component['INVOICE_ROWS'] = ''; |
|
405
|
405
|
|
|
406
|
|
- if( !$is_partial_payment ) { |
|
407
|
|
- if ( !empty($order_postmeta['order_items']) ) { |
|
408
|
|
- foreach( $order_postmeta['order_items'] as $item_id => $item ) { |
|
|
406
|
+ if (!$is_partial_payment) { |
|
|
407
|
+ if (!empty($order_postmeta['order_items'])) { |
|
|
408
|
+ foreach ($order_postmeta['order_items'] as $item_id => $item) { |
|
409
|
409
|
$sub_tpl_component = array(); |
|
410
|
410
|
$count_products += $item['item_qty']; |
|
411
|
|
- $barcode = get_post_meta( $item['item_id'], '_barcode', true ); |
|
412
|
|
- if ( empty($barcode) ) { |
|
413
|
|
- $product_metadata = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true ); |
|
414
|
|
- $barcode = ( !empty($product_metadata) && !empty($product_metadata['barcode']) ) ? $product_metadata['barcode'] : ''; |
|
415
|
|
- |
|
416
|
|
- if( empty($barcode) ) { |
|
417
|
|
- $product_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
418
|
|
- $att_def = wpshop_attributes::getElement( 'barcode', '"valid"', 'code' ); |
|
419
|
|
- $query = $wpdb->prepare( 'SELECT value FROM ' .$wpdb->prefix. 'wpshop__attribute_value_'.$att_def->data_type. ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d AND value != ""', $product_entity, $att_def->id, $item['item_id'] ); |
|
420
|
|
- $barcode = $wpdb->get_var( $query ); |
|
|
411
|
+ $barcode = get_post_meta($item['item_id'], '_barcode', true); |
|
|
412
|
+ if (empty($barcode)) { |
|
|
413
|
+ $product_metadata = get_post_meta($item['item_id'], '_wpshop_product_metadata', true); |
|
|
414
|
+ $barcode = (!empty($product_metadata) && !empty($product_metadata['barcode'])) ? $product_metadata['barcode'] : ''; |
|
|
415
|
+ |
|
|
416
|
+ if (empty($barcode)) { |
|
|
417
|
+ $product_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
|
418
|
+ $att_def = wpshop_attributes::getElement('barcode', '"valid"', 'code'); |
|
|
419
|
+ $query = $wpdb->prepare('SELECT value FROM ' . $wpdb->prefix . 'wpshop__attribute_value_' . $att_def->data_type . ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d AND value != ""', $product_entity, $att_def->id, $item['item_id']); |
|
|
420
|
+ $barcode = $wpdb->get_var($query); |
|
421
|
421
|
} |
|
422
|
422
|
} |
|
423
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_BARCODE'] = ( !empty($barcode) ) ? $barcode : '-'; |
|
|
423
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_BARCODE'] = (!empty($barcode)) ? $barcode : '-'; |
|
424
|
424
|
|
|
425
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_REF'] = ( !empty($barcode) ) ? $barcode : $item['item_ref']; |
|
|
425
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_REF'] = (!empty($barcode)) ? $barcode : $item['item_ref']; |
|
426
|
426
|
|
|
427
|
427
|
/** Item name **/ |
|
428
|
428
|
$is_variation = false; |
|
429
|
|
- if( get_post_type( $item['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
|
429
|
+ if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
430
|
430
|
$is_variation = true; |
|
431
|
|
- $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
432
|
|
- if( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
|
431
|
+ $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
|
432
|
+ if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
433
|
433
|
$parent_post = $parent_def['parent_post']; |
|
434
|
434
|
$item_parent_id = $parent_post->ID; |
|
435
|
|
- $item_title = $parent_post->post_title; |
|
|
435
|
+ $item_title = $parent_post->post_title; |
|
436
|
436
|
} |
|
437
|
437
|
} else { |
|
438
|
438
|
$item_title = $item['item_name']; |
|
439
|
439
|
} |
|
440
|
440
|
$sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = $item_title; |
|
441
|
441
|
/** Get attribute order for current product */ |
|
442
|
|
- $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true) ) ; |
|
|
442
|
+ $product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)); |
|
443
|
443
|
$output_order = array(); |
|
444
|
|
- if ( count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail) ) { |
|
445
|
|
- foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { |
|
446
|
|
- foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) { |
|
447
|
|
- if ( !empty($attribute_def->code) ) |
|
|
444
|
+ if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) { |
|
|
445
|
+ foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) { |
|
|
446
|
+ foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) { |
|
|
447
|
+ if (!empty($attribute_def->code)) |
|
448
|
448
|
$output_order[$attribute_def->code] = $position; |
|
449
|
449
|
} |
|
450
|
450
|
} |
|
451
|
451
|
} |
|
452
|
|
- $variation_attribute_ordered = wpshop_products::get_selected_variation_display( $item['item_meta'], $output_order, 'invoice_print', 'common'); |
|
|
452
|
+ $variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'invoice_print', 'common'); |
|
453
|
453
|
ksort($variation_attribute_ordered['attribute_list']); |
|
454
|
454
|
$detail_tpl_component['CART_PRODUCT_MORE_INFO'] = ''; |
|
455
|
|
- foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) { |
|
|
455
|
+ foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) { |
|
456
|
456
|
$detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= $attribute_variation_to_output; |
|
457
|
457
|
} |
|
458
|
|
- if( /*get_post_status( $item['item_id'] ) == 'free_product' &&*/ ! empty( get_post_field( 'post_content', $item['item_id'] ) ) && false ) { |
|
459
|
|
- if ( ! empty( $detail_tpl_component['CART_PRODUCT_MORE_INFO'] ) ) { |
|
|
458
|
+ if ( /*get_post_status( $item['item_id'] ) == 'free_product' &&*/ !empty(get_post_field('post_content', $item['item_id'])) && false ) { |
|
|
459
|
+ if (!empty($detail_tpl_component['CART_PRODUCT_MORE_INFO'])) { |
|
460
|
460
|
//$detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= '<br>'; |
|
461
|
461
|
} |
|
462
|
|
- $detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= '<span id="wpshop_cart_description_line">' . nl2br( get_post_field( 'post_content', $item['item_id'] ) ) . '</span>'; |
|
|
462
|
+ $detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= '<span id="wpshop_cart_description_line">' . nl2br(get_post_field('post_content', $item['item_id'])) . '</span>'; |
|
463
|
463
|
} |
|
464
|
464
|
$sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = !empty($detail_tpl_component['CART_PRODUCT_MORE_INFO']) ? wpshop_display::display_template_element('invoice_row_item_detail', $detail_tpl_component, array(), 'common') : ''; |
|
465
|
|
- unset( $detail_tpl_component ); |
|
|
465
|
+ unset($detail_tpl_component); |
|
466
|
466
|
|
|
467
|
467
|
$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = $item['item_qty']; |
|
468
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_PU_TTC'] = ( ( !empty($item['item_pu_ttc_before_discount']) ) ? number_format( $item['item_pu_ttc_before_discount'], 2, '.', '' ) : number_format( $item['item_pu_ttc'], 2, '.', '' ) ); |
|
469
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = ( ( !empty($item['item_pu_ht_before_discount']) ) ? number_format( $item['item_pu_ht_before_discount'], 2, '.', '' ) : number_format( $item['item_pu_ht'], 2, '.', '' ) ); |
|
470
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = ( !empty($item['item_discount_value']) ) ? number_format($item['item_discount_value'], 2, '.', '') : number_format(0, 2, '.', '' ); |
|
471
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format( ($item['item_pu_ht'] * $item['item_qty']), 2, '.', '' ); |
|
|
468
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_PU_TTC'] = ((!empty($item['item_pu_ttc_before_discount'])) ? number_format($item['item_pu_ttc_before_discount'], 2, '.', '') : number_format($item['item_pu_ttc'], 2, '.', '')); |
|
|
469
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = ((!empty($item['item_pu_ht_before_discount'])) ? number_format($item['item_pu_ht_before_discount'], 2, '.', '') : number_format($item['item_pu_ht'], 2, '.', '')); |
|
|
470
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = (!empty($item['item_discount_value'])) ? number_format($item['item_discount_value'], 2, '.', '') : number_format(0, 2, '.', ''); |
|
|
471
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format(($item['item_pu_ht'] * $item['item_qty']), 2, '.', ''); |
|
472
|
472
|
/** TVA **/ |
|
473
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format($item['item_tva_total_amount'], 2, '.', '' ); |
|
|
473
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format($item['item_tva_total_amount'], 2, '.', ''); |
|
474
|
474
|
$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = $item['item_tva_rate']; |
|
475
|
475
|
|
|
476
|
476
|
|
|
477
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format( $item['item_total_ttc'], 2, '.', '' ); |
|
|
477
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($item['item_total_ttc'], 2, '.', ''); |
|
478
|
478
|
|
|
479
|
479
|
|
|
480
|
480
|
/** Checking Rate amount **/ |
|
481
|
|
- if ( !$bon_colisage ) { |
|
482
|
|
- $checking = self::check_product_price( $item['item_total_ht'], $item['item_total_ttc'], $item['item_tva_total_amount'], $item['item_tva_rate'], $item['item_id'], $invoice_ref, $order_id ); |
|
483
|
|
- if( !$checking ) { |
|
|
481
|
+ if (!$bon_colisage) { |
|
|
482
|
+ $checking = self::check_product_price($item['item_total_ht'], $item['item_total_ttc'], $item['item_tva_total_amount'], $item['item_tva_rate'], $item['item_id'], $invoice_ref, $order_id); |
|
|
483
|
+ if (!$checking) { |
|
484
|
484
|
return __('Invoice cannot be generate because an error was found. The website administrator has been warned.', 'wpshop'); |
|
485
|
485
|
} |
|
486
|
486
|
} |
|
487
|
487
|
|
|
488
|
|
- if ( $bon_colisage ) { |
|
|
488
|
+ if ($bon_colisage) { |
|
489
|
489
|
$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('bon_colisage_row', $sub_tpl_component, array(), 'common'); |
|
490
|
490
|
} |
|
491
|
491
|
else { |
|
492
|
|
- if ( $discounts_exists ) { |
|
|
492
|
+ if ($discounts_exists) { |
|
493
|
493
|
$discounted_total_per_item = $item['item_total_ht']; |
|
494
|
494
|
/** Unit Discount **/ |
|
495
|
|
- if ( !empty($item['item_unit_discount_amount']) && !empty($item['item_unit_discount_value']) ) { |
|
496
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( $item['item_unit_discount_amount'], 2, '.', ''); |
|
497
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( $item['item_unit_discount_value'], 2, '.', ''); |
|
|
495
|
+ if (!empty($item['item_unit_discount_amount']) && !empty($item['item_unit_discount_value'])) { |
|
|
496
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format($item['item_unit_discount_amount'], 2, '.', ''); |
|
|
497
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format($item['item_unit_discount_value'], 2, '.', ''); |
|
498
|
498
|
$discounted_total_per_item = $discounted_total_per_item - $item['item_unit_discount_amount']; |
|
499
|
499
|
} |
|
500
|
500
|
else { |
|
501
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', ''); |
|
502
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( 0, 2, '.', ''); |
|
|
501
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
502
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); |
|
503
|
503
|
} |
|
504
|
504
|
|
|
505
|
505
|
/** Global Discount **/ |
|
506
|
|
- if ( !empty($item['item_global_discount_amount']) && !empty($item['item_global_discount_value']) ) { |
|
507
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( $item['item_global_discount_amount'], 2, '.', ''); |
|
508
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( $item['item_global_discount_value'], 2, '.', ''); |
|
|
506
|
+ if (!empty($item['item_global_discount_amount']) && !empty($item['item_global_discount_value'])) { |
|
|
507
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format($item['item_global_discount_amount'], 2, '.', ''); |
|
|
508
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format($item['item_global_discount_value'], 2, '.', ''); |
|
509
|
509
|
$discounted_total_per_item = $discounted_total_per_item - $item['item_global_discount_amount']; |
|
510
|
510
|
} |
|
511
|
511
|
else { |
|
512
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', ''); |
|
513
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', ''); |
|
|
512
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
513
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); |
|
514
|
514
|
} |
|
515
|
515
|
|
|
516
|
516
|
$total_discounted += $discounted_total_per_item; |
|
517
|
517
|
/** Total HT Discounted **/ |
|
518
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format( $discounted_total_per_item, 2, '.', ''); |
|
|
518
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format($discounted_total_per_item, 2, '.', ''); |
|
519
|
519
|
|
|
520
|
520
|
$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common'); |
|
521
|
521
|
} |
|
@@ -523,14 +523,14 @@ discard block |
|
|
block discarded – undo |
|
523
|
523
|
$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common'); |
|
524
|
524
|
} |
|
525
|
525
|
} |
|
526
|
|
- unset( $sub_tpl_component ); |
|
|
526
|
+ unset($sub_tpl_component); |
|
527
|
527
|
|
|
528
|
528
|
/** Check TVA **/ |
|
529
|
|
- if ( empty($order_tva[ $item['item_tva_rate'] ]) ) { |
|
530
|
|
- $order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount']; |
|
|
529
|
+ if (empty($order_tva[$item['item_tva_rate']])) { |
|
|
530
|
+ $order_tva[$item['item_tva_rate']] = $item['item_tva_total_amount']; |
|
531
|
531
|
} |
|
532
|
532
|
else { |
|
533
|
|
- $order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount']; |
|
|
533
|
+ $order_tva[$item['item_tva_rate']] += $item['item_tva_total_amount']; |
|
534
|
534
|
} |
|
535
|
535
|
|
|
536
|
536
|
} |
|
@@ -541,33 +541,33 @@ discard block |
|
|
block discarded – undo |
|
541
|
541
|
|
|
542
|
542
|
/** Display Partials payments **/ |
|
543
|
543
|
$total_partial_payment = 0; $last_payment = 0; |
|
544
|
|
- $order_invoice_ref = ( !empty($order_postmeta['order_invoice_ref']) ) ? $order_postmeta['order_invoice_ref'] : ''; |
|
545
|
|
- if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage ) { |
|
546
|
|
- foreach( $order_postmeta['order_payment']['received'] as $received_payment ) { |
|
547
|
|
- if ( !empty($received_payment['invoice_ref']) && $received_payment['invoice_ref'] != $order_invoice_ref ) { |
|
548
|
|
- if ( intval( substr($received_payment['invoice_ref'], 2) ) == intval( substr($tpl_component['INVOICE_ORDER_INVOICE_REF'], 2) )) { |
|
|
544
|
+ $order_invoice_ref = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ''; |
|
|
545
|
+ if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) { |
|
|
546
|
+ foreach ($order_postmeta['order_payment']['received'] as $received_payment) { |
|
|
547
|
+ if (!empty($received_payment['invoice_ref']) && $received_payment['invoice_ref'] != $order_invoice_ref) { |
|
|
548
|
+ if (intval(substr($received_payment['invoice_ref'], 2)) == intval(substr($tpl_component['INVOICE_ORDER_INVOICE_REF'], 2))) { |
|
549
|
549
|
$sub_tpl_component = array(); |
|
550
|
550
|
$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref']; |
|
551
|
551
|
|
|
552
|
552
|
/** Item name **/ |
|
553
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf( __('Partial payment on order %1$s', 'wpshop'), $order_postmeta['order_key'], __( $received_payment['method'], 'wpshop'), $received_payment['payment_reference']); |
|
|
553
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf(__('Partial payment on order %1$s', 'wpshop'), $order_postmeta['order_key'], __($received_payment['method'], 'wpshop'), $received_payment['payment_reference']); |
|
554
|
554
|
$sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = ''; |
|
555
|
555
|
$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1; |
|
556
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
557
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '' ); |
|
558
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
|
556
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); |
|
|
557
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
558
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); |
|
559
|
559
|
|
|
560
|
560
|
/** TVA **/ |
|
561
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '' ); |
|
|
561
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', ''); |
|
562
|
562
|
$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0; |
|
563
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
|
563
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); |
|
564
|
564
|
|
|
565
|
|
- if ( $discounts_exists ) { |
|
566
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = '-'.number_format( $received_payment['received_amount'], 2, '.', ''); |
|
567
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', ''); |
|
568
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( 0, 2, '.', ''); |
|
569
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', ''); |
|
570
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', ''); |
|
|
565
|
+ if ($discounts_exists) { |
|
|
566
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = '-' . number_format($received_payment['received_amount'], 2, '.', ''); |
|
|
567
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
568
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); |
|
|
569
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
570
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', ''); |
|
571
|
571
|
|
|
572
|
572
|
$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common'); |
|
573
|
573
|
} |
|
@@ -576,11 +576,11 @@ discard block |
|
|
block discarded – undo |
|
576
|
576
|
} |
|
577
|
577
|
} |
|
578
|
578
|
|
|
579
|
|
- unset( $sub_tpl_component ); |
|
580
|
|
- $total_partial_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0; |
|
|
579
|
+ unset($sub_tpl_component); |
|
|
580
|
+ $total_partial_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0; |
|
581
|
581
|
} |
|
582
|
|
- else if( 'payment_received' == $received_payment[ 'status' ] ) { |
|
583
|
|
- $last_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0; |
|
|
582
|
+ else if ('payment_received' == $received_payment['status']) { |
|
|
583
|
+ $last_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0; |
|
584
|
584
|
} |
|
585
|
585
|
|
|
586
|
586
|
} |
|
@@ -589,24 +589,24 @@ discard block |
|
|
block discarded – undo |
|
589
|
589
|
else { |
|
590
|
590
|
/** Display Partials payments **/ |
|
591
|
591
|
$total_partial_payment = 0; $last_payment = 0; |
|
592
|
|
- if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage ) { |
|
593
|
|
- foreach( $order_postmeta['order_payment']['received'] as $key => $received_payment ) { |
|
594
|
|
- if ( !empty($received_payment['invoice_ref']) && !empty($invoice_ref) && $received_payment['invoice_ref'] == $invoice_ref ) { |
|
|
592
|
+ if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) { |
|
|
593
|
+ foreach ($order_postmeta['order_payment']['received'] as $key => $received_payment) { |
|
|
594
|
+ if (!empty($received_payment['invoice_ref']) && !empty($invoice_ref) && $received_payment['invoice_ref'] == $invoice_ref) { |
|
595
|
595
|
$sub_tpl_component = array(); |
|
596
|
596
|
$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref']; |
|
597
|
597
|
/** Item name **/ |
|
598
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf( __('Partial payment %4$d on order %1$s', 'wpshop'), $order_postmeta['order_key'], __( $received_payment['method'], 'wpshop'), $received_payment['payment_reference'], $key+1); |
|
|
598
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = sprintf(__('Partial payment %4$d on order %1$s', 'wpshop'), $order_postmeta['order_key'], __($received_payment['method'], 'wpshop'), $received_payment['payment_reference'], $key + 1); |
|
599
|
599
|
$sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = ''; |
|
600
|
600
|
$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1; |
|
601
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
602
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '' ); |
|
603
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
|
601
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = number_format($received_payment['received_amount'], 2, '.', ''); |
|
|
602
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', ''); |
|
|
603
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format($received_payment['received_amount'], 2, '.', ''); |
|
604
|
604
|
/** TVA **/ |
|
605
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '' ); |
|
|
605
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', ''); |
|
606
|
606
|
$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0; |
|
607
|
|
- $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format( $received_payment['received_amount'], 2, '.', '' ); |
|
|
607
|
+ $sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($received_payment['received_amount'], 2, '.', ''); |
|
608
|
608
|
$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common'); |
|
609
|
|
- unset( $sub_tpl_component ); |
|
|
609
|
+ unset($sub_tpl_component); |
|
610
|
610
|
$total_partial_payment += $received_payment['received_amount']; |
|
611
|
611
|
} |
|
612
|
612
|
} |
|
@@ -619,126 +619,126 @@ discard block |
|
|
block discarded – undo |
|
619
|
619
|
/** Summary of order **/ |
|
620
|
620
|
$summary_tpl_component = array(); |
|
621
|
621
|
$tpl_component['INVOICE_SUMMARY_PART'] = $summary_tpl_component['INVOICE_SUMMARY_TAXES'] = ''; |
|
622
|
|
- if ( !$bon_colisage ) { |
|
623
|
|
- if ( !empty( $order_tva ) ) { |
|
624
|
|
- foreach( $order_tva as $tax_rate => $tax_amount ) { |
|
625
|
|
- if ( $tax_amount > 0 ) { |
|
626
|
|
- $tax_rate = ( !empty($tax_rate) && $tax_rate == 'VAT_shipping_cost' ) ? __('on Shipping cost', 'wpshop').' '.WPSHOP_VAT_ON_SHIPPING_COST : $tax_rate; |
|
627
|
|
- $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf( __('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%' ); |
|
|
622
|
+ if (!$bon_colisage) { |
|
|
623
|
+ if (!empty($order_tva)) { |
|
|
624
|
+ foreach ($order_tva as $tax_rate => $tax_amount) { |
|
|
625
|
+ if ($tax_amount > 0) { |
|
|
626
|
+ $tax_rate = (!empty($tax_rate) && $tax_rate == 'VAT_shipping_cost') ? __('on Shipping cost', 'wpshop') . ' ' . WPSHOP_VAT_ON_SHIPPING_COST : $tax_rate; |
|
|
627
|
+ $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%'); |
|
628
|
628
|
$sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency(); |
|
629
|
629
|
$summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); |
|
630
|
|
- unset( $sub_tpl_component ); |
|
|
630
|
+ unset($sub_tpl_component); |
|
631
|
631
|
} |
|
632
|
|
- elseif( $is_partial_payment ) { |
|
|
632
|
+ elseif ($is_partial_payment) { |
|
633
|
633
|
$tax_rate = 0; |
|
634
|
|
- $tax_amount = number_format( 0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
635
|
|
- $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf( __('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%' ); |
|
|
634
|
+ $tax_amount = number_format(0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
|
635
|
+ $sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%'); |
|
636
|
636
|
$sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency(); |
|
637
|
637
|
$summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); |
|
638
|
|
- unset( $sub_tpl_component ); |
|
|
638
|
+ unset($sub_tpl_component); |
|
639
|
639
|
} |
|
640
|
640
|
} |
|
641
|
641
|
} |
|
642
|
642
|
|
|
643
|
643
|
/** If Discount Exist **/ |
|
644
|
644
|
// Checking Discounts on order |
|
645
|
|
- if( !empty($order_postmeta['order_discount_type']) && $order_postmeta['order_discount_value'] ) { |
|
|
645
|
+ if (!empty($order_postmeta['order_discount_type']) && $order_postmeta['order_discount_value']) { |
|
646
|
646
|
$discounts_exists = true; |
|
647
|
647
|
// Calcul discount on Order |
|
648
|
|
- switch( $order_postmeta['order_discount_type'] ) { |
|
|
648
|
+ switch ($order_postmeta['order_discount_type']) { |
|
649
|
649
|
case 'amount': |
|
650
|
|
- $total_discounted += number_format( str_replace( ',', '.', $order_postmeta['order_discount_value'] ), 2, '.', '' ); |
|
|
650
|
+ $total_discounted += number_format(str_replace(',', '.', $order_postmeta['order_discount_value']), 2, '.', ''); |
|
651
|
651
|
break; |
|
652
|
652
|
case 'percent': |
|
653
|
|
- $total_discounted += number_format( $order_postmeta['order_grand_total_before_discount'], 2, '.', '') * ( number_format( str_replace( ',', '.', $order_postmeta['order_discount_value']), 2, '.', '') / 100 ); |
|
|
653
|
+ $total_discounted += number_format($order_postmeta['order_grand_total_before_discount'], 2, '.', '') * (number_format(str_replace(',', '.', $order_postmeta['order_discount_value']), 2, '.', '') / 100); |
|
654
|
654
|
break; |
|
655
|
655
|
} |
|
656
|
656
|
} |
|
657
|
|
- if ( !empty($total_discounted) && $discounts_exists ) { |
|
|
657
|
+ if (!empty($total_discounted) && $discounts_exists) { |
|
658
|
658
|
$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Discounted Total', 'wpshop'); |
|
659
|
|
- $sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format( $total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
|
659
|
+ $sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format($total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
660
|
660
|
$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); |
|
661
|
|
- unset( $sub_tpl_component ); |
|
|
661
|
+ unset($sub_tpl_component); |
|
662
|
662
|
} |
|
663
|
663
|
else { |
|
664
|
664
|
$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = ''; |
|
665
|
665
|
} |
|
666
|
666
|
|
|
667
|
667
|
$shipping_cost = 0; |
|
668
|
|
- if ( !$is_partial_payment ) { |
|
669
|
|
- if( !empty($order_postmeta['order_shipping_cost']) ) { |
|
|
668
|
+ if (!$is_partial_payment) { |
|
|
669
|
+ if (!empty($order_postmeta['order_shipping_cost'])) { |
|
670
|
670
|
$shipping_cost = $order_postmeta['order_shipping_cost']; |
|
671
|
671
|
} |
|
672
|
672
|
} |
|
673
|
|
- $price_piloting = get_option( 'wpshop_shop_price_piloting', 'TTC' ); |
|
674
|
|
- $shipping_taxes = 'HT' == $price_piloting ? ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) * $shipping_cost : $shipping_cost - ( $shipping_cost / ( 1 + WPSHOP_VAT_ON_SHIPPING_COST / 100 ) ); |
|
675
|
|
- $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = number_format( $shipping_cost, 2, ',', '' ); |
|
676
|
|
- $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST_TAXES'] = number_format( $shipping_taxes, 2, ',', '' ); |
|
|
673
|
+ $price_piloting = get_option('wpshop_shop_price_piloting', 'TTC'); |
|
|
674
|
+ $shipping_taxes = 'HT' == $price_piloting ? (WPSHOP_VAT_ON_SHIPPING_COST / 100) * $shipping_cost : $shipping_cost - ($shipping_cost / (1 + WPSHOP_VAT_ON_SHIPPING_COST / 100)); |
|
|
675
|
+ $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = number_format($shipping_cost, 2, ',', ''); |
|
|
676
|
+ $summary_tpl_component['INVOICE_ORDER_SHIPPING_COST_TAXES'] = number_format($shipping_taxes, 2, ',', ''); |
|
677
|
677
|
//$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = ( $is_partial_payment ) ? number_format( 0, 2, ',', '') : number_format( ( (!empty($order_postmeta['order_shipping_cost']) ) ? $order_postmeta['order_shipping_cost'] : 0 ), 2, ',', '' ); |
|
678
|
678
|
|
|
679
|
|
- $summary_tpl_component['INVOICE_ORDER_GRAND_TOTAL'] = ( $is_partial_payment ) ? number_format(0, 2, ',', '' ) : number_format( $order_postmeta['order_grand_total'], 2, ',', ''); // - $total_partial_payment , 2, ',', '' ); |
|
680
|
|
- $summary_tpl_component['INVOICE_ORDER_TOTAL_HT'] = ( $is_partial_payment ) ? number_format(0, 2, ',', '' ) : number_format( $order_postmeta['order_total_ht'], 2, ',', '' ); |
|
|
679
|
+ $summary_tpl_component['INVOICE_ORDER_GRAND_TOTAL'] = ($is_partial_payment) ? number_format(0, 2, ',', '') : number_format($order_postmeta['order_grand_total'], 2, ',', ''); // - $total_partial_payment , 2, ',', '' ); |
|
|
680
|
+ $summary_tpl_component['INVOICE_ORDER_TOTAL_HT'] = ($is_partial_payment) ? number_format(0, 2, ',', '') : number_format($order_postmeta['order_total_ht'], 2, ',', ''); |
|
681
|
681
|
|
|
682
|
682
|
$summary_tpl_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', ''); |
|
683
|
683
|
|
|
684
|
684
|
$total_payment = 0; |
|
685
|
685
|
|
|
686
|
686
|
/** Amount paid **/ |
|
687
|
|
- if ( empty($order_postmeta['order_invoice_ref']) ) { |
|
|
687
|
+ if (empty($order_postmeta['order_invoice_ref'])) { |
|
688
|
688
|
foreach ($order_postmeta['order_payment']['received'] as $key => $value) { |
|
689
|
|
- if ( !empty($value['invoice_ref']) && $value['invoice_ref'] === $tpl_component['INVOICE_ORDER_INVOICE_REF'] ) { |
|
|
689
|
+ if (!empty($value['invoice_ref']) && $value['invoice_ref'] === $tpl_component['INVOICE_ORDER_INVOICE_REF']) { |
|
690
|
690
|
$total_payment = number_format($value['received_amount'], 2, ',', ''); |
|
691
|
691
|
} |
|
692
|
692
|
} |
|
693
|
693
|
} |
|
694
|
694
|
else { |
|
695
|
|
- $total_payment = ( ($total_partial_payment+$last_payment) !== $order_postmeta['order_grand_total'] ) ? number_format($total_partial_payment+$last_payment, 2, ',', '') : $order_postmeta['order_grand_total']; |
|
|
695
|
+ $total_payment = (($total_partial_payment + $last_payment) !== $order_postmeta['order_grand_total']) ? number_format($total_partial_payment + $last_payment, 2, ',', '') : $order_postmeta['order_grand_total']; |
|
696
|
696
|
} |
|
697
|
697
|
|
|
698
|
698
|
$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Amount already paid', 'wpshop'); |
|
699
|
|
- $sub_tpl_component['SUMMARY_ROW_VALUE'] = ( !$is_partial_payment ) ? number_format( $last_payment, 2, ',', '') .' ' . wpshop_tools::wpshop_get_currency() : $total_payment .' ' . wpshop_tools::wpshop_get_currency(); |
|
|
699
|
+ $sub_tpl_component['SUMMARY_ROW_VALUE'] = (!$is_partial_payment) ? number_format($last_payment, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency() : $total_payment . ' ' . wpshop_tools::wpshop_get_currency(); |
|
700
|
700
|
//$sub_tpl_component['SUMMARY_ROW_VALUE'] = ( $is_partial_payment ) ? number_format($total_partial_payment, 2, ',', '' ). ' ' . wpshop_tools::wpshop_get_currency() : number_format($order_postmeta['order_grand_total'], 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
701
|
701
|
$summary_tpl_component['INVOICE_SUMMARY_MORE'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); |
|
702
|
|
- unset( $sub_tpl_component ); |
|
|
702
|
+ unset($sub_tpl_component); |
|
703
|
703
|
|
|
704
|
704
|
$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Number of products', 'wpshop'); |
|
705
|
705
|
$sub_tpl_component['SUMMARY_ROW_VALUE'] = $count_products; |
|
706
|
706
|
$summary_tpl_component['INVOICE_SUMMARY_MORE'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common'); |
|
707
|
|
- unset( $sub_tpl_component ); |
|
|
707
|
+ unset($sub_tpl_component); |
|
708
|
708
|
|
|
709
|
709
|
|
|
710
|
710
|
/** If Discount Exist **/ |
|
711
|
|
- if ( !empty($order_postmeta['coupon_id']) && !empty($order_postmeta['order_discount_value']) ) { |
|
|
711
|
+ if (!empty($order_postmeta['coupon_id']) && !empty($order_postmeta['order_discount_value'])) { |
|
712
|
712
|
$tpl_discount_component = array(); |
|
713
|
713
|
$tpl_discount_component['DISCOUNT_VALUE'] = ($order_postmeta['order_discount_type'] == 'percent') ? number_format($order_postmeta['order_discount_amount_total_cart'], 2, ',', '') : number_format($order_postmeta['order_discount_value'], 2, ',', ''); |
|
714
|
714
|
|
|
715
|
715
|
$tpl_discount_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', ''); |
|
716
|
716
|
$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = wpshop_display::display_template_element('invoice_discount_part', $tpl_discount_component, array(), 'common'); |
|
717
|
|
- unset( $tpl_discount_component ); |
|
|
717
|
+ unset($tpl_discount_component); |
|
718
|
718
|
} |
|
719
|
719
|
else { |
|
720
|
720
|
$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = ''; |
|
721
|
721
|
} |
|
722
|
722
|
|
|
723
|
|
- $summary_tpl_component[ 'PRICE_PILOTING' ] = 'HT' == $price_piloting ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' ); |
|
|
723
|
+ $summary_tpl_component['PRICE_PILOTING'] = 'HT' == $price_piloting ? __('ET', 'wpshop') : __('ATI', 'wpshop'); |
|
724
|
724
|
|
|
725
|
725
|
$tpl_component['INVOICE_SUMMARY_PART'] = wpshop_display::display_template_element('invoice_summary_part', $summary_tpl_component, array(), 'common'); |
|
726
|
|
- unset( $summary_tpl_component ); |
|
|
726
|
+ unset($summary_tpl_component); |
|
727
|
727
|
} |
|
728
|
728
|
|
|
729
|
729
|
|
|
730
|
730
|
/** IBAN Include on quotation **/ |
|
731
|
|
- if ( $is_quotation ) { |
|
|
731
|
+ if ($is_quotation) { |
|
732
|
732
|
/** If admin want to include his IBAN to quotation */ |
|
733
|
733
|
$iban_options = get_option('wpshop_paymentMethod_options'); |
|
734
|
734
|
$payment_options = get_option('wps_payment_mode'); |
|
735
|
|
- if ( !empty($payment_options) && !empty($payment_options['mode']) && !empty($payment_options['mode']['banktransfer']) && !empty($payment_options['mode']['banktransfer']['active']) && $payment_options['mode']['banktransfer']['active'] == 'on' ) { |
|
736
|
|
- if ( !empty($iban_options) && !empty($iban_options['banktransfer']) /*&& !empty($iban_options['banktransfer']['add_in_quotation'])*/ ) { |
|
737
|
|
- $tpl_component['IBAN_INFOS'] = __('Payment by Bank Transfer on this bank account', 'wpshop'). ' : <br/>'; |
|
738
|
|
- $tpl_component['IBAN_INFOS'] .= __('Bank name', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['bank_name']) ) ? $iban_options['banktransfer']['bank_name'] : ''). '<br/>'; |
|
739
|
|
- $tpl_component['IBAN_INFOS'] .= __('IBAN', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['iban']) ) ? $iban_options['banktransfer']['iban'] : ''). '<br/>'; |
|
740
|
|
- $tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['bic']) ) ? $iban_options['banktransfer']['bic'] : ''). '<br/>'; |
|
741
|
|
- $tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['accountowner']) ) ? $iban_options['banktransfer']['accountowner'] : ''). '<br/>'; |
|
|
735
|
+ if (!empty($payment_options) && !empty($payment_options['mode']) && !empty($payment_options['mode']['banktransfer']) && !empty($payment_options['mode']['banktransfer']['active']) && $payment_options['mode']['banktransfer']['active'] == 'on') { |
|
|
736
|
+ if (!empty($iban_options) && !empty($iban_options['banktransfer']) /*&& !empty($iban_options['banktransfer']['add_in_quotation'])*/) { |
|
|
737
|
+ $tpl_component['IBAN_INFOS'] = __('Payment by Bank Transfer on this bank account', 'wpshop') . ' : <br/>'; |
|
|
738
|
+ $tpl_component['IBAN_INFOS'] .= __('Bank name', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['bank_name'])) ? $iban_options['banktransfer']['bank_name'] : '') . '<br/>'; |
|
|
739
|
+ $tpl_component['IBAN_INFOS'] .= __('IBAN', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['iban'])) ? $iban_options['banktransfer']['iban'] : '') . '<br/>'; |
|
|
740
|
+ $tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['bic'])) ? $iban_options['banktransfer']['bic'] : '') . '<br/>'; |
|
|
741
|
+ $tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['accountowner'])) ? $iban_options['banktransfer']['accountowner'] : '') . '<br/>'; |
|
742
|
742
|
} |
|
743
|
743
|
} |
|
744
|
744
|
else { |
|
@@ -751,8 +751,8 @@ discard block |
|
|
block discarded – undo |
|
751
|
751
|
|
|
752
|
752
|
|
|
753
|
753
|
/** Received payements **/ |
|
754
|
|
- if ( !$is_partial_payment && !$bon_colisage && !empty($order_postmeta['order_invoice_ref']) ) { |
|
755
|
|
- $tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part( $order_id ); |
|
|
754
|
+ if (!$is_partial_payment && !$bon_colisage && !empty($order_postmeta['order_invoice_ref'])) { |
|
|
755
|
+ $tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part($order_id); |
|
756
|
756
|
} |
|
757
|
757
|
else { |
|
758
|
758
|
$tpl_component['RECEIVED_PAYMENT'] = ''; |
|
@@ -765,11 +765,11 @@ discard block |
|
|
block discarded – undo |
|
765
|
765
|
$output = wpshop_display::display_template_element('invoice_page_content', $tpl_component, array(), 'common'); |
|
766
|
766
|
} |
|
767
|
767
|
else { |
|
768
|
|
- $output = __('No order information has been found', 'wpshop'); |
|
|
768
|
+ $output = __('No order information has been found', 'wpshop'); |
|
769
|
769
|
} |
|
770
|
770
|
} |
|
771
|
771
|
else { |
|
772
|
|
- $output = __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop'); |
|
|
772
|
+ $output = __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop'); |
|
773
|
773
|
} |
|
774
|
774
|
return $output; |
|
775
|
775
|
} |
|
@@ -780,61 +780,61 @@ discard block |
|
|
block discarded – undo |
|
780
|
780
|
* @param integer $order_id |
|
781
|
781
|
* @return string |
|
782
|
782
|
*/ |
|
783
|
|
- public static function generate_received_payment_part( $order_id ) { |
|
784
|
|
- $date_ouput_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' ); |
|
|
783
|
+ public static function generate_received_payment_part($order_id) { |
|
|
784
|
+ $date_ouput_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
785
|
785
|
$output = ''; |
|
786
|
786
|
$tpl_component = array(); |
|
787
|
787
|
$tpl_component['ORDER_RECEIVED_PAYMENT_ROWS'] = ''; |
|
788
|
|
- if ( !empty($order_id) ) { |
|
|
788
|
+ if (!empty($order_id)) { |
|
789
|
789
|
$order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
790
|
|
- if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) ) { |
|
791
|
|
- $wps_payment_option = get_option( 'wps_payment_mode' ); |
|
792
|
|
- foreach( $order_postmeta['order_payment']['received'] as $payment ) { |
|
793
|
|
- if ( ! empty( $payment ) && ! in_array( $payment['method'], array( 'quotation' ), true ) && ! empty( $payment['received_amount'] ) ) { |
|
|
790
|
+ if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received'])) { |
|
|
791
|
+ $wps_payment_option = get_option('wps_payment_mode'); |
|
|
792
|
+ foreach ($order_postmeta['order_payment']['received'] as $payment) { |
|
|
793
|
+ if (!empty($payment) && !in_array($payment['method'], array('quotation'), true) && !empty($payment['received_amount'])) { |
|
794
|
794
|
$sub_tpl_component = array(); |
|
795
|
|
- $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_RECEIVED_AMOUNT'] = ( !empty($payment['received_amount']) ) ? number_format( $payment['received_amount'], 2, ',', '' ).' '.wpshop_tools::wpshop_get_currency() : 0; |
|
796
|
|
- $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_DATE'] = (!empty($payment['date']) ) ? mysql2date($date_ouput_format, $payment['date'], true) : ''; |
|
797
|
|
- $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_METHOD'] = ( ( !empty( $payment[ 'method' ] ) && is_array( $wps_payment_option ) && array_key_exists( strtolower( $payment['method'] ), $wps_payment_option[ 'mode' ] ) && !empty( $wps_payment_option[ 'mode' ][ strtolower( $payment['method'] ) ][ 'name' ] ) ) ? $wps_payment_option[ 'mode' ][ strtolower( $payment['method'] ) ][ 'name' ] : ( !empty( $payment[ 'method' ] ) ? __( $payment[ 'method' ], 'wpshop' ) : '' ) ); |
|
798
|
|
- $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_PAYMENT_REFERENCE'] = ( !empty($payment['payment_reference']) ) ? $payment['payment_reference'] : ''; |
|
799
|
|
- $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_INVOICE_REF'] = ( !empty($payment['invoice_ref']) ) ? $payment['invoice_ref'] : ''; |
|
|
795
|
+ $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_RECEIVED_AMOUNT'] = (!empty($payment['received_amount'])) ? number_format($payment['received_amount'], 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency() : 0; |
|
|
796
|
+ $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_DATE'] = (!empty($payment['date'])) ? mysql2date($date_ouput_format, $payment['date'], true) : ''; |
|
|
797
|
+ $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_METHOD'] = ((!empty($payment['method']) && is_array($wps_payment_option) && array_key_exists(strtolower($payment['method']), $wps_payment_option['mode']) && !empty($wps_payment_option['mode'][strtolower($payment['method'])]['name'])) ? $wps_payment_option['mode'][strtolower($payment['method'])]['name'] : (!empty($payment['method']) ? __($payment['method'], 'wpshop') : '')); |
|
|
798
|
+ $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_PAYMENT_REFERENCE'] = (!empty($payment['payment_reference'])) ? $payment['payment_reference'] : ''; |
|
|
799
|
+ $sub_tpl_component['INVOICE_RECEIVED_PAYMENT_INVOICE_REF'] = (!empty($payment['invoice_ref'])) ? $payment['invoice_ref'] : ''; |
|
800
|
800
|
$tpl_component['ORDER_RECEIVED_PAYMENT_ROWS'] .= wpshop_display::display_template_element('received_payment_row', $sub_tpl_component, array('type' => 'invoice_line', 'id' => 'partial_payment'), 'common'); |
|
801
|
801
|
} |
|
802
|
802
|
} |
|
803
|
803
|
} |
|
804
|
804
|
$output = wpshop_display::display_template_element('received_payment', $tpl_component, array('type' => 'invoice_line', 'id' => 'partial_payment'), 'common'); |
|
805
|
|
- unset( $tpl_component ); |
|
|
805
|
+ unset($tpl_component); |
|
806
|
806
|
} |
|
807
|
807
|
return $output; |
|
808
|
808
|
} |
|
809
|
809
|
|
|
810
|
810
|
|
|
811
|
811
|
/** Return the validity period of a quotation **/ |
|
812
|
|
- public static function quotation_validate_period( $quotation_date ) { |
|
|
812
|
+ public static function quotation_validate_period($quotation_date) { |
|
813
|
813
|
$quotation_options = get_option('wpshop_quotation_validate_time'); |
|
814
|
|
- if ( !empty($quotation_options) && !empty($quotation_options['number']) && !empty($quotation_options['time_type']) ) { |
|
|
814
|
+ if (!empty($quotation_options) && !empty($quotation_options['number']) && !empty($quotation_options['time_type'])) { |
|
815
|
815
|
$timestamp_quotation = strtotime($quotation_date); |
|
816
|
816
|
$timestamp_validity_date_quotation = 0; |
|
817
|
817
|
$query = ''; |
|
818
|
818
|
$date = ''; |
|
819
|
819
|
global $wpdb; |
|
820
|
|
- switch ( $quotation_options['time_type'] ) { |
|
|
820
|
+ switch ($quotation_options['time_type']) { |
|
821
|
821
|
case 'day' : |
|
822
|
|
- $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " DAY) "); |
|
|
822
|
+ $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " DAY) "); |
|
823
|
823
|
break; |
|
824
|
824
|
case 'month' : |
|
825
|
|
- $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " MONTH) "); |
|
|
825
|
+ $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " MONTH) "); |
|
826
|
826
|
break; |
|
827
|
827
|
case 'year' : |
|
828
|
|
- $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " YEAR) "); |
|
|
828
|
+ $query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " YEAR) "); |
|
829
|
829
|
break; |
|
830
|
830
|
default : |
|
831
|
831
|
$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL 15 DAY) "); |
|
832
|
832
|
break; |
|
833
|
833
|
} |
|
834
|
|
- if ( $query != null) { |
|
|
834
|
+ if ($query != null) { |
|
835
|
835
|
$date = mysql2date('d F Y', $wpdb->get_var($query), true); |
|
836
|
836
|
} |
|
837
|
|
- return sprintf( __('Quotation validity date %s', 'wpshop'), $date ) ; |
|
|
837
|
+ return sprintf(__('Quotation validity date %s', 'wpshop'), $date); |
|
838
|
838
|
} |
|
839
|
839
|
} |
|
840
|
840
|
|
|
@@ -844,19 +844,19 @@ discard block |
|
|
block discarded – undo |
|
844
|
844
|
* @param string $invoice_ref |
|
845
|
845
|
* @return string |
|
846
|
846
|
*/ |
|
847
|
|
- public static function generate_invoice_for_email ( $order_id, $invoice_ref = '' ) { |
|
|
847
|
+ public static function generate_invoice_for_email($order_id, $invoice_ref = '') { |
|
848
|
848
|
/** Generate the PDF file for the invoice **/ |
|
849
|
849
|
$is_ok = false; |
|
850
|
|
- if ( !empty($invoice_ref) ) { |
|
851
|
|
- require_once(WPSHOP_LIBRAIRIES_DIR.'HTML2PDF/html2pdf.class.php'); |
|
|
850
|
+ if (!empty($invoice_ref)) { |
|
|
851
|
+ require_once(WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php'); |
|
852
|
852
|
try { |
|
853
|
|
- $html_content = wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref ); |
|
|
853
|
+ $html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref); |
|
854
|
854
|
$html_content = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>'; |
|
855
|
855
|
$html2pdf = new HTML2PDF('P', 'A4', 'fr'); |
|
856
|
856
|
|
|
857
|
857
|
$html2pdf->setDefaultFont('Arial'); |
|
858
|
858
|
$html2pdf->writeHTML($html_content); |
|
859
|
|
- $html2pdf->Output(WPSHOP_UPLOAD_DIR.$invoice_ref.'.pdf', 'F'); |
|
|
859
|
+ $html2pdf->Output(WPSHOP_UPLOAD_DIR . $invoice_ref . '.pdf', 'F'); |
|
860
|
860
|
$is_ok = true; |
|
861
|
861
|
} |
|
862
|
862
|
catch (HTML2PDF_exception $e) { |
|
@@ -864,7 +864,7 @@ discard block |
|
|
block discarded – undo |
|
864
|
864
|
exit; |
|
865
|
865
|
} |
|
866
|
866
|
} |
|
867
|
|
- return ( $is_ok ) ? WPSHOP_UPLOAD_DIR.$invoice_ref.'.pdf' : ''; |
|
|
867
|
+ return ($is_ok) ? WPSHOP_UPLOAD_DIR . $invoice_ref . '.pdf' : ''; |
|
868
|
868
|
} |
|
869
|
869
|
|
|
870
|
870
|
/** |
|
@@ -872,38 +872,38 @@ discard block |
|
|
block discarded – undo |
|
872
|
872
|
* @return Ambigous <string, string> |
|
873
|
873
|
*/ |
|
874
|
874
|
public static function generate_invoice_sender_part() { |
|
875
|
|
- $output =''; |
|
|
875
|
+ $output = ''; |
|
876
|
876
|
$company = get_option('wpshop_company_info', array()); |
|
877
|
877
|
$emails = get_option('wpshop_emails', array()); |
|
878
|
|
- if ( !empty($company) ) { |
|
879
|
|
- $tpl_component['COMPANY_EMAIL'] = ( !empty($emails) && !empty($emails['contact_email']) ) ? $emails['contact_email'] : ''; |
|
|
878
|
+ if (!empty($company)) { |
|
|
879
|
+ $tpl_component['COMPANY_EMAIL'] = (!empty($emails) && !empty($emails['contact_email'])) ? $emails['contact_email'] : ''; |
|
880
|
880
|
$tpl_component['COMPANY_WEBSITE'] = get_option('siteurl'); |
|
881
|
|
- foreach ( $company as $company_info_key => $company_info_value ) { |
|
|
881
|
+ foreach ($company as $company_info_key => $company_info_value) { |
|
882
|
882
|
switch ($company_info_key) { |
|
883
|
883
|
case 'company_rcs' : |
|
884
|
|
- $data = ( !empty($company_info_value) ) ? __('RCS', 'wpshop').' : '.$company_info_value : ''; |
|
|
884
|
+ $data = (!empty($company_info_value)) ? __('RCS', 'wpshop') . ' : ' . $company_info_value : ''; |
|
885
|
885
|
break; |
|
886
|
886
|
case 'company_capital' : |
|
887
|
|
- $data = ( !empty($company_info_value) ) ? __('Capital', 'wpshop').' : '.$company_info_value : ''; |
|
|
887
|
+ $data = (!empty($company_info_value)) ? __('Capital', 'wpshop') . ' : ' . $company_info_value : ''; |
|
888
|
888
|
break; |
|
889
|
889
|
case 'company_siren' : |
|
890
|
|
- $data = ( !empty($company_info_value) ) ? __('SIREN', 'wpshop').' : '.$company_info_value : ''; |
|
|
890
|
+ $data = (!empty($company_info_value)) ? __('SIREN', 'wpshop') . ' : ' . $company_info_value : ''; |
|
891
|
891
|
break; |
|
892
|
892
|
case 'company_siret' : |
|
893
|
|
- $data = ( !empty($company_info_value) ) ? __('SIRET', 'wpshop').' : '.$company_info_value : ''; |
|
|
893
|
+ $data = (!empty($company_info_value)) ? __('SIRET', 'wpshop') . ' : ' . $company_info_value : ''; |
|
894
|
894
|
break; |
|
895
|
895
|
case 'company_tva_intra' : |
|
896
|
|
- $data = ( !empty($company_info_value) ) ? __('TVA Intracommunautaire', 'wpshop').' : '.$company_info_value : ''; |
|
|
896
|
+ $data = (!empty($company_info_value)) ? __('TVA Intracommunautaire', 'wpshop') . ' : ' . $company_info_value : ''; |
|
897
|
897
|
break; |
|
898
|
898
|
case 'company_legal_statut' : |
|
899
|
899
|
$array_state_compagny = wpshop_company_options::get_legal_status(); |
|
900
|
|
- $data = ( !empty( $array_state_compagny ) && !empty( $array_state_compagny[$company_info_value] ) ) ? $array_state_compagny[$company_info_value] : __( 'Auto-Entrepreneur', 'wpshop' ) ; |
|
|
900
|
+ $data = (!empty($array_state_compagny) && !empty($array_state_compagny[$company_info_value])) ? $array_state_compagny[$company_info_value] : __('Auto-Entrepreneur', 'wpshop'); |
|
901
|
901
|
break; |
|
902
|
902
|
default : |
|
903
|
903
|
$data = $company_info_value; |
|
904
|
904
|
break; |
|
905
|
905
|
} |
|
906
|
|
- $tpl_component[ strtoupper( $company_info_key) ] = $data; |
|
|
906
|
+ $tpl_component[strtoupper($company_info_key)] = $data; |
|
907
|
907
|
} |
|
908
|
908
|
$output = wpshop_display::display_template_element('invoice_sender_formatted_address', $tpl_component, array(), 'common'); |
|
909
|
909
|
} |
|
@@ -916,57 +916,57 @@ discard block |
|
|
block discarded – undo |
|
916
|
916
|
* @param unknown_type $bon_colisage |
|
917
|
917
|
* @return Ambigous <string, string> |
|
918
|
918
|
*/ |
|
919
|
|
- public static function generate_receiver_part( $order_id, $bon_colisage = false ) { |
|
|
919
|
+ public static function generate_receiver_part($order_id, $bon_colisage = false) { |
|
920
|
920
|
$output = ''; |
|
921
|
921
|
$order_customer_postmeta = get_post_meta($order_id, '_order_info', true); |
|
922
|
|
- $order_postmeta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
|
922
|
+ $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
|
923
|
923
|
|
|
924
|
|
- if( $bon_colisage && !empty($order_customer_postmeta['shipping']) && !empty($order_customer_postmeta['shipping']['address']) && is_array($order_customer_postmeta['shipping']['address']) ) { |
|
|
924
|
+ if ($bon_colisage && !empty($order_customer_postmeta['shipping']) && !empty($order_customer_postmeta['shipping']['address']) && is_array($order_customer_postmeta['shipping']['address'])) { |
|
925
|
925
|
$address_info = $order_customer_postmeta['shipping']['address']; |
|
926
|
926
|
} else { |
|
927
|
|
- if( !empty($order_customer_postmeta['billing']) && !empty($order_customer_postmeta['billing']['address']) && is_array($order_customer_postmeta['billing']['address']) ) { |
|
|
927
|
+ if (!empty($order_customer_postmeta['billing']) && !empty($order_customer_postmeta['billing']['address']) && is_array($order_customer_postmeta['billing']['address'])) { |
|
928
|
928
|
$address_info = $order_customer_postmeta['billing']['address']; |
|
929
|
929
|
} else { |
|
930
|
930
|
$address_info = array(); |
|
931
|
931
|
} |
|
932
|
932
|
} |
|
933
|
933
|
|
|
934
|
|
- if ( !empty($order_customer_postmeta) && !empty($address_info) ) { |
|
|
934
|
+ if (!empty($order_customer_postmeta) && !empty($address_info)) { |
|
935
|
935
|
$default_address_attributes = array('CIVILITY', 'ADDRESS_LAST_NAME', 'ADDRESS_FIRST_NAME', 'ADDRESS', 'POSTCODE', 'CITY', 'STATE', 'COUNTRY', 'PHONE', 'ADDRESS_USER_EMAIL', 'COMPANY'); |
|
936
|
|
- foreach ( $default_address_attributes as $default_address_attribute ) { |
|
|
936
|
+ foreach ($default_address_attributes as $default_address_attribute) { |
|
937
|
937
|
$tpl_component[$default_address_attribute] = ''; |
|
938
|
938
|
} |
|
939
|
939
|
|
|
940
|
|
- foreach ( $address_info as $order_customer_info_key => $order_customer_info_value ) { |
|
|
940
|
+ foreach ($address_info as $order_customer_info_key => $order_customer_info_value) { |
|
941
|
941
|
$tpl_component[strtoupper($order_customer_info_key)] = ''; |
|
942
|
|
- if ( $order_customer_info_key == 'civility') { |
|
|
942
|
+ if ($order_customer_info_key == 'civility') { |
|
943
|
943
|
global $wpdb; |
|
944
|
|
- $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id= %d', $order_customer_info_value); |
|
|
944
|
+ $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $order_customer_info_value); |
|
945
|
945
|
$civility = $wpdb->get_row($query); |
|
946
|
|
- $tpl_component[strtoupper($order_customer_info_key)] = (!empty($civility) ) ? (!empty($civility->label)) ? $civility->label : __($civility->value, 'wpshop') : ''; |
|
|
946
|
+ $tpl_component[strtoupper($order_customer_info_key)] = (!empty($civility)) ? (!empty($civility->label)) ? $civility->label : __($civility->value, 'wpshop') : ''; |
|
947
|
947
|
} |
|
948
|
|
- else if( $order_customer_info_key == 'country') { |
|
|
948
|
+ else if ($order_customer_info_key == 'country') { |
|
949
|
949
|
foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key=>$value) { |
|
950
|
|
- if ( $order_customer_info_value == $key) { |
|
|
950
|
+ if ($order_customer_info_value == $key) { |
|
951
|
951
|
$tpl_component[strtoupper($order_customer_info_key)] = $value; |
|
952
|
952
|
} |
|
953
|
953
|
} |
|
954
|
954
|
} |
|
955
|
|
- elseif( $order_customer_info_key == 'phone' ){ |
|
956
|
|
- $tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? __('Phone', 'wpshop').' : '.$order_customer_info_value : ''; |
|
|
955
|
+ elseif ($order_customer_info_key == 'phone') { |
|
|
956
|
+ $tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value)) ? __('Phone', 'wpshop') . ' : ' . $order_customer_info_value : ''; |
|
957
|
957
|
} |
|
958
|
958
|
else { |
|
959
|
|
- $tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? $order_customer_info_value : ''; |
|
|
959
|
+ $tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value)) ? $order_customer_info_value : ''; |
|
960
|
960
|
} |
|
961
|
961
|
} |
|
962
|
962
|
|
|
963
|
|
- if ( empty($tpl_component['PHONE']) ) { |
|
964
|
|
- $tpl_component['PHONE'] = ( !empty( $order_customer_postmeta['billing']['address']['phone']) ) ? __('Phone', 'wpshop').' : '.$order_customer_postmeta['billing']['address']['phone'] : ''; |
|
|
963
|
+ if (empty($tpl_component['PHONE'])) { |
|
|
964
|
+ $tpl_component['PHONE'] = (!empty($order_customer_postmeta['billing']['address']['phone'])) ? __('Phone', 'wpshop') . ' : ' . $order_customer_postmeta['billing']['address']['phone'] : ''; |
|
965
|
965
|
} |
|
966
|
966
|
|
|
967
|
|
- if ( empty($tpl_component['ADDRESS_USER_EMAIL']) || ( empty($tpl_component['ADDRESS_USER_EMAIL']) && $bon_colisage ) ){ |
|
968
|
|
- $user_info = get_userdata( $order_postmeta['customer_id'] ); |
|
969
|
|
- $tpl_component['ADDRESS_USER_EMAIL'] = ( !empty($user_info) && !empty($user_info->user_email) ) ? $user_info->user_email : ''; |
|
|
967
|
+ if (empty($tpl_component['ADDRESS_USER_EMAIL']) || (empty($tpl_component['ADDRESS_USER_EMAIL']) && $bon_colisage)) { |
|
|
968
|
+ $user_info = get_userdata($order_postmeta['customer_id']); |
|
|
969
|
+ $tpl_component['ADDRESS_USER_EMAIL'] = (!empty($user_info) && !empty($user_info->user_email)) ? $user_info->user_email : ''; |
|
970
|
970
|
} |
|
971
|
971
|
|
|
972
|
972
|
|
|
@@ -980,36 +980,36 @@ discard block |
|
|
block discarded – undo |
|
980
|
980
|
* Genrate Footer invoice |
|
981
|
981
|
* @return Ambigous <string, string> |
|
982
|
982
|
*/ |
|
983
|
|
- public static function generate_footer_invoice(){ |
|
984
|
|
- $output =''; |
|
|
983
|
+ public static function generate_footer_invoice() { |
|
|
984
|
+ $output = ''; |
|
985
|
985
|
$company = get_option('wpshop_company_info', array()); |
|
986
|
986
|
$emails = get_option('wpshop_emails', array()); |
|
987
|
|
- if ( !empty($company) ) { |
|
988
|
|
- $tpl_component['COMPANY_EMAIL'] = ( !empty($emails) && !empty($emails['contact_email']) ) ? $emails['contact_email'] : ''; |
|
|
987
|
+ if (!empty($company)) { |
|
|
988
|
+ $tpl_component['COMPANY_EMAIL'] = (!empty($emails) && !empty($emails['contact_email'])) ? $emails['contact_email'] : ''; |
|
989
|
989
|
$tpl_component['COMPANY_WEBSITE'] = site_url(); |
|
990
|
|
- foreach ( $company as $company_info_key => $company_info_value ) { |
|
|
990
|
+ foreach ($company as $company_info_key => $company_info_value) { |
|
991
|
991
|
|
|
992
|
992
|
switch ($company_info_key) { |
|
993
|
993
|
case 'company_rcs' : |
|
994
|
|
- $data = ( !empty($company_info_value) ) ? __('RCS', 'wpshop').' : '.$company_info_value : ''; |
|
|
994
|
+ $data = (!empty($company_info_value)) ? __('RCS', 'wpshop') . ' : ' . $company_info_value : ''; |
|
995
|
995
|
break; |
|
996
|
996
|
case 'company_capital' : |
|
997
|
|
- $data = ( !empty($company_info_value) ) ? __('Capital', 'wpshop').' : '.$company_info_value : ''; |
|
|
997
|
+ $data = (!empty($company_info_value)) ? __('Capital', 'wpshop') . ' : ' . $company_info_value : ''; |
|
998
|
998
|
break; |
|
999
|
999
|
case 'company_siren' : |
|
1000
|
|
- $data = ( !empty($company_info_value) ) ? __('SIREN', 'wpshop').' : '.$company_info_value : ''; |
|
|
1000
|
+ $data = (!empty($company_info_value)) ? __('SIREN', 'wpshop') . ' : ' . $company_info_value : ''; |
|
1001
|
1001
|
break; |
|
1002
|
1002
|
case 'company_siret' : |
|
1003
|
|
- $data = ( !empty($company_info_value) ) ? __('SIRET', 'wpshop').' : '.$company_info_value : ''; |
|
|
1003
|
+ $data = (!empty($company_info_value)) ? __('SIRET', 'wpshop') . ' : ' . $company_info_value : ''; |
|
1004
|
1004
|
break; |
|
1005
|
1005
|
case 'company_tva_intra' : |
|
1006
|
|
- $data = ( !empty($company_info_value) ) ? __('TVA Intracommunautaire', 'wpshop').' : '.$company_info_value : ''; |
|
|
1006
|
+ $data = (!empty($company_info_value)) ? __('TVA Intracommunautaire', 'wpshop') . ' : ' . $company_info_value : ''; |
|
1007
|
1007
|
break; |
|
1008
|
1008
|
default : |
|
1009
|
1009
|
$data = $company_info_value; |
|
1010
|
1010
|
break; |
|
1011
|
1011
|
} |
|
1012
|
|
- $tpl_component[ strtoupper( $company_info_key) ] = $data; |
|
|
1012
|
+ $tpl_component[strtoupper($company_info_key)] = $data; |
|
1013
|
1013
|
} |
|
1014
|
1014
|
$output = wpshop_display::display_template_element('invoice_footer', $tpl_component, array(), 'common'); |
|
1015
|
1015
|
} |
|
@@ -1025,33 +1025,33 @@ discard block |
|
|
block discarded – undo |
|
1025
|
1025
|
* @param id $product_id |
|
1026
|
1026
|
* @param string $invoice_ref |
|
1027
|
1027
|
*/ |
|
1028
|
|
- public static function check_product_price( $price_ht, $price_ati, $tva_amount, $tva_rate, $product_id, $invoice_ref, $order_id ) { |
|
|
1028
|
+ public static function check_product_price($price_ht, $price_ati, $tva_amount, $tva_rate, $product_id, $invoice_ref, $order_id) { |
|
1029
|
1029
|
$checking = true; |
|
1030
|
|
- $error_percent = 1; |
|
|
1030
|
+ $error_percent = 1; |
|
1031
|
1031
|
|
|
1032
|
1032
|
/** Check VAT Amount **/ |
|
1033
|
|
- $formatted_tva_amount = number_format( $tva_amount, 2, '.', '' ); |
|
1034
|
|
- $formatted_price_ht = number_format( $price_ht, 2, '.', '' ); |
|
1035
|
|
- $formatted_price_ati = number_format( $price_ati, 2, '.', '' ); |
|
1036
|
|
- $calculated_price_excluding_tax = $price_ati / ( 1 + ($tva_rate / 100) ); |
|
|
1033
|
+ $formatted_tva_amount = number_format($tva_amount, 2, '.', ''); |
|
|
1034
|
+ $formatted_price_ht = number_format($price_ht, 2, '.', ''); |
|
|
1035
|
+ $formatted_price_ati = number_format($price_ati, 2, '.', ''); |
|
|
1036
|
+ $calculated_price_excluding_tax = $price_ati / (1 + ($tva_rate / 100)); |
|
1037
|
1037
|
$unformatted = $formatted_price_ati - $calculated_price_excluding_tax; |
|
1038
|
|
- $checked_tva_amount = number_format( $unformatted, 2, '.', '' ); |
|
|
1038
|
+ $checked_tva_amount = number_format($unformatted, 2, '.', ''); |
|
1039
|
1039
|
|
|
1040
|
|
- if ( ( $checked_tva_amount < ($formatted_tva_amount / ( 1 + ($error_percent / 100) ) ) ) || ( $checked_tva_amount > ($formatted_tva_amount * (1 + ($error_percent / 100) ) ) ) ) { |
|
|
1040
|
+ if (($checked_tva_amount < ($formatted_tva_amount / (1 + ($error_percent / 100)))) || ($checked_tva_amount > ($formatted_tva_amount * (1 + ($error_percent / 100))))) { |
|
1041
|
1041
|
$error_infos = array(); |
|
1042
|
|
- $error_infos['real_datas']['price_ati'] = $formatted_price_ati; |
|
1043
|
|
- $error_infos['real_datas']['price_ht'] = $formatted_price_ht; |
|
1044
|
|
- $error_infos['real_datas']['tva_amount'] = $formatted_tva_amount; |
|
|
1042
|
+ $error_infos['real_datas']['price_ati'] = $formatted_price_ati; |
|
|
1043
|
+ $error_infos['real_datas']['price_ht'] = $formatted_price_ht; |
|
|
1044
|
+ $error_infos['real_datas']['tva_amount'] = $formatted_tva_amount; |
|
1045
|
1045
|
|
|
1046
|
1046
|
$error_infos['corrected_data'] = $checked_tva_amount; |
|
1047
|
|
- self::invoice_error_check_administrator( $invoice_ref, __('VAT error', 'wpshop'), $product_id, $order_id, $error_infos ); |
|
|
1047
|
+ self::invoice_error_check_administrator($invoice_ref, __('VAT error', 'wpshop'), $product_id, $order_id, $error_infos); |
|
1048
|
1048
|
$checking = false; |
|
1049
|
1049
|
} |
|
1050
|
1050
|
|
|
1051
|
1051
|
/** Check price ati **/ |
|
1052
|
|
- $checked_price_ati = $formatted_price_ht * ( 1 + ( $tva_rate / 100) ); |
|
1053
|
|
- if ( ( $checked_price_ati < ($formatted_price_ati /( 1 + ($error_percent / 100) ) ) ) || ( $checked_price_ati > ($formatted_price_ati * (1 + ($error_percent / 100)) ) ) ) { |
|
1054
|
|
- self::invoice_error_check_administrator( $invoice_ref, __('ATI Price error', 'wpshop'), $product_id, $order_id ); |
|
|
1052
|
+ $checked_price_ati = $formatted_price_ht * (1 + ($tva_rate / 100)); |
|
|
1053
|
+ if (($checked_price_ati < ($formatted_price_ati / (1 + ($error_percent / 100)))) || ($checked_price_ati > ($formatted_price_ati * (1 + ($error_percent / 100))))) { |
|
|
1054
|
+ self::invoice_error_check_administrator($invoice_ref, __('ATI Price error', 'wpshop'), $product_id, $order_id); |
|
1055
|
1055
|
$checking = false; |
|
1056
|
1056
|
} |
|
1057
|
1057
|
|
|
@@ -1064,29 +1064,29 @@ discard block |
|
|
block discarded – undo |
|
1064
|
1064
|
* @param string $object |
|
1065
|
1065
|
* @param unknown_type $product_id |
|
1066
|
1066
|
*/ |
|
1067
|
|
- function invoice_error_check_administrator( $invoice_ref, $object, $product_id, $order_id, $errors_infos = array() ) { |
|
1068
|
|
- $wpshop_email_option = get_option( 'wpshop_emails'); |
|
1069
|
|
- if ( !empty($wpshop_email_option) && !empty($wpshop_email_option['contact_email']) ) { |
|
|
1067
|
+ function invoice_error_check_administrator($invoice_ref, $object, $product_id, $order_id, $errors_infos = array()) { |
|
|
1068
|
+ $wpshop_email_option = get_option('wpshop_emails'); |
|
|
1069
|
+ if (!empty($wpshop_email_option) && !empty($wpshop_email_option['contact_email'])) { |
|
1070
|
1070
|
$headers = "MIME-Version: 1.0\r\n"; |
|
1071
|
1071
|
$headers .= "Content-type: text/html; charset=UTF-8\r\n"; |
|
1072
|
|
- $headers .= 'From: '.get_bloginfo('name').' <'.$wpshop_email_option['noreply_email'].'>' . "\r\n"; |
|
1073
|
|
- $message = '<b>'.__('Error type', 'wpshop').' : </b>'.$object.'<br/>'; |
|
1074
|
|
- $message .= '<b>'.__( 'Product', 'wpshop').' : </b>'.get_the_title( $product_id ).'<br/>'; |
|
1075
|
|
- $message .= '<b>'.__( 'Invoice ref', 'wpshop').' : </b>'.$invoice_ref.'<br/>'; |
|
1076
|
|
- $message .= '<b>'.__( 'Order ID', 'wpshop').' : </b>'.$order_id.'<br/>'; |
|
1077
|
|
- |
|
1078
|
|
- if ( !empty($errors_infos) && !empty($errors_infos['real_datas']) ) { |
|
1079
|
|
- $message .='<b>' .__( 'Bad datas', 'wpshop').' :</b> <ul>'; |
|
1080
|
|
- foreach( $errors_infos['real_datas'] as $k => $errors_info ) { |
|
1081
|
|
- $message .= '<li><b>'.$k.' : </b>'.$errors_info.'</li>'; |
|
|
1072
|
+ $headers .= 'From: ' . get_bloginfo('name') . ' <' . $wpshop_email_option['noreply_email'] . '>' . "\r\n"; |
|
|
1073
|
+ $message = '<b>' . __('Error type', 'wpshop') . ' : </b>' . $object . '<br/>'; |
|
|
1074
|
+ $message .= '<b>' . __('Product', 'wpshop') . ' : </b>' . get_the_title($product_id) . '<br/>'; |
|
|
1075
|
+ $message .= '<b>' . __('Invoice ref', 'wpshop') . ' : </b>' . $invoice_ref . '<br/>'; |
|
|
1076
|
+ $message .= '<b>' . __('Order ID', 'wpshop') . ' : </b>' . $order_id . '<br/>'; |
|
|
1077
|
+ |
|
|
1078
|
+ if (!empty($errors_infos) && !empty($errors_infos['real_datas'])) { |
|
|
1079
|
+ $message .= '<b>' . __('Bad datas', 'wpshop') . ' :</b> <ul>'; |
|
|
1080
|
+ foreach ($errors_infos['real_datas'] as $k => $errors_info) { |
|
|
1081
|
+ $message .= '<li><b>' . $k . ' : </b>' . $errors_info . '</li>'; |
|
1082
|
1082
|
} |
|
1083
|
1083
|
$message .= '</ul>'; |
|
1084
|
|
- if ( !empty($errors_infos['corrected_data']) ) { |
|
1085
|
|
- $message .= '<b>' . __( 'Good value', 'wpshop' ) . ' : </b>' . $errors_infos['corrected_data']; |
|
|
1084
|
+ if (!empty($errors_infos['corrected_data'])) { |
|
|
1085
|
+ $message .= '<b>' . __('Good value', 'wpshop') . ' : </b>' . $errors_infos['corrected_data']; |
|
1086
|
1086
|
} |
|
1087
|
1087
|
} |
|
1088
|
1088
|
|
|
1089
|
|
- wp_mail( $wpshop_email_option['contact_email'], __('Error on invoice generation', 'wpshop') , $message, $headers); |
|
|
1089
|
+ wp_mail($wpshop_email_option['contact_email'], __('Error on invoice generation', 'wpshop'), $message, $headers); |
|
1090
|
1090
|
} |
|
1091
|
1091
|
} |
|
1092
|
1092
|
|
|
@@ -1096,9 +1096,9 @@ discard block |
|
|
block discarded – undo |
|
1096
|
1096
|
* @param array $posted_datas |
|
1097
|
1097
|
* @return string |
|
1098
|
1098
|
*/ |
|
1099
|
|
- function force_invoice_generation_on_order( $order_metadata, $posted_datas ) { |
|
1100
|
|
- if ( !empty ($posted_datas['action_triggered_from']) && $posted_datas['action_triggered_from'] == 'generate_invoice') { |
|
1101
|
|
- $order_metadata['order_invoice_ref'] = $this->generate_invoice_number( $posted_datas['post_ID'] ); |
|
|
1099
|
+ function force_invoice_generation_on_order($order_metadata, $posted_datas) { |
|
|
1100
|
+ if (!empty ($posted_datas['action_triggered_from']) && $posted_datas['action_triggered_from'] == 'generate_invoice') { |
|
|
1101
|
+ $order_metadata['order_invoice_ref'] = $this->generate_invoice_number($posted_datas['post_ID']); |
|
1102
|
1102
|
} |
|
1103
|
1103
|
return $order_metadata; |
|
1104
|
1104
|
} |
|
@@ -1113,12 +1113,12 @@ discard block |
|
|
block discarded – undo |
|
1113
|
1113
|
$partial_payment_current_config = get_option('wpshop_payment_partial', array('for_quotation' => array())); |
|
1114
|
1114
|
|
|
1115
|
1115
|
$partial_for_quotation_is_activate = false; |
|
1116
|
|
- if ( !empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_quotation']) && !empty($partial_payment_current_config['for_quotation']['activate']) ) { |
|
|
1116
|
+ if (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_quotation']) && !empty($partial_payment_current_config['for_quotation']['activate'])) { |
|
1117
|
1117
|
$partial_for_quotation_is_activate = true; |
|
1118
|
1118
|
} |
|
1119
|
1119
|
|
|
1120
|
1120
|
$output .= ' |
|
1121
|
|
- <input type="checkbox" name="wpshop_payment_partial[for_quotation][activate]"' . ($partial_for_quotation_is_activate ? ' checked="checked"' : '') . ' id="wpshop_payment_partial_on_quotation_activation_state" /> <label for="wpshop_payment_partial_on_quotation_activation_state" >' . __('Activate partial command for quotations', 'wpshop') . '</label><a href="#" title="'.__('If you want that customer pay a part o f total amount of there order, check this box then fill fields below','wpshop').'" class="wpshop_infobulle_marker">?</a> |
|
|
1121
|
+ <input type="checkbox" name="wpshop_payment_partial[for_quotation][activate]"' . ($partial_for_quotation_is_activate ? ' checked="checked"' : '') . ' id="wpshop_payment_partial_on_quotation_activation_state" /> <label for="wpshop_payment_partial_on_quotation_activation_state" >' . __('Activate partial command for quotations', 'wpshop') . '</label><a href="#" title="' . __('If you want that customer pay a part o f total amount of there order, check this box then fill fields below', 'wpshop') . '" class="wpshop_infobulle_marker">?</a> |
|
1122
|
1122
|
<div class="wpshop_partial_payment_quotation_config_container' . ($partial_for_quotation_is_activate ? '' : ' wpshopHide') . '" id="wpshop_partial_payment_quotation_config_container" > |
|
1123
|
1123
|
<div class="alignleft" > |
|
1124
|
1124
|
' . __('Value of partial payment', 'wpshop') . '<br/> |
|
@@ -1140,6 +1140,6 @@ discard block |
|
|
block discarded – undo |
|
1140
|
1140
|
} |
|
1141
|
1141
|
|
|
1142
|
1142
|
/** Instanciate the module utilities if not */ |
|
1143
|
|
-if ( class_exists("wpshop_modules_billing") ) { |
|
|
1143
|
+if (class_exists("wpshop_modules_billing")) { |
|
1144
|
1144
|
$wpshop_modules_billing = new wpshop_modules_billing(); |
|
1145
|
1145
|
} |