Completed
Pull Request — master (#2)
by Jimmy
1075:13 queued 1053:53
created
includes/librairies/install.class.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param integer $i The wpshop db version to execute operation for
282 282
 	 *
283
-	 * @return boolean
283
+	 * @return boolean|null
284 284
 	 */
285 285
 	public static function execute_operation_on_db_for_update($i){
286 286
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_content_add, $wpshop_db_content_update, $wpshop_db_options_add, $wpshop_eav_content, $wpshop_eav_content_update, $wpshop_db_options_update, $wpshop_db_request, $wpshop_db_delete;
@@ -547,6 +547,7 @@  discard block
 block discarded – undo
547 547
 
548 548
 	/**
549 549
 	 * Manage special operation on wpshop plugin update
550
+	 * @param integer $version
550 551
 	 */
551 552
 	public static function make_specific_operation_on_update($version){
552 553
 		global $wpdb, $wp_rewrite;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 class wpshop_install {
24 24
 
25 25
 	/**
26
-	*	Define the action launch when plugin is activate
27
-	*
28
-	* @return void
29
-	*/
26
+	 *	Define the action launch when plugin is activate
27
+	 *
28
+	 * @return void
29
+	 */
30 30
 	public static function install_on_activation(){
31 31
 		/*	Create the different option needed for the plugin work properly	*/
32 32
 		add_option('wpshop_db_options', array('db_version' => 0));
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @param array $eav_content The complete array with all element to create into database
444 444
 	 * @param boolean $do_changes The current state of changes to do
445
-	 	*
445
+	 *
446 446
 	 * @return boolean If there are changes to do or not
447 447
 	 */
448 448
 	public static function update_eav_content( $eav_content, $do_changes ) {
Please login to merge, or discard this patch.
Spacing   +589 added lines, -589 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	*
28 28
 	* @return void
29 29
 	*/
30
-	public static function install_on_activation(){
30
+	public static function install_on_activation() {
31 31
 		/*	Create the different option needed for the plugin work properly	*/
32 32
 		add_option('wpshop_db_options', array('db_version' => 0));
33 33
 		add_option('wpshop_shop_default_currency', WPSHOP_SHOP_DEFAULT_CURRENCY);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 *	Create the default pages
42 42
 	 */
43
-	public static function wpshop_insert_default_pages( $pages_type = '' ) {
43
+	public static function wpshop_insert_default_pages($pages_type = '') {
44 44
 		global $wpdb, $wp_rewrite;
45 45
 
46 46
 		/**	if we will create any new pages we need to flush page cache */
@@ -57,48 +57,48 @@  discard block
 block discarded – undo
57 57
 		);
58 58
 
59 59
 		/**	Get defined shop type	*/
60
-		$wpshop_shop_type = !empty( $pages_type ) ? $pages_type : get_option( 'wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE );
60
+		$wpshop_shop_type = !empty($pages_type) ? $pages_type : get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
61 61
 
62 62
 		/**	Get the default datas for installation - Pages	*/
63
-		$xml_default_pages = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml' );
64
-		$defined_default_pages = new SimpleXMLElement( $xml_default_pages );
65
-		foreach ( $defined_default_pages->xpath( '//pages/page' ) as $page ) {
66
-			if ( ( $wpshop_shop_type == $page->attributes()->shop_type ) || ( 'sale' == $wpshop_shop_type ) ) {
63
+		$xml_default_pages = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_pages.xml');
64
+		$defined_default_pages = new SimpleXMLElement($xml_default_pages);
65
+		foreach ($defined_default_pages->xpath('//pages/page') as $page) {
66
+			if (($wpshop_shop_type == $page->attributes()->shop_type) || ('sale' == $wpshop_shop_type)) {
67 67
 				$page_id = null;
68 68
 
69 69
 				/**	Do a specific check for cart page, for old wpshop installation	*/
70
-				if ( 'wpshop_cart_page_id' == (string)$page->attributes()->code ) {
70
+				if ('wpshop_cart_page_id' == (string)$page->attributes()->code) {
71 71
 					$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_content LIKE %s	AND post_type != %s", '%[wpshop_basket]%', 'revision');
72 72
 					$page_id = $wpdb->get_var($query);
73 73
 
74
-					wp_update_post( array(
74
+					wp_update_post(array(
75 75
 						'ID' => $page_id,
76 76
 						'post_content' => (string)$page->content,
77
-					) );
77
+					));
78 78
 				}
79 79
 
80 80
 				/**	Check if a page exists with the current content readed form xml file	*/
81
-				if ( empty( $page_id ) ) {
81
+				if (empty($page_id)) {
82 82
 					$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE %s AND post_type != %s", '%' . (string)$page->content . '%', 'revision');
83 83
 					$page_id = $wpdb->get_var($query);
84 84
 				}
85 85
 
86 86
 				/**	If the page does not exists create it	*/
87
-				if ( empty( $page_id ) ) {
88
-					$default_page_args  = wp_parse_args( array(
89
-						'post_title' 	=> __( (string)$page->title, 'wpshop' ),
90
-						'post_name' 	=> __( (string)$page->slug, 'wpshop' ),
91
-						'post_content' 	=> __( (string)$page->content, 'wpshop' ),
87
+				if (empty($page_id)) {
88
+					$default_page_args = wp_parse_args(array(
89
+						'post_title' 	=> __((string)$page->title, 'wpshop'),
90
+						'post_name' 	=> __((string)$page->slug, 'wpshop'),
91
+						'post_content' 	=> __((string)$page->content, 'wpshop'),
92 92
 						'menu_order' 	=> (string)$page->attributes()->position,
93
-					), $page_default_args );
93
+					), $page_default_args);
94 94
 
95
-					$page_id = wp_insert_post( $default_page_args );
95
+					$page_id = wp_insert_post($default_page_args);
96 96
 					$created_pages[] = (string)$page->attributes()->code;
97 97
 				}
98 98
 
99 99
 				/**	If the page is created or already exists associated the page to the good service	*/
100
-				if ( !empty( $page_id ) ) {
101
-					add_option( (string)$page->attributes()->code, $page_id );
100
+				if (!empty($page_id)) {
101
+					add_option((string)$page->attributes()->code, $page_id);
102 102
 
103 103
 					$page_creation = true;
104 104
 				}
@@ -107,18 +107,18 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 
109 109
 		/**	Check if page have been created in order to do specific action	*/
110
-		if ( !empty( $created_pages ) ) {
110
+		if (!empty($created_pages)) {
111 111
 			/**	If cart page and checkout page have just been created, change cart page id into checkout page id	*/
112
-			if ( in_array( 'wpshop_cart_page_id', $created_pages ) && in_array( 'wpshop_checkout_page_id', $created_pages ) ) {
113
-				update_option( 'wpshop_cart_page_id', get_option( 'wpshop_checkout_page_id' ) );
112
+			if (in_array('wpshop_cart_page_id', $created_pages) && in_array('wpshop_checkout_page_id', $created_pages)) {
113
+				update_option('wpshop_cart_page_id', get_option('wpshop_checkout_page_id'));
114 114
 			}
115 115
 
116 116
 		}
117 117
 
118 118
 		wp_cache_flush();
119 119
 		/** If new page => empty cache */
120
-		if ( $page_creation ) {
121
-			wp_cache_delete( 'all_page_ids', 'pages' );
120
+		if ($page_creation) {
121
+			wp_cache_delete('all_page_ids', 'pages');
122 122
 		//	$wp_rewrite->flush_rules();
123 123
 		}
124 124
 	}
@@ -138,54 +138,54 @@  discard block
 block discarded – undo
138 138
 		);
139 139
 
140 140
 		/**	Get the default datas for installation - sample products	*/
141
-		$sample_datas = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/sample_datas.xml' );
142
-		$defined_sample_datas = new SimpleXMLElement( $sample_datas, LIBXML_NOCDATA );
141
+		$sample_datas = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/sample_datas.xml');
142
+		$defined_sample_datas = new SimpleXMLElement($sample_datas, LIBXML_NOCDATA);
143 143
 
144 144
 		$namespaces = $defined_sample_datas->getDocNamespaces();
145
-		if ( ! isset( $namespaces['wp'] ) )
145
+		if (!isset($namespaces['wp']))
146 146
 			$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
147
-		if ( ! isset( $namespaces['excerpt'] ) )
147
+		if (!isset($namespaces['excerpt']))
148 148
 			$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
149 149
 
150
-		foreach ( $defined_sample_datas->xpath( '//wpshop_products/wpshop_product' ) as $product ) {
151
-			$dc = $product->children( 'http://purl.org/dc/elements/1.1/' );
152
-			$content = $product->children( 'http://purl.org/rss/1.0/modules/content/' );
153
-			$excerpt = $product->children( $namespaces['excerpt'] );
154
-			$wp = $product->children( $namespaces['wp'] );
150
+		foreach ($defined_sample_datas->xpath('//wpshop_products/wpshop_product') as $product) {
151
+			$dc = $product->children('http://purl.org/dc/elements/1.1/');
152
+			$content = $product->children('http://purl.org/rss/1.0/modules/content/');
153
+			$excerpt = $product->children($namespaces['excerpt']);
154
+			$wp = $product->children($namespaces['wp']);
155 155
 
156
-			$product_args  = wp_parse_args( array(
156
+			$product_args = wp_parse_args(array(
157 157
 				'post_title' => (string)$product->title,
158
-				'post_name' => (string) $wp->post_name,
159
-				'post_content' => (string) $content->encoded,
160
-				'post_excerpt' => (string) $excerpt->encoded,
161
-				'post_type' => (string) $wp->post_type,
162
-			), $product_default_args );
158
+				'post_name' => (string)$wp->post_name,
159
+				'post_content' => (string)$content->encoded,
160
+				'post_excerpt' => (string)$excerpt->encoded,
161
+				'post_type' => (string)$wp->post_type,
162
+			), $product_default_args);
163 163
 
164
-			$product_id = wp_insert_post( $product_args );
164
+			$product_id = wp_insert_post($product_args);
165 165
 
166
-			foreach ( $wp->postmeta as $meta ) {
167
-				update_post_meta( $product_id, (string)$meta->meta_key, (string)$meta->meta_value);
166
+			foreach ($wp->postmeta as $meta) {
167
+				update_post_meta($product_id, (string)$meta->meta_key, (string)$meta->meta_value);
168 168
 			}
169 169
 
170
-			foreach ( $defined_sample_datas->xpath( '//wps_pdt_variations/wps_pdt_variation/wp:post_parent[. ="' . $wp->post_id . '"]/parent::*' ) as $product_variation ) {
171
-				$wps_pdt_var_dc = $product_variation->children( 'http://purl.org/dc/elements/1.1/' );
172
-				$wps_pdt_var_content = $product_variation->children( 'http://purl.org/rss/1.0/modules/content/' );
173
-				$wps_pdt_var_excerpt = $product_variation->children( $namespaces['excerpt'] );
174
-				$wps_pdt_var_wp = $product_variation->children( $namespaces['wp'] );
170
+			foreach ($defined_sample_datas->xpath('//wps_pdt_variations/wps_pdt_variation/wp:post_parent[. ="' . $wp->post_id . '"]/parent::*') as $product_variation) {
171
+				$wps_pdt_var_dc = $product_variation->children('http://purl.org/dc/elements/1.1/');
172
+				$wps_pdt_var_content = $product_variation->children('http://purl.org/rss/1.0/modules/content/');
173
+				$wps_pdt_var_excerpt = $product_variation->children($namespaces['excerpt']);
174
+				$wps_pdt_var_wp = $product_variation->children($namespaces['wp']);
175 175
 
176
-				$product_args  = wp_parse_args( array(
176
+				$product_args = wp_parse_args(array(
177 177
 						'post_title' => (string)$product_variation->title,
178
-						'post_name' => (string) $wps_pdt_var_wp->post_name,
179
-						'post_content' => (string) $wps_pdt_var_content->encoded,
180
-						'post_excerpt' => (string) $wps_pdt_var_excerpt->encoded,
181
-						'post_type' => (string) $wps_pdt_var_wp->post_type,
178
+						'post_name' => (string)$wps_pdt_var_wp->post_name,
179
+						'post_content' => (string)$wps_pdt_var_content->encoded,
180
+						'post_excerpt' => (string)$wps_pdt_var_excerpt->encoded,
181
+						'post_type' => (string)$wps_pdt_var_wp->post_type,
182 182
 						'post_parent' => $product_id,
183
-				), $product_default_args );
183
+				), $product_default_args);
184 184
 
185
-				$product_variation_id = wp_insert_post( $product_args );
185
+				$product_variation_id = wp_insert_post($product_args);
186 186
 
187
-				foreach ( $wps_pdt_var_wp->postmeta as $meta ) {
188
-					update_post_meta( $product_variation_id, (string)$meta->meta_key, (string)$meta->meta_value);
187
+				foreach ($wps_pdt_var_wp->postmeta as $meta) {
188
+					update_post_meta($product_variation_id, (string)$meta->meta_key, (string)$meta->meta_value);
189 189
 				}
190 190
 			}
191 191
 		}
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 		$version_nb_delta = $current_def_max_version - $current_db_version;
220 220
 
221 221
 		/*	Check if there are modification to do	*/
222
-		if($current_def_max_version >= $current_db_version){
222
+		if ($current_def_max_version >= $current_db_version) {
223 223
 			/*	Check the lowest version of db to execute	*/
224 224
 			$lowest_version_to_execute = $current_def_max_version - $version_nb_delta;
225 225
 
226
-			for($i = $lowest_version_to_execute; $i <= $current_def_max_version; $i++){
226
+			for ($i = $lowest_version_to_execute; $i <= $current_def_max_version; $i++) {
227 227
 				$do_changes = self::execute_operation_on_db_for_update($i);
228 228
 			}
229 229
 		}
230 230
 
231 231
 		/*	Update the db version option value	*/
232
-		if($do_changes){
232
+		if ($do_changes) {
233 233
 			$db_version = get_option('wpshop_db_options', 0);
234 234
 			$db_version['db_version'] = $new_version;
235 235
 			update_option('wpshop_db_options', $db_version);
@@ -242,31 +242,31 @@  discard block
 block discarded – undo
242 242
 	 * @param integer $i The current plugin db version
243 243
 	 * @return boolean If the changes are done correctly or not
244 244
 	 */
245
-	public static function alter_db_structure_on_update( $i ) {
245
+	public static function alter_db_structure_on_update($i) {
246 246
 		$do_changes = false;
247 247
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_request, $wpshop_db_delete;
248 248
 
249 249
 		/*	Check if there are modification to do	*/
250
-		if(isset($wpshop_update_way[$i])){
250
+		if (isset($wpshop_update_way[$i])) {
251 251
 			/*	Check if there are modification to make on table	*/
252
-			if(isset($wpshop_db_table_list[$i])){
253
-				foreach($wpshop_db_table_list[$i] as $table_name){
252
+			if (isset($wpshop_db_table_list[$i])) {
253
+				foreach ($wpshop_db_table_list[$i] as $table_name) {
254 254
 					dbDelta($wpshop_db_table[$table_name]);
255 255
 				}
256 256
 				$do_changes = true;
257 257
 			}
258 258
 
259 259
 			/*	Request maker	*/
260
-			if(isset($wpshop_db_request[$i]) && is_array($wpshop_db_request) && is_array($wpshop_db_request[$i]) && (count($wpshop_db_request[$i]) > 0)){
261
-				foreach($wpshop_db_request[$i] as $request){
260
+			if (isset($wpshop_db_request[$i]) && is_array($wpshop_db_request) && is_array($wpshop_db_request[$i]) && (count($wpshop_db_request[$i]) > 0)) {
261
+				foreach ($wpshop_db_request[$i] as $request) {
262 262
 					$wpdb->query($request);
263 263
 					$do_changes = true;
264 264
 				}
265 265
 			}
266 266
 
267 267
 			/*	Delete datas	*/
268
-			if(isset($wpshop_db_delete[$i]) && is_array($wpshop_db_delete) && is_array($wpshop_db_delete[$i]) && (count($wpshop_db_delete[$i]) > 0)){
269
-				foreach($wpshop_db_delete[$i] as $request){
268
+			if (isset($wpshop_db_delete[$i]) && is_array($wpshop_db_delete) && is_array($wpshop_db_delete[$i]) && (count($wpshop_db_delete[$i]) > 0)) {
269
+				foreach ($wpshop_db_delete[$i] as $request) {
270 270
 					$wpdb->query($request);
271 271
 				}
272 272
 			}
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * @return boolean
284 284
 	 */
285
-	public static function execute_operation_on_db_for_update($i){
285
+	public static function execute_operation_on_db_for_update($i) {
286 286
 		global $wpdb, $wpshop_db_table, $wpshop_db_table_list, $wpshop_update_way, $wpshop_db_content_add, $wpshop_db_content_update, $wpshop_db_options_add, $wpshop_eav_content, $wpshop_eav_content_update, $wpshop_db_options_update, $wpshop_db_request, $wpshop_db_delete;
287 287
 		$do_changes = false;
288 288
 
289 289
 		/*	Check if there are modification to do	*/
290
-		if(isset($wpshop_update_way[$i])){
290
+		if (isset($wpshop_update_way[$i])) {
291 291
 			$do_changes = self::alter_db_structure_on_update($i);
292 292
 
293 293
 
@@ -295,16 +295,16 @@  discard block
 block discarded – undo
295 295
 			/*		Insert data		*/
296 296
 			/********************/
297 297
 			/*	Options content	*/
298
-			if(isset($wpshop_db_options_add[$i]) && is_array($wpshop_db_options_add) && is_array($wpshop_db_options_add[$i]) && (count($wpshop_db_options_add[$i]) > 0)){
299
-				foreach($wpshop_db_options_add[$i] as $option_name => $option_content){
298
+			if (isset($wpshop_db_options_add[$i]) && is_array($wpshop_db_options_add) && is_array($wpshop_db_options_add[$i]) && (count($wpshop_db_options_add[$i]) > 0)) {
299
+				foreach ($wpshop_db_options_add[$i] as $option_name => $option_content) {
300 300
 					add_option($option_name, $option_content, '', 'yes');
301 301
 				}
302 302
 				$do_changes = true;
303 303
 			}
304
-			if(isset($wpshop_db_options_update[$i]) && is_array($wpshop_db_options_update) && is_array($wpshop_db_options_update[$i]) && (count($wpshop_db_options_update[$i]) > 0)){
305
-				foreach($wpshop_db_options_update[$i] as $option_name => $option_content){
304
+			if (isset($wpshop_db_options_update[$i]) && is_array($wpshop_db_options_update) && is_array($wpshop_db_options_update[$i]) && (count($wpshop_db_options_update[$i]) > 0)) {
305
+				foreach ($wpshop_db_options_update[$i] as $option_name => $option_content) {
306 306
 					$option_current_content = get_option($option_name);
307
-					foreach($option_content as $option_key => $option_value){
307
+					foreach ($option_content as $option_key => $option_value) {
308 308
 						$option_current_content[$option_key] = $option_value;
309 309
 					}
310 310
 					update_option($option_name, $option_current_content);
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 			}
314 314
 
315 315
 			/*	Eav content	*/
316
-			if(isset($wpshop_eav_content[$i]) && is_array($wpshop_eav_content) && is_array($wpshop_eav_content[$i]) && (count($wpshop_eav_content[$i]) > 0)){
316
+			if (isset($wpshop_eav_content[$i]) && is_array($wpshop_eav_content) && is_array($wpshop_eav_content[$i]) && (count($wpshop_eav_content[$i]) > 0)) {
317 317
 				$do_changes = self::add_content_to_eav($wpshop_eav_content[$i], $do_changes);
318 318
 			}
319 319
 			/*	Eav content update	*/
320
-			if(isset($wpshop_eav_content_update[$i]) && is_array($wpshop_eav_content_update) && is_array($wpshop_eav_content_update[$i]) && (count($wpshop_eav_content_update[$i]) > 0)){
320
+			if (isset($wpshop_eav_content_update[$i]) && is_array($wpshop_eav_content_update) && is_array($wpshop_eav_content_update[$i]) && (count($wpshop_eav_content_update[$i]) > 0)) {
321 321
 				$do_changes = self::add_content_to_eav($wpshop_eav_content_update[$i], $do_changes);
322 322
 			}
323 323
 
324 324
 			/*	Add datas	*/
325
-			if(isset($wpshop_db_content_add[$i]) && is_array($wpshop_db_content_add) && is_array($wpshop_db_content_add[$i]) && (count($wpshop_db_content_add[$i]) > 0)){
326
-				foreach($wpshop_db_content_add[$i] as $table_name => $def){
327
-					foreach($def as $information_index => $table_information){
325
+			if (isset($wpshop_db_content_add[$i]) && is_array($wpshop_db_content_add) && is_array($wpshop_db_content_add[$i]) && (count($wpshop_db_content_add[$i]) > 0)) {
326
+				foreach ($wpshop_db_content_add[$i] as $table_name => $def) {
327
+					foreach ($def as $information_index => $table_information) {
328 328
 						$wpdb->insert($table_name, $table_information, '%s');
329 329
 						$do_changes = true;
330 330
 					}
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 			}
333 333
 
334 334
 			/*	Update datas	*/
335
-			if(isset($wpshop_db_content_update[$i]) && is_array($wpshop_db_content_update) && is_array($wpshop_db_content_update[$i]) && (count($wpshop_db_content_update[$i]) > 0)){
336
-				foreach($wpshop_db_content_update[$i] as $table_name => $def){
337
-					foreach($def as $information_index => $table_information){
335
+			if (isset($wpshop_db_content_update[$i]) && is_array($wpshop_db_content_update) && is_array($wpshop_db_content_update[$i]) && (count($wpshop_db_content_update[$i]) > 0)) {
336
+				foreach ($wpshop_db_content_update[$i] as $table_name => $def) {
337
+					foreach ($def as $information_index => $table_information) {
338 338
 						$wpdb->update($table_name, $table_information['datas'], $table_information['where'], '%s', '%s');
339 339
 						$do_changes = true;
340 340
 					}
@@ -355,54 +355,54 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return boolean If there are changes to do or not
357 357
 	 */
358
-	public static function add_content_to_eav( $eav_content, $do_changes ) {
358
+	public static function add_content_to_eav($eav_content, $do_changes) {
359 359
 		global $wpdb;
360 360
 		/*	Create entities if entites are set to be created for the current version	*/
361
-		if(isset($eav_content['entities']) && is_array($eav_content['entities']) && is_array($eav_content['entities']) && (count($eav_content['entities']) > 0)){
362
-			foreach($eav_content['entities'] as $entity){
361
+		if (isset($eav_content['entities']) && is_array($eav_content['entities']) && is_array($eav_content['entities']) && (count($eav_content['entities']) > 0)) {
362
+			foreach ($eav_content['entities'] as $entity) {
363 363
 				/*	Creation de l'entité produit dans la table des posts	*/
364
-				wpshop_entities::create_cpt_from_csv_file( $entity );
364
+				wpshop_entities::create_cpt_from_csv_file($entity);
365 365
 			}
366 366
 			$do_changes = true;
367 367
 		}
368 368
 
369 369
 		/*	Create attributes for a given entity if attributes are set to be created for current version	*/
370 370
 		if (!empty($eav_content['attributes']) && is_array($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)) {
371
-			foreach($eav_content['attributes'] as $entity_code){
372
-				wpshop_entities::create_cpt_attributes_from_csv_file( $entity_code );
371
+			foreach ($eav_content['attributes'] as $entity_code) {
372
+				wpshop_entities::create_cpt_attributes_from_csv_file($entity_code);
373 373
 			}
374 374
 			$do_changes = true;
375 375
 		}
376 376
 
377 377
 		/*	Create attribute groups for a given entity if attributes groups are set to be created for current version	*/
378
-		if(isset($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)){
379
-			foreach($eav_content['attribute_groups'] as $entity_code => $attribute_set){
378
+		if (isset($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)) {
379
+			foreach ($eav_content['attribute_groups'] as $entity_code => $attribute_set) {
380 380
 				$entity_id = wpshop_entities::get_entity_identifier_from_code($entity_code);
381 381
 
382
-				if($entity_id > 0){
383
-					foreach($attribute_set as $set_name => $set_groups){
382
+				if ($entity_id > 0) {
383
+					foreach ($attribute_set as $set_name => $set_groups) {
384 384
 						$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE entity_id = %d AND name = LOWER(%s)", $entity_id, wpshop_tools::slugify($set_name, array('noAccent', 'noSpaces', 'lowerCase')));
385 385
 						$attribute_set_id = $wpdb->get_var($query);
386
-						if($attribute_set_id <= 0){
386
+						if ($attribute_set_id <= 0) {
387 387
 							$attribute_set_content = array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_id' => $entity_id, 'name' => $set_name);
388
-							if($set_name == 'default'){
388
+							if ($set_name == 'default') {
389 389
 								$attribute_set_content['default_set'] = 'yes';
390 390
 							}
391 391
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_SET, $attribute_set_content);
392 392
 							$attribute_set_id = $wpdb->insert_id;
393 393
 						}
394 394
 
395
-						if($attribute_set_id > 0){
396
-							foreach($set_groups as $set_group_infos){
395
+						if ($attribute_set_id > 0) {
396
+							foreach ($set_groups as $set_group_infos) {
397 397
 								$set_group_infos_details = $set_group_infos['details'];
398 398
 								unset($set_group_infos['details']);
399 399
 								/*	Change an attribute set status if definition specify this param 	*/
400
-								if(isset($set_group_infos['status'])){
400
+								if (isset($set_group_infos['status'])) {
401 401
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('last_update_date' => current_time('mysql', 0), 'status' => $set_group_infos['status']), array('id' => $attribute_set_id));
402 402
 								}
403 403
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, $set_group_infos['code']);
404 404
 								$attribute_set_section_id = $wpdb->get_var($query);
405
-								if($attribute_set_section_id <= 0){
405
+								if ($attribute_set_section_id <= 0) {
406 406
 									$new_set_section_infos = $set_group_infos;
407 407
 									$new_set_section_infos['status'] = (isset($new_set_section_infos['status']) ? $new_set_section_infos['status'] : 'valid');
408 408
 									$new_set_section_infos['creation_date'] = current_time('mysql', 0);
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
 									$attribute_set_section_id = $wpdb->insert_id;
412 412
 								}
413 413
 
414
-								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details) && (count($set_group_infos_details) > 0))){
414
+								if (($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details) && (count($set_group_infos_details) > 0))) {
415 415
 									$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
416 416
 									$last_position = $wpdb->get_var($query);
417 417
 									$position = (int)$last_position + 1;
418
-									foreach($set_group_infos_details as $attribute_code){
418
+									foreach ($set_group_infos_details as $attribute_code) {
419 419
 										$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
420 420
 										$attribute_id = $wpdb->get_row($query);
421 421
 
422
-										if($attribute_id->id > 0){
422
+										if ($attribute_id->id > 0) {
423 423
 											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id->id, 'position' => $position));
424 424
 											$position++;
425 425
 										}
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
 	 	*
446 446
 	 * @return boolean If there are changes to do or not
447 447
 	 */
448
-	public static function update_eav_content( $eav_content, $do_changes ) {
448
+	public static function update_eav_content($eav_content, $do_changes) {
449 449
 		/*	Update attributes fo a given entity if attributes are set to be updated for current version	*/
450
-		if(isset($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)){
451
-			foreach($eav_content['attributes'] as $entity_code => $attribute_definition){
452
-				foreach($attribute_definition as $attribute_def){
450
+		if (isset($eav_content['attributes']) && is_array($eav_content['attributes']) && (count($eav_content['attributes']) > 0)) {
451
+			foreach ($eav_content['attributes'] as $entity_code => $attribute_definition) {
452
+				foreach ($attribute_definition as $attribute_def) {
453 453
 					$option_list_for_attribute = '';
454
-					if(isset($attribute_def['backend_input_values'])){
454
+					if (isset($attribute_def['backend_input_values'])) {
455 455
 						$option_list_for_attribute = $attribute_def['backend_input_values'];
456 456
 						unset($attribute_def['backend_input_values']);
457 457
 					}
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
 					$attribute_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $attribute_def['code']));
466 466
 
467 467
 					/*	Insert option values if there are some to add for the current attribute	*/
468
-					if(($option_list_for_attribute != '') && (is_array($option_list_for_attribute))){
469
-						foreach($option_list_for_attribute as $option_code => $option_value){
468
+					if (($option_list_for_attribute != '') && (is_array($option_list_for_attribute))) {
469
+						foreach ($option_list_for_attribute as $option_code => $option_value) {
470 470
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $attribute_id, 'label' => ((substr($option_code, 0, 2) != '__') ? $option_value : __(substr($option_code, 2), 'wpshop')), 'value' => $option_value));
471
-							if($option_code == $attribute_def['default_value']){
471
+							if ($option_code == $attribute_def['default_value']) {
472 472
 								$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $wpdb->insert_id), array('id' => $attribute_id, 'default_value' => $option_code));
473 473
 							}
474 474
 						}
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
 		}
480 480
 
481 481
 		/*	Update attribute groups fo a given entity if attributes groups are set to be updated for current version	*/
482
-		if(is_array($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)){
483
-			foreach($eav_content['attribute_groups'] as $entity_code => $attribute_set){
482
+		if (is_array($eav_content['attribute_groups']) && is_array($eav_content['attribute_groups']) && (count($eav_content['attribute_groups']) > 0)) {
483
+			foreach ($eav_content['attribute_groups'] as $entity_code => $attribute_set) {
484 484
 				$entity_id = wpshop_entities::get_entity_identifier_from_code($entity_code);
485 485
 
486
-				if($entity_id > 0){
487
-					foreach($attribute_set as $set_name => $set_groups){
486
+				if ($entity_id > 0) {
487
+					foreach ($attribute_set as $set_name => $set_groups) {
488 488
 						$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE entity_id = %d AND name = LOWER(%s)", $entity_id, wpshop_tools::slugify($set_name, array('noAccent', 'noSpaces', 'lowerCase')));
489 489
 						$attribute_set_id = $wpdb->get_var($query);
490
-						if($attribute_set_id <= 0){
490
+						if ($attribute_set_id <= 0) {
491 491
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_SET, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_id' => $entity_id, 'name' => $set_name));
492 492
 							$attribute_set_id = $wpdb->insert_id;
493 493
 						}
494 494
 
495
-						if($attribute_set_id > 0){
496
-							foreach($set_groups as $set_group_infos){
495
+						if ($attribute_set_id > 0) {
496
+							foreach ($set_groups as $set_group_infos) {
497 497
 								$set_group_infos_details = $set_group_infos['details'];
498 498
 								unset($set_group_infos['details']);
499 499
 								/*	Change an attribute set status if definition specify this param 	*/
500
-								if(isset($set_group_infos['status'])){
500
+								if (isset($set_group_infos['status'])) {
501 501
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('last_update_date' => current_time('mysql', 0), 'status' => $set_group_infos['status']), array('id' => $attribute_set_id));
502 502
 								}
503 503
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, $set_group_infos['code']);
504 504
 								$attribute_set_section_id = $wpdb->get_var($query);
505
-								if($attribute_set_section_id <= 0){
505
+								if ($attribute_set_section_id <= 0) {
506 506
 									$new_set_section_infos = $set_group_infos;
507 507
 									$new_set_section_infos['status'] = (isset($new_set_section_infos['status']) ? $new_set_section_infos['status'] : 'valid');
508 508
 									$new_set_section_infos['creation_date'] = current_time('mysql', 0);
@@ -510,24 +510,24 @@  discard block
 block discarded – undo
510 510
 									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos);
511 511
 									$attribute_set_section_id = $wpdb->insert_id;
512 512
 								}
513
-								else{
513
+								else {
514 514
 									$new_set_section_infos = $set_group_infos;
515 515
 									$new_set_section_infos['last_update_date'] = current_time('mysql', 0);
516 516
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos, array('id' => $attribute_set_section_id));
517 517
 								}
518 518
 
519
-								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))){
520
-									if(count($set_group_infos_details) <= 0){
519
+								if (($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))) {
520
+									if (count($set_group_infos_details) <= 0) {
521 521
 										$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'status' => 'deleted'), array('entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id));
522 522
 									}
523
-									else{
523
+									else {
524 524
 										$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
525 525
 										$last_position = $wpdb->get_var($query);
526 526
 										$position = (int)$last_position + 1;
527
-										foreach($set_group_infos_details as $attribute_code){
527
+										foreach ($set_group_infos_details as $attribute_code) {
528 528
 											$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_code, $entity_id);
529 529
 											$attribute_id = $wpdb->get_var($query);
530
-											if($attribute_id > 0){
530
+											if ($attribute_id > 0) {
531 531
 												$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $attribute_id, 'position' => $position));
532 532
 												$position++;
533 533
 											}
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
 	/**
549 549
 	 * Manage special operation on wpshop plugin update
550 550
 	 */
551
-	public static function make_specific_operation_on_update($version){
551
+	public static function make_specific_operation_on_update($version) {
552 552
 		global $wpdb, $wp_rewrite;
553 553
 		$wpshop_shop_type = get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
554 554
 
555
-		switch($version){
555
+		switch ($version) {
556 556
 			case 3:
557 557
 			case 6:
558 558
  				self::wpshop_insert_default_pages($wpshop_shop_type);
@@ -561,38 +561,38 @@  discard block
 block discarded – undo
561 561
 			break;
562 562
 			case 8:
563 563
 				/**	Change metaboxes order for product in case it already exists	*/
564
-				$query = $wpdb->prepare( "SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'meta-box-order_wpshop_product' );
565
-				$customer_metaboxes_order = $wpdb->get_results( $query );
566
-				if ( !empty( $customer_metaboxes_order ) ) {
567
-					foreach ( $customer_metaboxes_order as $customer_metabox_order ) {
564
+				$query = $wpdb->prepare("SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'meta-box-order_wpshop_product');
565
+				$customer_metaboxes_order = $wpdb->get_results($query);
566
+				if (!empty($customer_metaboxes_order)) {
567
+					foreach ($customer_metaboxes_order as $customer_metabox_order) {
568 568
 						$do_changes = false;
569
-						$current_order = unserialize( $customer_metabox_order->meta_value );
570
-						if ( array_key_exists( 'normal', $current_order ) && ( false !== strpos( 'wpshop_product_important_datas', $current_order[ 'normal' ] ) ) ) {
571
-							str_replace( 'wpshop_product_important_datas,', '', $current_order[ 'normal' ] );
569
+						$current_order = unserialize($customer_metabox_order->meta_value);
570
+						if (array_key_exists('normal', $current_order) && (false !== strpos('wpshop_product_important_datas', $current_order['normal']))) {
571
+							str_replace('wpshop_product_important_datas,', '', $current_order['normal']);
572 572
 							$do_changes = true;
573 573
 						}
574 574
 
575
-						if ( array_key_exists( 'side', $current_order ) ) {
576
-							str_replace( 'wpshop_product_important_datas,', '', $current_order[ 'side' ] );
577
-							str_replace( 'submitdiv,', 'submitdiv,wpshop_product_important_datas,', $current_order[ 'side' ] );
575
+						if (array_key_exists('side', $current_order)) {
576
+							str_replace('wpshop_product_important_datas,', '', $current_order['side']);
577
+							str_replace('submitdiv,', 'submitdiv,wpshop_product_important_datas,', $current_order['side']);
578 578
 							$do_changes = true;
579 579
 						}
580 580
 
581
-						if ( true === $do_changes ) {
582
-							$wpdb->update( $wpdb->usermeta, array( 'meta_value' => serialize( $current_order ), ), array( 'umeta_id' => $customer_metabox_order->umeta_id ) );
581
+						if (true === $do_changes) {
582
+							$wpdb->update($wpdb->usermeta, array('meta_value' => serialize($current_order),), array('umeta_id' => $customer_metabox_order->umeta_id));
583 583
 						}
584 584
 					}
585 585
 				}
586 586
 				else {
587
-					$users = get_users( array( 'role' => 'administrator', ) );
588
-					if ( !empty( $users ) ) {
589
-						foreach ( $users as $user ) {
587
+					$users = get_users(array('role' => 'administrator',));
588
+					if (!empty($users)) {
589
+						foreach ($users as $user) {
590 590
 							$user_meta = array(
591 591
 								'side' => 'submitdiv,formatdiv,wpshop_product_important_datas,wpshop_product_categorydiv,pageparentdiv,wps_barcode_product,wpshop_product_actions,wpshop_product_options,postimagediv',
592 592
 								'normal' => 'wpshop_product_fixed_tab,postexcerpt,trackbacksdiv,postcustom,commentstatusdiv,slugdiv,authordiv,wpshop_wpshop_variations,wps_media_manager,wpshop_product_order_historic',
593 593
 								'advanced' => '',
594 594
 							);
595
-							update_user_meta( $user->ID, 'meta-box-order_wpshop_product', $user_meta );
595
+							update_user_meta($user->ID, 'meta-box-order_wpshop_product', $user_meta);
596 596
 						}
597 597
 					}
598 598
 				}
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 				$tax_id = $wpdb->get_var($wpdb->prepare("SELECT ATT_OPT.id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATT_OPT WHERE attribute_id = %d AND value = '20'", $product_prices->tx_tva));
609 609
 				$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . " WHERE attribute_id = %d", $product_prices->product_price);
610 610
 				$price_list = $wpdb->get_results($query);
611
-				foreach($price_list as $existing_ttc_price){
611
+				foreach ($price_list as $existing_ttc_price) {
612 612
 					$tax_rate = 1.20;
613 613
 					$price_ht = $existing_ttc_price->value / $tax_rate;
614 614
 					$tax_amount = $existing_ttc_price->value - $price_ht;
@@ -619,24 +619,24 @@  discard block
 block discarded – undo
619 619
 				}
620 620
 
621 621
 				/*	Update orders structure into database	*/
622
-				$orders_id = $wpdb->get_results('SELECT ID FROM '.$wpdb->posts.' WHERE post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_ORDER.'"');
622
+				$orders_id = $wpdb->get_results('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '"');
623 623
 				foreach ($orders_id as $o) {
624 624
 					$myorder = get_post_meta($o->ID, '_order_postmeta', true);
625 625
 					$neworder = array();
626 626
 					$items = array();
627 627
 
628
-					if(!isset($myorder['order_tva'])){
628
+					if (!isset($myorder['order_tva'])) {
629 629
 						$order_total_ht = 0;
630 630
 						$order_total_ttc = 0;
631 631
 						$order_tva = array('20'=>0);
632 632
 
633 633
 						foreach ($myorder['order_items'] as $item) {
634 634
 							/* item */
635
-							$pu_ht = $item['cost']/1.20;
636
-							$pu_tva = $item['cost']-$pu_ht;
637
-							$total_ht = $pu_ht*$item['qty'];
638
-							$tva_total_amount = $pu_tva*$item['qty'];
639
-							$total_ttc = $item['cost']*$item['qty'];
635
+							$pu_ht = $item['cost'] / 1.20;
636
+							$pu_tva = $item['cost'] - $pu_ht;
637
+							$total_ht = $pu_ht * $item['qty'];
638
+							$tva_total_amount = $pu_tva * $item['qty'];
639
+							$total_ttc = $item['cost'] * $item['qty'];
640 640
 							/* item */
641 641
 							$order_total_ht += $total_ht;
642 642
 							$order_total_ttc += $total_ttc;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 							'order_total_ttc' => $order_total_ttc,
684 684
 							'order_grand_total' => $order_total_ttc,
685 685
 							'order_shipping_cost' => number_format(0, 2, '.', ''),
686
-							'order_tva' => array_map(array( 'wpshop_tools', 'number_format_hack' ), $order_tva),
686
+							'order_tva' => array_map(array('wpshop_tools', 'number_format_hack'), $order_tva),
687 687
 							'order_items' => $items
688 688
 						);
689 689
 						/* Update the order postmeta */
@@ -698,29 +698,29 @@  discard block
 block discarded – undo
698 698
 			case 12:
699 699
 				$query = "SELECT ID FROM " . $wpdb->users;
700 700
 				$user_list = $wpdb->get_results($query);
701
-				foreach($user_list as $user){
701
+				foreach ($user_list as $user) {
702 702
 					$user_first_name = get_user_meta($user->ID, 'first_name', true);
703 703
 					$user_last_name = get_user_meta($user->ID, 'last_name', true);
704 704
 					$shipping_info = get_user_meta($user->ID, 'shipping_info', true);
705 705
 
706
-					if(($user_first_name == '') && !empty($shipping_info['first_name'])){
706
+					if (($user_first_name == '') && !empty($shipping_info['first_name'])) {
707 707
 						update_user_meta($user->ID, 'first_name', $shipping_info['first_name']);
708 708
 					}
709 709
 
710
-					if(($user_last_name == '') && !empty($shipping_info['last_name'])){
710
+					if (($user_last_name == '') && !empty($shipping_info['last_name'])) {
711 711
 						update_user_meta($user->ID, 'last_name', $shipping_info['last_name']);
712 712
 					}
713 713
 				}
714 714
 
715 715
 				/*	Update orders structure into database	*/
716
-				$orders_id = $wpdb->get_results('SELECT ID FROM '.$wpdb->posts.' WHERE post_type = "'.WPSHOP_NEWTYPE_IDENTIFIER_ORDER.'"');
717
-				foreach($orders_id as $o){
716
+				$orders_id = $wpdb->get_results('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = "' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '"');
717
+				foreach ($orders_id as $o) {
718 718
 					$myorder = get_post_meta($o->ID, '_order_postmeta', true);
719
-					if(!empty($myorder)){
719
+					if (!empty($myorder)) {
720 720
 						$new_items = array();
721
-						foreach($myorder['order_items'] as $item){
721
+						foreach ($myorder['order_items'] as $item) {
722 722
 							$new_items = $item;
723
-							$new_items['item_discount_type'] = !empty($item['item_discount_rate'])?$item['item_discount_rate']:'amount';
723
+							$new_items['item_discount_type'] = !empty($item['item_discount_rate']) ? $item['item_discount_rate'] : 'amount';
724 724
 							// unset($new_items['item_discount_rate']);
725 725
 							$new_items['item_discount_value'] = 0;
726 726
 						}
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 			break;
741 741
 			case 13:
742 742
 				$attribute_used_for_sort_by = wpshop_attributes::getElement('yes', "'valid', 'moderated', 'notused'", 'is_used_for_sort_by', true);
743
-				foreach($attribute_used_for_sort_by as $attribute){
743
+				foreach ($attribute_used_for_sort_by as $attribute) {
744 744
 					$data = query_posts(array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
745
-					foreach($data as $post){
745
+					foreach ($data as $post) {
746 746
 						$postmeta = get_post_meta($post->ID, '_wpshop_product_metadata', true);
747
-						if(!empty($postmeta[$attribute->code])) {
748
-							update_post_meta($post->ID, '_'.$attribute->code, $postmeta[$attribute->code]);
747
+						if (!empty($postmeta[$attribute->code])) {
748
+							update_post_meta($post->ID, '_' . $attribute->code, $postmeta[$attribute->code]);
749 749
 						}
750 750
 					}
751 751
 					wp_reset_query();
@@ -758,9 +758,9 @@  discard block
 block discarded – undo
758 758
 				);
759 759
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = %s", 'yes');
760 760
 				$default_attribute_set = $wpdb->get_var($query);
761
-				foreach($products as $product){
761
+				foreach ($products as $product) {
762 762
 					$p_att_set_id = get_post_meta($product->ID, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true);
763
-					if(empty($p_att_set_id)){
763
+					if (empty($p_att_set_id)) {
764 764
 						/*	Update the attribute set id for the current product	*/
765 765
 						update_post_meta($product->ID, WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, $default_attribute_set);
766 766
 					}
@@ -786,16 +786,16 @@  discard block
 block discarded – undo
786 786
 				 */
787 787
 				$query = $wpdb->prepare("SELECT ATTR_OPT.id, ATTR_OPT.value, ATTR_OPT.label, ATTR_OPT.position, ATTR_OPT.attribute_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " AS ATTR_OPT INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = ATTR_OPT.attribute_id) WHERE ATTR_OPT.status=%s AND ATTR.code=%s", 'valid', 'manage_stock');
788 788
 				$manage_stock_option = $wpdb->get_results($query);
789
-				if( !empty( $manage_stock_option ) ){
789
+				if (!empty($manage_stock_option)) {
790 790
 					$no_is_present = false;
791 791
 					$attribute_id = $manage_stock_option[0]->attribute_id;
792 792
 					foreach ($manage_stock_option as $manage_definition) {
793
-						if( strtolower( __( $manage_definition->value, 'wpshop' ) ) == strtolower( __( 'no', 'wpshop' ) ) ) {
793
+						if (strtolower(__($manage_definition->value, 'wpshop')) == strtolower(__('no', 'wpshop'))) {
794 794
 							$no_is_present = true;
795 795
 						}
796 796
 					}
797
-					if ( !$no_is_present ) {
798
-						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql',0), 'last_update_date'=>current_time('mysql',0),'attribute_id'=>$attribute_id, 'value'=>'no', 'label'=>__('No', 'wpshop')));
797
+					if (!$no_is_present) {
798
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status'=>'valid', 'creation_date'=>current_time('mysql', 0), 'last_update_date'=>current_time('mysql', 0), 'attribute_id'=>$attribute_id, 'value'=>'no', 'label'=>__('No', 'wpshop')));
799 799
 					}
800 800
 				}
801 801
 
@@ -814,29 +814,29 @@  discard block
 block discarded – undo
814 814
 WHERE ATTR_DET.attribute_id IN (" . $attribute_ids . ")"
815 815
 						, 'prices', __('default', 'wpshop'));
816 816
 				$list = $wpdb->get_results($query);
817
-				if(!empty($list)){
817
+				if (!empty($list)) {
818 818
 					$change_order = true;
819 819
 					$old_value = $list[0]->attribute_group_id;
820 820
 					unset($list[0]);
821
-					if(!empty($list)){
821
+					if (!empty($list)) {
822 822
 						foreach ($list as $data) {
823
-							if ( $old_value !=  $data->attribute_group_id) {
823
+							if ($old_value != $data->attribute_group_id) {
824 824
 								$change_order = false;
825 825
 							}
826 826
 						}
827 827
 						if ($change_order) {
828
-							foreach($price_tab as $price_code){
828
+							foreach ($price_tab as $price_code) {
829 829
 								$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $price_code);
830 830
 								$attribute_id = $wpdb->get_var($query);
831
-								switch($price_code){
831
+								switch ($price_code) {
832 832
 									case WPSHOP_PRODUCT_PRICE_HT:
833
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 1 : 3;
833
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 1 : 3;
834 834
 										break;
835 835
 									case WPSHOP_PRODUCT_PRICE_TAX:
836 836
 										$position = 2;
837 837
 										break;
838 838
 									case WPSHOP_PRODUCT_PRICE_TTC:
839
-										$position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 3 : 1;
839
+										$position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 3 : 1;
840 840
 										break;
841 841
 									case WPSHOP_PRODUCT_PRICE_TAX_AMOUNT:
842 842
 										$position = 4;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 			case 22:
853 853
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
854 854
 				$product_entity_id = $wpdb->get_var($query);
855
-				if(empty($product_entityd_id) || ($product_entity_id <= 0) || !$product_entity_id){
855
+				if (empty($product_entityd_id) || ($product_entity_id <= 0) || !$product_entity_id) {
856 856
 					/*	Create the product entity into post table	*/
857 857
 					$product_entity = array(
858 858
 						'post_title' => __('Products', 'wpshop'),
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 						'post_author' => 1,
863 863
 						'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES
864 864
 					);
865
-					$product_entity_id = wp_insert_post( $product_entity );
865
+					$product_entity_id = wp_insert_post($product_entity);
866 866
 				}
867 867
 
868 868
 				/*	Update eav table with the new entity id for product	*/
@@ -886,12 +886,12 @@  discard block
 block discarded – undo
886 886
 			break;
887 887
 			case 23:
888 888
 				/*	Delete duplicate entities	*/
889
-				$query = ("SELECT ID FROM " . $wpdb->posts . " WHERE post_name LIKE '%".WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT."%' ");
889
+				$query = ("SELECT ID FROM " . $wpdb->posts . " WHERE post_name LIKE '%" . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "%' ");
890 890
 				$product_entity_list = $wpdb->get_results($query);
891
-				if ( count($product_entity_list) > 1 ) {
891
+				if (count($product_entity_list) > 1) {
892 892
 					$i = 0;
893
-					foreach($product_entity_list as $product_entity){
894
-						if ($i>0) {
893
+					foreach ($product_entity_list as $product_entity) {
894
+						if ($i > 0) {
895 895
 							wp_delete_post($product_entity->ID);
896 896
 						}
897 897
 					}
@@ -902,16 +902,16 @@  discard block
 block discarded – undo
902 902
 				/*	Update the link status for disabled attribute set	*/
903 903
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE status = %s", 'deleted');
904 904
 				$deleted_attribute_group = $wpdb->get_results($query);
905
-				if(!empty($deleted_attribute_group)) {
906
-					foreach($deleted_attribute_group as $group){
905
+				if (!empty($deleted_attribute_group)) {
906
+					foreach ($deleted_attribute_group as $group) {
907 907
 						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0)), array('attribute_group_id' => $group->id));
908 908
 					}
909 909
 				}
910 910
 
911 911
 				/*	Update entities meta management	*/
912 912
 				$entities = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES));
913
-				if(!empty($entities)){
914
-					foreach($entities as $entity){
913
+				if (!empty($entities)) {
914
+					foreach ($entities as $entity) {
915 915
 						$support = get_post_meta($entity->ID, '_wpshop_entity_support', true);
916 916
 						$rewrite = get_post_meta($entity->ID, '_wpshop_entity_rewrite', true);
917 917
 						update_post_meta($entity->ID, '_wpshop_entity_params', array('support' => $support, 'rewrite' => array('slug' => $rewrite)));
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 				/*	Get entities that have been created a lot of time and delete them	*/
932 932
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE (post_name LIKE '%%" . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "-%%' OR post_name LIKE '%%" . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . "-%%') AND post_type=%s", WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
933 933
 				$entities_to_delete = $wpdb->get_results($query);
934
-				if ( !empty($entities_to_delete) && is_array($entities_to_delete) ) {
934
+				if (!empty($entities_to_delete) && is_array($entities_to_delete)) {
935 935
 					foreach ($entities_to_delete as $entity) {
936 936
 						wp_delete_post($entity->ID, true);
937 937
 					}
@@ -940,14 +940,14 @@  discard block
 block discarded – undo
940 940
 				/*	Get post list that are children of entities created a lot of time */
941 941
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE %s", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . "-%");
942 942
 				$entities_to_update = $wpdb->get_results($query);
943
-				if ( !empty($entities_to_update) && is_array($entities_to_update) ) {
943
+				if (!empty($entities_to_update) && is_array($entities_to_update)) {
944 944
 					foreach ($entities_to_update as $entity) {
945 945
 						wp_update_post(array('ID' => $entity->ID, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS));
946 946
 					}
947 947
 				}
948 948
 				$query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE %s", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . "-%");
949 949
 				$entities_to_update = $wpdb->get_results($query);
950
-				if ( !empty($entities_to_update) && is_array($entities_to_update) ) {
950
+				if (!empty($entities_to_update) && is_array($entities_to_update)) {
951 951
 					foreach ($entities_to_update as $entity) {
952 952
 						wp_update_post(array('ID' => $entity->ID, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
953 953
 					}
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
 
956 956
 				/*	Change addons managament	*/
957 957
 				$wpshop_addons_options = get_option('wpshop_addons_state', array());
958
-				if ( !empty($wpshop_addons_options) ) {
959
-					foreach ($wpshop_addons_options as $addon_name => $addon_state ) {
958
+				if (!empty($wpshop_addons_options)) {
959
+					foreach ($wpshop_addons_options as $addon_name => $addon_state) {
960 960
 						$options_args = array();
961 961
 						$options_args[$addon_name]['activate'] = $addon_state;
962 962
 						$options_args[$addon_name]['activation_date'] = current_time('mysql', 0);
963
-						if (! $addon_state ) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
963
+						if (!$addon_state) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
964 964
 						add_option(WPSHOP_ADDONS_OPTION_NAME, $options_args);
965 965
 					}
966 966
 					delete_option('wpshop_addons_state');
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 				return true;
974 974
 			break;
975 975
 			case 26:
976
-				$query = "SELECT post_id, meta_value FROM " .$wpdb->postmeta. " WHERE meta_key = '_order_postmeta' ";
976
+				$query = "SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '_order_postmeta' ";
977 977
 				$results = $wpdb->get_results($query);
978 978
 				foreach ($results as $result) {
979 979
 					$order_info = unserialize($result->meta_value);
@@ -990,36 +990,36 @@  discard block
 block discarded – undo
990 990
 			break;
991 991
 
992 992
 			case 29:
993
-				$billing_title = __( 'Billing address', 'wpshop' );
994
-				$shipping_title = __( 'Shipping address', 'wpshop' );
993
+				$billing_title = __('Billing address', 'wpshop');
994
+				$shipping_title = __('Shipping address', 'wpshop');
995 995
 
996 996
 				//UPDATE USERS ADDRESSES
997
-				$billing_address_set_id_query = 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .$billing_title. '"';
998
-				$shipping_address_set_id_query = 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE name = "' .$shipping_title. '"';
997
+				$billing_address_set_id_query = 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . $billing_title . '"';
998
+				$shipping_address_set_id_query = 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE name = "' . $shipping_title . '"';
999 999
 
1000 1000
 				$billing_address_set_id = $wpdb->get_var($billing_address_set_id_query);
1001 1001
 				$shipping_address_set_id = $wpdb->get_var($shipping_address_set_id_query);
1002 1002
 
1003 1003
 
1004 1004
 				//Add Address & Google Map API KEY options
1005
-				add_option( 'wpshop_billing_address', array('choice' => $billing_address_set_id), '', 'yes' );
1006
-				add_option( 'wpshop_shipping_address_choice', array('activate'=>'on', 'choice'=> $shipping_address_set_id), '', 'yes' );
1007
-				add_option( 'wpshop_google_map_api_key', '', '', 'yes' );
1005
+				add_option('wpshop_billing_address', array('choice' => $billing_address_set_id), '', 'yes');
1006
+				add_option('wpshop_shipping_address_choice', array('activate'=>'on', 'choice'=> $shipping_address_set_id), '', 'yes');
1007
+				add_option('wpshop_google_map_api_key', '', '', 'yes');
1008 1008
 
1009 1009
 
1010 1010
 
1011
-				$query = 'SELECT * FROM ' .$wpdb->users. '';
1011
+				$query = 'SELECT * FROM ' . $wpdb->users . '';
1012 1012
 				$results = $wpdb->get_results($query);
1013 1013
 				foreach ($results as $result) {
1014
-					$billing_infos = get_user_meta( $result->ID, 'billing_info', true );
1015
-					$shipping_infos = get_user_meta( $result->ID, 'shipping_info', true );
1016
-					if ( !empty($billing_infos) ) {
1014
+					$billing_infos = get_user_meta($result->ID, 'billing_info', true);
1015
+					$shipping_infos = get_user_meta($result->ID, 'shipping_info', true);
1016
+					if (!empty($billing_infos)) {
1017 1017
 						//Save Billing Infos
1018 1018
 						$billing_address = array();
1019
-						if ( !empty($billing_infos['civility']) ) {
1020
-							switch ( $billing_infos['civility'] ) {
1019
+						if (!empty($billing_infos['civility'])) {
1020
+							switch ($billing_infos['civility']) {
1021 1021
 								case 1:
1022
-									$civility = $mister_id ;
1022
+									$civility = $mister_id;
1023 1023
 								break;
1024 1024
 								case 2:
1025 1025
 									$civility = $madam_id;
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 							}
1031 1031
 						}
1032 1032
 						else {
1033
-							$civility = $mister_id ;
1033
+							$civility = $mister_id;
1034 1034
 						}
1035 1035
 						$billing_address = array('address_title' => $billing_title,
1036 1036
 							'address_last_name' => !empty($billing_infos['last_name']) ? $billing_infos['last_name'] : '',
@@ -1058,16 +1058,16 @@  discard block
 block discarded – undo
1058 1058
 						$post_address_id = wp_insert_post($post_address);
1059 1059
 
1060 1060
 						//Create the post_meta with the address infos
1061
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', $billing_address);
1062
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_attribute_set_id', $billing_address_set_id);
1061
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', $billing_address);
1062
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id', $billing_address_set_id);
1063 1063
 					}
1064 1064
 
1065
-					if ( !empty($shipping_infos) ) {
1065
+					if (!empty($shipping_infos)) {
1066 1066
 						//Save Shipping Infos
1067
-						if ( !empty($shipping_infos['civility']) ) {
1068
-							switch ( $shipping_infos['civility'] ) {
1067
+						if (!empty($shipping_infos['civility'])) {
1068
+							switch ($shipping_infos['civility']) {
1069 1069
 								case 1:
1070
-									$civility = $mister_id ;
1070
+									$civility = $mister_id;
1071 1071
 									break;
1072 1072
 								case 2:
1073 1073
 									$civility = $madam_id;
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 							}
1079 1079
 						}
1080 1080
 						else {
1081
-							$civility = $mister_id ;
1081
+							$civility = $mister_id;
1082 1082
 						}
1083 1083
 						$shipping_address = array();
1084 1084
 						$shipping_address = array('address_title' => $shipping_title,
@@ -1103,22 +1103,22 @@  discard block
 block discarded – undo
1103 1103
 						);
1104 1104
 						$post_address_id = wp_insert_post($post_address);
1105 1105
 						//Create the post_meta with the address infos
1106
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', $shipping_address);
1107
-						update_post_meta($post_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_attribute_set_id', $shipping_address_set_id);
1106
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', $shipping_address);
1107
+						update_post_meta($post_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id', $shipping_address_set_id);
1108 1108
 					}
1109 1109
 				}
1110 1110
 
1111 1111
 				// FORMATE THE ORDER ADDRESSES INFOS
1112
-				$results = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1) );
1113
-				foreach ( $results as $result ) {
1112
+				$results = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1));
1113
+				foreach ($results as $result) {
1114 1114
 					$address = get_post_meta($result->ID, '_order_info', true);
1115 1115
 
1116 1116
 					$billing_address = array();
1117
-					if ( !empty($address['billing']) ) {
1118
-						if ( !empty($address['billing']['civility']) ) {
1119
-							switch ( $address['billing']['civility'] ) {
1117
+					if (!empty($address['billing'])) {
1118
+						if (!empty($address['billing']['civility'])) {
1119
+							switch ($address['billing']['civility']) {
1120 1120
 								case 1:
1121
-									$civility = $mister_id ;
1121
+									$civility = $mister_id;
1122 1122
 									break;
1123 1123
 								case 2:
1124 1124
 									$civility = $madam_id;
@@ -1127,12 +1127,12 @@  discard block
 block discarded – undo
1127 1127
 									$civility = $miss_id;
1128 1128
 									break;
1129 1129
 								default:
1130
-									$civility = $mister_id ;
1130
+									$civility = $mister_id;
1131 1131
 									break;
1132 1132
 							}
1133 1133
 						}
1134 1134
 						else {
1135
-							$civility = $mister_id ;
1135
+							$civility = $mister_id;
1136 1136
 						}
1137 1137
 						$billing_address = array('address_title' => $billing_title,
1138 1138
 							'address_last_name' => !empty($address['billing']['last_name']) ? $address['billing']['last_name'] : '',
@@ -1151,11 +1151,11 @@  discard block
 block discarded – undo
1151 1151
 					}
1152 1152
 
1153 1153
 					$shipping_address = array();
1154
-					if ( !empty($address['shipping']) ) {
1155
-						if ( !empty($address['shipping']['civility']) ) {
1156
-							switch ( $address['shipping']['civility'] ) {
1154
+					if (!empty($address['shipping'])) {
1155
+						if (!empty($address['shipping']['civility'])) {
1156
+							switch ($address['shipping']['civility']) {
1157 1157
 								case 1:
1158
-									$civility = $mister_id ;
1158
+									$civility = $mister_id;
1159 1159
 									break;
1160 1160
 								case 2:
1161 1161
 									$civility = $madam_id;
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 							}
1167 1167
 						}
1168 1168
 						else {
1169
-							$civility = $mister_id ;
1169
+							$civility = $mister_id;
1170 1170
 						}
1171 1171
 						$shipping_address = array('address_title' => $shipping_title,
1172 1172
 							'address_last_name' => !empty($address['shipping']['last_name']) ? $address['shipping']['last_name'] : '',
@@ -1191,11 +1191,11 @@  discard block
 block discarded – undo
1191 1191
 
1192 1192
 				/*	Update entities meta management	*/
1193 1193
 				$entities = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'posts_per_page' => -1));
1194
-				if(!empty($entities)){
1195
-					foreach($entities as $entity){
1194
+				if (!empty($entities)) {
1195
+					foreach ($entities as $entity) {
1196 1196
 						$params = get_post_meta($entity->ID, '_wpshop_entity_params', true);
1197
-						$support = ( !empty($params['support']) ) ? $params['support'] : '';
1198
-						$rewrite = ( !empty($params['rewrite']) ) ? $params['rewrite'] : '';
1197
+						$support = (!empty($params['support'])) ? $params['support'] : '';
1198
+						$rewrite = (!empty($params['rewrite'])) ? $params['rewrite'] : '';
1199 1199
 
1200 1200
 						$display_admin_menu = 'on';
1201 1201
 
@@ -1205,35 +1205,35 @@  discard block
 block discarded – undo
1205 1205
 				wp_reset_query();
1206 1206
 
1207 1207
 				// Default Weight unity and Currency Options
1208
-				add_option( 'wpshop_shop_weight_group', 3, '', 'yes' );
1209
-				add_option( 'wpshop_shop_default_weight_unity', 6, '', 'yes' );
1210
-				add_option( 'wpshop_shop_currency_group', 4, '', 'yes' );
1208
+				add_option('wpshop_shop_weight_group', 3, '', 'yes');
1209
+				add_option('wpshop_shop_default_weight_unity', 6, '', 'yes');
1210
+				add_option('wpshop_shop_currency_group', 4, '', 'yes');
1211 1211
 
1212 1212
 				$default_currency = get_option('wpshop_shop_default_currency');
1213
-				foreach ( unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v ) {
1214
-					if ( $default_currency == $k ) {
1213
+				foreach (unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v) {
1214
+					if ($default_currency == $k) {
1215 1215
 						$symbol = $v;
1216 1216
 					}
1217 1217
 				}
1218
-				if ( !empty($symbol) ) {
1219
-					$query = 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE name = "'.html_entity_decode($symbol, ENT_QUOTES, 'UTF-8').'"';
1218
+				if (!empty($symbol)) {
1219
+					$query = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE name = "' . html_entity_decode($symbol, ENT_QUOTES, 'UTF-8') . '"';
1220 1220
 					$currency = $wpdb->get_row($query);
1221
-					if ( !empty($currency) ) {
1221
+					if (!empty($currency)) {
1222 1222
 						update_option('wpshop_shop_default_currency', $currency->id);
1223 1223
 						// Update the change rate of the default currency
1224
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id) );
1224
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id));
1225 1225
 					}
1226 1226
 				}
1227 1227
 
1228 1228
 				// Update the field for variation and user definition field
1229
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_for_variation' => 'yes'), array('is_user_defined' => 'yes') );
1229
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_for_variation' => 'yes'), array('is_user_defined' => 'yes'));
1230 1230
 				// Update field type for frontend output selection
1231 1231
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'text'), array());
1232
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'textarea'), array('backend_input' => 'textarea') );
1233
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'multiple-select') );
1234
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'select') );
1232
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'textarea'), array('backend_input' => 'textarea'));
1233
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'multiple-select'));
1234
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_input' => 'select'), array('backend_input' => 'select'));
1235 1235
 
1236
-				add_option('wpshop_cart_option', array( 'product_added_to_cart' => array('dialog_msg'), 'product_added_to_quotation' => array('cart_page')) );
1236
+				add_option('wpshop_cart_option', array('product_added_to_cart' => array('dialog_msg'), 'product_added_to_quotation' => array('cart_page')));
1237 1237
 
1238 1238
 				return true;
1239 1239
 			break;
@@ -1247,22 +1247,22 @@  discard block
 block discarded – undo
1247 1247
 				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('is_used_in_variation' => 'yes', 'last_update_date' => current_time('mysql', 0)), array('code' => 'product_reference'));
1248 1248
 
1249 1249
 				/**	Insert new message for admin when a customer make an order	*/
1250
-				$admin_new_order_message = get_option( 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' );
1251
-				if ( empty($admin_new_order_message) ) {
1252
-					wps_message_ctr::createMessage( 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' );
1250
+				$admin_new_order_message = get_option('WPSHOP_NEW_ORDER_ADMIN_MESSAGE');
1251
+				if (empty($admin_new_order_message)) {
1252
+					wps_message_ctr::createMessage('WPSHOP_NEW_ORDER_ADMIN_MESSAGE');
1253 1253
 				}
1254 1254
 				/**	Update all amount for paypal orders	*/
1255 1255
 				$query = $wpdb->prepare("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND meta_value = %s ", '_wpshop_payment_method', 'paypal');
1256
-				$paypal_payment_list = $wpdb->get_results( $query );
1257
-				if ( !empty($paypal_payment_list) ) {
1258
-					foreach ( $paypal_payment_list as $post ) {
1259
-						$order_meta = get_post_meta( $post->post_id, '_order_postmeta', true );
1260
-						$order_payment_meta = get_post_meta( $post->post_id, 'wpshop_payment_return_data', true );
1261
-						if ( !empty($order_meta['order_status']) && ($order_meta['order_status'] == 'incorrect_amount') ) {
1262
-							if ( !empty($order_meta['order_grand_total']) && !empty($order_payment_meta['mc_gross']) ) {
1256
+				$paypal_payment_list = $wpdb->get_results($query);
1257
+				if (!empty($paypal_payment_list)) {
1258
+					foreach ($paypal_payment_list as $post) {
1259
+						$order_meta = get_post_meta($post->post_id, '_order_postmeta', true);
1260
+						$order_payment_meta = get_post_meta($post->post_id, 'wpshop_payment_return_data', true);
1261
+						if (!empty($order_meta['order_status']) && ($order_meta['order_status'] == 'incorrect_amount')) {
1262
+							if (!empty($order_meta['order_grand_total']) && !empty($order_payment_meta['mc_gross'])) {
1263 1263
 								$order_amount_to_pay = number_format($order_meta['order_grand_total'], 5);
1264 1264
 								$order_amount_payed = number_format(floatval($order_payment_meta['mc_gross']), 5);
1265
-								if ($order_amount_payed == $order_amount_to_pay ) {
1265
+								if ($order_amount_payed == $order_amount_to_pay) {
1266 1266
 									wpshop_payment::setOrderPaymentStatus($order_id, 'completed');
1267 1267
 								}
1268 1268
 							}
@@ -1273,17 +1273,17 @@  discard block
 block discarded – undo
1273 1273
 				/**	Save existing orders address information	*/
1274 1274
 				$billing_title = __('Billing address', 'wpshop');
1275 1275
 				$shipping_title = __('Shipping address', 'wpshop');
1276
-				$results = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1) );
1277
-				foreach ( $results as $result ) {
1276
+				$results = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1));
1277
+				foreach ($results as $result) {
1278 1278
 					$address = get_post_meta($result->ID, '_order_info', true);
1279 1279
 					$address_format = array();
1280 1280
 
1281 1281
 					$billing_address = array();
1282
-					if ( !empty($address['billing']) && empty($address['billing']['id']) ) {
1283
-						if ( !empty($address['billing']['civility']) ) {
1284
-							switch ( $address['billing']['civility'] ) {
1282
+					if (!empty($address['billing']) && empty($address['billing']['id'])) {
1283
+						if (!empty($address['billing']['civility'])) {
1284
+							switch ($address['billing']['civility']) {
1285 1285
 								case 1:
1286
-									$civility = $mister_id ;
1286
+									$civility = $mister_id;
1287 1287
 									break;
1288 1288
 								case 2:
1289 1289
 									$civility = $madam_id;
@@ -1292,12 +1292,12 @@  discard block
 block discarded – undo
1292 1292
 									$civility = $miss_id;
1293 1293
 									break;
1294 1294
 								default:
1295
-									$civility = $mister_id ;
1295
+									$civility = $mister_id;
1296 1296
 									break;
1297 1297
 							}
1298 1298
 						}
1299 1299
 						else {
1300
-							$civility = $mister_id ;
1300
+							$civility = $mister_id;
1301 1301
 						}
1302 1302
 						$billing_address = array('address_title' => $billing_title,
1303 1303
 							'address_last_name' => !empty($address['billing']['last_name']) ? $address['billing']['last_name'] : '',
@@ -1313,17 +1313,17 @@  discard block
 block discarded – undo
1313 1313
 							'tva_intra' => !empty($address['billing']['company_tva_intra']) ? $address['billing']['company_tva_intra'] : '',
1314 1314
 							'civility' => $civility
1315 1315
 						);
1316
-						$billing_address_option = get_option( 'wpshop_billing_address' );
1316
+						$billing_address_option = get_option('wpshop_billing_address');
1317 1317
 						$address_format['billing']['id'] = $billing_address_option['choice'];
1318 1318
 						$address_format['billing']['address'] = $shipping_address;
1319 1319
 					}
1320 1320
 
1321 1321
 					$shipping_address = array();
1322
-					if ( !empty($address['shipping']) && empty($address['shipping']['id']) ) {
1323
-						if ( !empty($address['shipping']['civility']) ) {
1324
-							switch ( $address['shipping']['civility'] ) {
1322
+					if (!empty($address['shipping']) && empty($address['shipping']['id'])) {
1323
+						if (!empty($address['shipping']['civility'])) {
1324
+							switch ($address['shipping']['civility']) {
1325 1325
 								case 1:
1326
-									$civility = $mister_id ;
1326
+									$civility = $mister_id;
1327 1327
 									break;
1328 1328
 								case 2:
1329 1329
 									$civility = $madam_id;
@@ -1347,19 +1347,19 @@  discard block
 block discarded – undo
1347 1347
 							'country' => !empty($address['shipping']['country']) ? $address['shipping']['country'] : '',
1348 1348
 							'civility' => $civility
1349 1349
 						);
1350
-						$shipping_address_options = get_option( 'wpshop_shipping_address_choice' );
1350
+						$shipping_address_options = get_option('wpshop_shipping_address_choice');
1351 1351
 						$address_format['shipping']['id'] = $shipping_address_options['choice'];
1352 1352
 						$address_format['shipping']['address'] = $shipping_address;
1353 1353
 					}
1354 1354
 
1355
-					if ( !empty($address_format) ) {
1355
+					if (!empty($address_format)) {
1356 1356
 						update_post_meta($result->ID, '_order_info', $address_format);
1357 1357
 					}
1358 1358
 				}
1359 1359
 
1360 1360
 				/**	Delete username from frontend form	*/
1361 1361
 				$attribute_login = wpshop_attributes::getElement('user_login', "'valid'", 'code');
1362
-				if ( !empty($attribute_login) ) {
1362
+				if (!empty($attribute_login)) {
1363 1363
 					$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $attribute_login->id));
1364 1364
 				}
1365 1365
 
@@ -1370,9 +1370,9 @@  discard block
 block discarded – undo
1370 1370
 
1371 1371
 			case '31':
1372 1372
 				/**	Change order structure in order to support several payment	*/
1373
-				$existing_orders = query_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1, 'post_status' => array('draft', 'trash', 'publish')) );
1374
-				if ( !empty($existing_orders) ) {
1375
-					foreach ( $existing_orders as $order_main_informations) {
1373
+				$existing_orders = query_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'posts_per_page' => -1, 'post_status' => array('draft', 'trash', 'publish')));
1374
+				if (!empty($existing_orders)) {
1375
+					foreach ($existing_orders as $order_main_informations) {
1376 1376
 						/**	Transfer payment return data form old meta to new	*/
1377 1377
 						$order_payment_return_data = get_post_meta($order_main_informations->ID, 'wpshop_payment_return_data', true);
1378 1378
 						update_post_meta($order_main_informations->ID, '_wpshop_payment_return_data', $order_payment_return_data);
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 
1381 1381
 						/**	Transfer old payment storage method to new storage method	*/
1382 1382
 						$order_meta = get_post_meta($order_main_informations->ID, '_order_postmeta', true);
1383
-						if ( !empty($order_meta['order_status']) ) {
1383
+						if (!empty($order_meta['order_status'])) {
1384 1384
 							$order_meta['order_payment']['customer_choice'] = array('method' => (!empty($order_meta['payment_method']) ? $order_meta['payment_method'] : (!empty($order_meta['order_payment']['customer_choice']) ? $order_meta['order_payment']['customer_choice'] : '')));
1385 1385
 							unset($order_meta['payment_method']);
1386 1386
 							$order_meta['order_payment']['received'][0]['waited_amount'] = !empty($order_meta['order_grand_total']) ? $order_meta['order_grand_total'] : 0;
@@ -1389,9 +1389,9 @@  discard block
 block discarded – undo
1389 1389
 							$order_meta['order_payment']['received'][0]['status'] = 'waiting_payment';
1390 1390
 							$order_meta['order_payment']['received'][0]['comment'] = '';
1391 1391
 							$order_meta['order_payment']['received'][0]['author'] = $order_meta['order_payment']['customer_choice'] == 'check' ? 1 : $order_meta['customer_id'];
1392
-							if ( in_array($order_meta['order_status'], array('completed', 'shipped')) ) {
1392
+							if (in_array($order_meta['order_status'], array('completed', 'shipped'))) {
1393 1393
 								$order_meta['order_payment']['received'][0]['received_amount'] = $order_meta['order_grand_total'];
1394
-								$order_meta['order_payment']['received'][0]['payment_reference'] = wpshop_payment::get_payment_transaction_number_old_way( $order_main_informations->ID );
1394
+								$order_meta['order_payment']['received'][0]['payment_reference'] = wpshop_payment::get_payment_transaction_number_old_way($order_main_informations->ID);
1395 1395
 								$order_meta['order_payment']['received'][0]['date'] = $order_meta['order_payment_date'];
1396 1396
 								$order_meta['order_payment']['received'][0]['status'] = 'payment_received';
1397 1397
 								$order_meta['order_payment']['received'][0]['comment'] = '';
@@ -1421,43 +1421,43 @@  discard block
 block discarded – undo
1421 1421
 				wp_reset_query();
1422 1422
 
1423 1423
 				$default_currency = get_option('wpshop_shop_default_currency');
1424
-				foreach ( unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v ) {
1425
-					if ( $default_currency == $k ) {
1424
+				foreach (unserialize(WPSHOP_SHOP_CURRENCIES) as $k => $v) {
1425
+					if ($default_currency == $k) {
1426 1426
 						$symbol = $v;
1427 1427
 					}
1428 1428
 				}
1429
-				if ( !empty($symbol) ) {
1430
-					$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE name = "'.html_entity_decode($symbol, ENT_QUOTES, 'UTF-8').'"', '');
1429
+				if (!empty($symbol)) {
1430
+					$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE name = "' . html_entity_decode($symbol, ENT_QUOTES, 'UTF-8') . '"', '');
1431 1431
 					$currency = $wpdb->get_row($query);
1432
-					if ( !empty($currency) ) {
1432
+					if (!empty($currency)) {
1433 1433
 						update_option('wpshop_shop_default_currency', $currency->id);
1434 1434
 						// Update the change rate of the default currency
1435
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id) );
1435
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('change_rate' => 1), array('id' => $currency->id));
1436 1436
 					}
1437 1437
 				}
1438 1438
 
1439 1439
 				$shipping_confirmation_message = get_option('WPSHOP_SHIPPING_CONFIRMATION_MESSAGE');
1440
-				if ( !empty($shipping_confirmation_message) ) {
1440
+				if (!empty($shipping_confirmation_message)) {
1441 1441
 					$message = __('Hello [customer_first_name] [customer_last_name], this email confirms that your order ([order_key]) has just been shipped (order date : [order_date], tracking number : [order_trackingNumber]). Thank you for your loyalty. Have a good day.', 'wpshop');
1442 1442
 					$post = array('ID'=> $shipping_confirmation_message, 'post_content' => $message);
1443
-					wp_update_post( $post );
1443
+					wp_update_post($post);
1444 1444
 				}
1445 1445
 				return true;
1446 1446
 			break;
1447 1447
 			case '32':
1448 1448
 				/**	Update product set id that are null 	*/
1449
-				$query = $wpdb->prepare( "UPDATE " . $wpdb->postmeta . " SET meta_value = (SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = 'yes' AND entity_id = '" . wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) . "') WHERE meta_key = %s AND ((meta_value = '') OR (meta_value = null))", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id' );
1449
+				$query = $wpdb->prepare("UPDATE " . $wpdb->postmeta . " SET meta_value = (SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE default_set = 'yes' AND entity_id = '" . wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) . "') WHERE meta_key = %s AND ((meta_value = '') OR (meta_value = null))", '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id');
1450 1450
 				$wpdb->query($query);
1451 1451
 
1452
-				$addons_options = get_option( WPSHOP_ADDONS_OPTION_NAME );
1453
-				if ( !empty($addons_options) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) && $addons_options['WPSHOP_ADDONS_QUOTATION']['activate'] ) {
1454
-					$admin_new_quotation_message = get_option( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1455
-					if ( empty($admin_new_quotation_message) ) {
1456
-						wps_message_ctr::createMessage( 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' );
1452
+				$addons_options = get_option(WPSHOP_ADDONS_OPTION_NAME);
1453
+				if (!empty($addons_options) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']) && !empty($addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) && $addons_options['WPSHOP_ADDONS_QUOTATION']['activate']) {
1454
+					$admin_new_quotation_message = get_option('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1455
+					if (empty($admin_new_quotation_message)) {
1456
+						wps_message_ctr::createMessage('WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE');
1457 1457
 					}
1458
-					$admin_new_quotation_confirm_message = get_option( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1459
-					if ( empty($admin_new_quotation_confirm_message) ) {
1460
-						wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' );
1458
+					$admin_new_quotation_confirm_message = get_option('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1459
+					if (empty($admin_new_quotation_confirm_message)) {
1460
+						wps_message_ctr::createMessage('WPSHOP_QUOTATION_CONFIRMATION_MESSAGE');
1461 1461
 					}
1462 1462
 				}
1463 1463
 
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 				/** Update VAT Rate*/
1478 1478
 				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'tx_tva', 'eco_taxe_rate_tva');
1479 1479
 				$attribute_ids = $wpdb->get_results($query);
1480
-				foreach ( $attribute_ids as $attribute_id) {
1481
-					$query = $wpdb->prepare('UPDATE ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' SET value = replace(value, "-", ".") WHERE attribute_id = %d', $attribute_id->id);
1480
+				foreach ($attribute_ids as $attribute_id) {
1481
+					$query = $wpdb->prepare('UPDATE ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' SET value = replace(value, "-", ".") WHERE attribute_id = %d', $attribute_id->id);
1482 1482
 					$wpdb->query($query);
1483 1483
 				}
1484 1484
 
@@ -1487,78 +1487,78 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 			case '33' :
1489 1489
 				/** Update the user_mail for the new system of log in/register */
1490
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "user_email"');
1490
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "user_email"');
1491 1491
 
1492 1492
 				/** Put discount attributes in price attribute set section*/
1493
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'prices');
1493
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'prices');
1494 1494
 				$prices_section_id = $wpdb->get_var($query);
1495 1495
 
1496
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s OR code = %s', 'discount_rate', 'discount_amount');
1496
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'discount_rate', 'discount_amount');
1497 1497
 				$attributes = $wpdb->get_results($query);
1498
-				if ( !empty($attributes) && !empty($prices_section_id) ) {
1499
-					foreach ( $attributes as $attribute) {
1500
-						$query = $wpdb->query('UPDATE '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' SET attribute_group_id = '. $prices_section_id .' WHERE attribute_id = '.$attribute->id);
1498
+				if (!empty($attributes) && !empty($prices_section_id)) {
1499
+					foreach ($attributes as $attribute) {
1500
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' SET attribute_group_id = ' . $prices_section_id . ' WHERE attribute_id = ' . $attribute->id);
1501 1501
 					}
1502 1502
 				}
1503 1503
 				return true;
1504 1504
 			break;
1505 1505
 
1506 1506
 			case '34' :
1507
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'prices');
1507
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'prices');
1508 1508
 				$prices_section_id = $wpdb->get_var($query);
1509 1509
 
1510
-				$query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' WHERE attribute_group_id = %d', $prices_section_id);
1510
+				$query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_group_id = %d', $prices_section_id);
1511 1511
 				$last_position_id = $wpdb->get_var($query);
1512 1512
 
1513
-				$query = $wpdb->prepare('SELECT * FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' WHERE  attribute_group_id = %d AND position = %d', $prices_section_id, $last_position_id);
1513
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE  attribute_group_id = %d AND position = %d', $prices_section_id, $last_position_id);
1514 1514
 				$attribute_example = $wpdb->get_row($query);
1515 1515
 
1516
-				$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s OR code = %s', 'special_from', 'special_to');
1516
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s', 'special_from', 'special_to');
1517 1517
 				$attributes = $wpdb->get_results($query);
1518 1518
 				$i = 1;
1519
-				if ( !empty($attributes) && !empty($prices_section_id) ) {
1519
+				if (!empty($attributes) && !empty($prices_section_id)) {
1520 1520
 
1521
-					foreach ( $attributes as $attribute) {
1522
-						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('attribute_group_id' => $prices_section_id), array('attribute_id' => $attribute->id) );
1521
+					foreach ($attributes as $attribute) {
1522
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('attribute_group_id' => $prices_section_id), array('attribute_id' => $attribute->id));
1523 1523
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_example->entity_type_id, 'attribute_set_id' => $attribute_example->attribute_set_id, 'attribute_group_id' => $prices_section_id, 'attribute_id' => $attribute->id, 'position' => $last_position_id + $i));
1524 1524
 						$i++;
1525 1525
 					}
1526 1526
 				}
1527 1527
 				$discount_options = get_option('wpshop_catalog_product_option');
1528
-				$status =  ( !empty($discount_options) && !empty($discount_options['discount']) ) ? 'valid' : 'notused';
1529
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount from', 'wpshop'), 'status' => $status ), array('code' => 'special_from') );
1530
-				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount to', 'wpshop'), 'status' => $status ), array('code' => 'special_to') );
1528
+				$status = (!empty($discount_options) && !empty($discount_options['discount'])) ? 'valid' : 'notused';
1529
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount from', 'wpshop'), 'status' => $status), array('code' => 'special_from'));
1530
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('frontend_label' => __('Discount to', 'wpshop'), 'status' => $status), array('code' => 'special_to'));
1531 1531
 				return true;
1532 1532
 			break;
1533 1533
 
1534 1534
 
1535 1535
 			case '35' :
1536
-				$wpdb->update( $wpdb->posts, array('post_status'=>'draft'), array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) );
1536
+				$wpdb->update($wpdb->posts, array('post_status'=>'draft'), array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS));
1537 1537
 				return true;
1538 1538
 			break;
1539 1539
 
1540 1540
 			case '36' :
1541 1541
 				wpshop_entities::create_cpt_attributes_from_csv_file(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS);
1542
-				@set_time_limit( 900 );
1542
+				@set_time_limit(900);
1543 1543
 				/** Change the path for old categories pictures */
1544
-				@chmod(WPSHOP_UPLOAD_DIR .'wpshop_product_category', 0755);
1544
+				@chmod(WPSHOP_UPLOAD_DIR . 'wpshop_product_category', 0755);
1545 1545
 
1546
-				$query = 'SELECT * FROM ' .$wpdb->terms;
1546
+				$query = 'SELECT * FROM ' . $wpdb->terms;
1547 1547
 				$terms = $wpdb->get_results($query);
1548
-				if ( !empty($terms) ) {
1549
-					foreach ( $terms as $term ) {
1550
-						@chmod(WPSHOP_UPLOAD_DIR .'wpshop_product_category/'.$term->term_id, 0755);
1548
+				if (!empty($terms)) {
1549
+					foreach ($terms as $term) {
1550
+						@chmod(WPSHOP_UPLOAD_DIR . 'wpshop_product_category/' . $term->term_id, 0755);
1551 1551
 						/** Check if a picture exists **/
1552
-						$term_option =  get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$term->term_id );
1553
-						if ( !empty($term_option) && !empty($term_option['wpshop_category_picture']) && is_file(WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture']) ) {
1552
+						$term_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $term->term_id);
1553
+						if (!empty($term_option) && !empty($term_option['wpshop_category_picture']) && is_file(WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture'])) {
1554 1554
 							$wp_upload_dir = wp_upload_dir();
1555 1555
 							$img_path = WPSHOP_UPLOAD_DIR . $term_option['wpshop_category_picture'];
1556 1556
 							$img_basename = basename($img_path);
1557
-							$wp_filetype = wp_check_filetype($img_basename, null );
1557
+							$wp_filetype = wp_check_filetype($img_basename, null);
1558 1558
 							/** Check if there is an image with the same name, if yes we add a rand number to image's name **/
1559
-							$rand_name = ( is_file($wp_upload_dir['path'] . '/' .$img_basename) ) ? rand() : '';
1560
-							$img_basename = ( !empty($rand_name) ) ? $rand_name.'_'.$img_basename : $img_basename;
1561
-							if ( copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename) ) {
1559
+							$rand_name = (is_file($wp_upload_dir['path'] . '/' . $img_basename)) ? rand() : '';
1560
+							$img_basename = (!empty($rand_name)) ? $rand_name . '_' . $img_basename : $img_basename;
1561
+							if (copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename)) {
1562 1562
 								$attachment = array(
1563 1563
 										'guid' => $wp_upload_dir['url'] . '/' . $img_basename,
1564 1564
 										'post_mime_type' => $wp_filetype['type'],
@@ -1566,14 +1566,14 @@  discard block
 block discarded – undo
1566 1566
 										'post_content' => '',
1567 1567
 										'post_status' => 'inherit'
1568 1568
 								);
1569
-								$attach_id = wp_insert_attachment( $attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1569
+								$attach_id = wp_insert_attachment($attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1570 1570
 								/** Generate differnts sizes for this image **/
1571 1571
 								require_once(ABSPATH . 'wp-admin/includes/image.php');
1572
-								$attach_data = wp_generate_attachment_metadata( $attach_id, $wp_upload_dir['path'] . '/' . $img_basename );
1573
-								wp_update_attachment_metadata( $attach_id, $attach_data );
1572
+								$attach_data = wp_generate_attachment_metadata($attach_id, $wp_upload_dir['path'] . '/' . $img_basename);
1573
+								wp_update_attachment_metadata($attach_id, $attach_data);
1574 1574
 								/** Update option picture **/
1575 1575
 								$term_option['wpshop_category_picture'] = $attach_id;
1576
-								update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$term->term_id , $term_option);
1576
+								update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $term->term_id, $term_option);
1577 1577
 							}
1578 1578
 						}
1579 1579
 					}
@@ -1581,16 +1581,16 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
 
1583 1583
 				/** Change metabox Hidden Nav Menu Definition to display WPShop categories' metabox **/
1584
-				$query = $wpdb->prepare('SELECT * FROM ' .$wpdb->usermeta. ' WHERE meta_key = %s', 'metaboxhidden_nav-menus');
1585
-				$meta_keys = $wpdb->get_results( $query );
1586
-				if ( !empty($meta_keys) && is_array( $meta_keys) ) {
1587
-					foreach ( $meta_keys as $meta_key ) {
1584
+				$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->usermeta . ' WHERE meta_key = %s', 'metaboxhidden_nav-menus');
1585
+				$meta_keys = $wpdb->get_results($query);
1586
+				if (!empty($meta_keys) && is_array($meta_keys)) {
1587
+					foreach ($meta_keys as $meta_key) {
1588 1588
 						$user_id = $meta_key->user_id;
1589 1589
 						$meta_value = unserialize($meta_key->meta_value);
1590
-						if ( !empty( $meta_value) && is_array($meta_value) ) {
1590
+						if (!empty($meta_value) && is_array($meta_value)) {
1591 1591
 							$data_to_delete = array_search('add-wpshop_product_category', $meta_value);
1592
-							if ( $data_to_delete !== false ) {
1593
-								unset( $meta_value[$data_to_delete] );
1592
+							if ($data_to_delete !== false) {
1593
+								unset($meta_value[$data_to_delete]);
1594 1594
 							}
1595 1595
 						}
1596 1596
 						update_user_meta($user_id, 'metaboxhidden_nav-menus', $meta_value);
@@ -1600,39 +1600,39 @@  discard block
 block discarded – undo
1600 1600
 			break;
1601 1601
 
1602 1602
 			case '37' :
1603
-				@set_time_limit( 900 );
1603
+				@set_time_limit(900);
1604 1604
 				/** Change the path for old categories pictures */
1605
-				@chmod(WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category', 0755);
1605
+				@chmod(WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category', 0755);
1606 1606
 				/** Read all categories folders **/
1607
-				$categories_main_dir = WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category';
1608
-				if ( file_exists($categories_main_dir) ) {
1607
+				$categories_main_dir = WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category';
1608
+				if (file_exists($categories_main_dir)) {
1609 1609
 					$main_folder_content = scandir($categories_main_dir);
1610 1610
 					/** For each category folder **/
1611
-					foreach ( $main_folder_content as $category_folder ) {
1612
-						if ( $category_folder && substr( $category_folder, 0, 1) != '.' ) {
1611
+					foreach ($main_folder_content as $category_folder) {
1612
+						if ($category_folder && substr($category_folder, 0, 1) != '.') {
1613 1613
 							$category_id = $category_folder;
1614
-							@chmod(WPSHOP_UPLOAD_DIR .'wpshop/wpshop_product_category/'.$category_id, 0755);
1615
-							$scan_category_folder = opendir($categories_main_dir.'/'.$category_folder);
1614
+							@chmod(WPSHOP_UPLOAD_DIR . 'wpshop/wpshop_product_category/' . $category_id, 0755);
1615
+							$scan_category_folder = opendir($categories_main_dir . '/' . $category_folder);
1616 1616
 							/** For each Picture of category **/
1617 1617
 							$file_time = 0;
1618 1618
 							$save_this_picture = false;
1619
-							while(false !== ($fichier = readdir($scan_category_folder))) {
1620
-								if ( $fichier && substr( $fichier, 0, 1) != '.' ) {
1621
-									if ( $file_time < filemtime($categories_main_dir . '/'. $category_id . '/'. $fichier) ) {
1619
+							while (false !== ($fichier = readdir($scan_category_folder))) {
1620
+								if ($fichier && substr($fichier, 0, 1) != '.') {
1621
+									if ($file_time < filemtime($categories_main_dir . '/' . $category_id . '/' . $fichier)) {
1622 1622
 										$save_this_picture = true;
1623
-										$file_time = filemtime($categories_main_dir . '/'. $category_id . '/'. $fichier);
1623
+										$file_time = filemtime($categories_main_dir . '/' . $category_id . '/' . $fichier);
1624 1624
 									}
1625 1625
 									/** Select category option **/
1626
-									$term_option =  get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$category_id );
1626
+									$term_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id);
1627 1627
 									$wp_upload_dir = wp_upload_dir();
1628
-									$img_path = $categories_main_dir . '/' . $category_id .'/'. $fichier;
1628
+									$img_path = $categories_main_dir . '/' . $category_id . '/' . $fichier;
1629 1629
 									$img_basename = basename($img_path);
1630
-									$wp_filetype = wp_check_filetype($img_basename, null );
1630
+									$wp_filetype = wp_check_filetype($img_basename, null);
1631 1631
 									/** Check if there is an image with the same name, if yes we add a rand number to image's name **/
1632
-									$rand_name = ( is_file($wp_upload_dir['path'] . '/' .$img_basename) ) ? rand() : '';
1633
-									$img_basename = ( !empty($rand_name) ) ? $rand_name.'_'.$img_basename : $img_basename;
1632
+									$rand_name = (is_file($wp_upload_dir['path'] . '/' . $img_basename)) ? rand() : '';
1633
+									$img_basename = (!empty($rand_name)) ? $rand_name . '_' . $img_basename : $img_basename;
1634 1634
 
1635
-									if ( copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename) ) {
1635
+									if (copy($img_path, $wp_upload_dir['path'] . '/' . $img_basename)) {
1636 1636
 										$attachment = array(
1637 1637
 												'guid' => $wp_upload_dir['url'] . '/' . $img_basename,
1638 1638
 												'post_mime_type' => $wp_filetype['type'],
@@ -1640,15 +1640,15 @@  discard block
 block discarded – undo
1640 1640
 												'post_content' => '',
1641 1641
 												'post_status' => 'inherit'
1642 1642
 										);
1643
-										$attach_id = wp_insert_attachment( $attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1643
+										$attach_id = wp_insert_attachment($attachment, $wp_upload_dir['path'] . '/' . $img_basename);
1644 1644
 										/** Generate differnts sizes for this image **/
1645 1645
 										require_once(ABSPATH . 'wp-admin/includes/image.php');
1646
-										$attach_data = wp_generate_attachment_metadata( $attach_id, $wp_upload_dir['path'] . '/' . $img_basename );
1647
-										wp_update_attachment_metadata( $attach_id, $attach_data );
1646
+										$attach_data = wp_generate_attachment_metadata($attach_id, $wp_upload_dir['path'] . '/' . $img_basename);
1647
+										wp_update_attachment_metadata($attach_id, $attach_data);
1648 1648
 										/** Update option picture **/
1649
-										$term_option['wpshop_category_picture'] =  $attach_id;
1650
-										if ( $save_this_picture ) {
1651
-											update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' .$category_id , $term_option);
1649
+										$term_option['wpshop_category_picture'] = $attach_id;
1650
+										if ($save_this_picture) {
1651
+											update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id, $term_option);
1652 1652
 										}
1653 1653
 										$save_this_picture = false;
1654 1654
 									}
@@ -1661,33 +1661,33 @@  discard block
 block discarded – undo
1661 1661
 				break;
1662 1662
 
1663 1663
 			case '38' :
1664
-				wps_message_ctr::createMessage( 'WPSHOP_QUOTATION_UPDATE_MESSAGE' );
1664
+				wps_message_ctr::createMessage('WPSHOP_QUOTATION_UPDATE_MESSAGE');
1665 1665
 				return true;
1666 1666
 			break;
1667 1667
 
1668 1668
 			case '39' :
1669 1669
 				$attribute_def = wpshop_attributes::getElement('tx_tva', "'valid'", 'code');
1670 1670
 				/** Check if the 7% VAT Rate is not already created **/
1671
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d AND value = %s',  $attribute_def->id, '7');
1672
-				$exist_vat_rate = $wpdb->get_results( $query );
1671
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d AND value = %s', $attribute_def->id, '7');
1672
+				$exist_vat_rate = $wpdb->get_results($query);
1673 1673
 
1674
-				if ( empty($exist_vat_rate) ) {
1674
+				if (empty($exist_vat_rate)) {
1675 1675
 					/** Get Max Position **/
1676
-					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d', $attribute_def->id);
1677
-					$max_position = $wpdb->get_var( $query );
1676
+					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d', $attribute_def->id);
1677
+					$max_position = $wpdb->get_var($query);
1678 1678
 
1679
-					if ( !empty( $attribute_def) && !empty($attribute_def->id)  ) {
1680
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '7', 'label' => '7') );
1679
+					if (!empty($attribute_def) && !empty($attribute_def->id)) {
1680
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '7', 'label' => '7'));
1681 1681
 					}
1682 1682
 				}
1683 1683
 
1684 1684
 				/** Filter Search optimization **/
1685
-				@set_time_limit( 900 );
1686
-				$query = $wpdb->prepare('SELECT term_id FROM '.$wpdb->term_taxonomy.' WHERE taxonomy = %s ', WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1687
-				$categories = $wpdb->get_results( $query );
1685
+				@set_time_limit(900);
1686
+				$query = $wpdb->prepare('SELECT term_id FROM ' . $wpdb->term_taxonomy . ' WHERE taxonomy = %s ', WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES);
1687
+				$categories = $wpdb->get_results($query);
1688 1688
 				$cats = array();
1689
-				if ( !empty($categories) ) {
1690
-					foreach($categories as $category) {
1689
+				if (!empty($categories)) {
1690
+					foreach ($categories as $category) {
1691 1691
 						$cats[] = $category->term_id;
1692 1692
 					}
1693 1693
 					$wpshop_filter_search = new wps_filter_search();
@@ -1699,116 +1699,116 @@  discard block
 block discarded – undo
1699 1699
 			case '40' :
1700 1700
 				/**	Store watt in puissance unit group	*/
1701 1701
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('puissance', 'wpshop'));
1702
-				$puissance_unit_group_id = $wpdb->get_var( $query );
1703
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $puissance_unit_group_id), array('unit' => 'watt') );
1702
+				$puissance_unit_group_id = $wpdb->get_var($query);
1703
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $puissance_unit_group_id), array('unit' => 'watt'));
1704 1704
 
1705 1705
 				/**	Store day/week/year in duration unit group	*/
1706 1706
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('duration', 'wpshop'));
1707
-				$duration_unit_group_id = $wpdb->get_var( $query );
1708
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'day') );
1709
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'week') );
1710
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'year') );
1707
+				$duration_unit_group_id = $wpdb->get_var($query);
1708
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'day'));
1709
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'week'));
1710
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $duration_unit_group_id), array('unit' => 'year'));
1711 1711
 
1712 1712
 				/**	Store day/week/year in duration unit group	*/
1713 1713
 				$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s", __('length', 'wpshop'));
1714
-				$length_unit_group_id = $wpdb->get_var( $query );
1715
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $length_unit_group_id), array('unit' => 'cm') );
1714
+				$length_unit_group_id = $wpdb->get_var($query);
1715
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_UNIT, array('group_id' => $length_unit_group_id), array('unit' => 'cm'));
1716 1716
 				return true;
1717 1717
 			break;
1718 1718
 
1719 1719
 			case '41':
1720 1720
 				/**	Get distinct attribute set and delete doublons	*/
1721 1721
 				$query = "SELECT DISTINCT( name ) AS name, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " GROUP BY name HAVING COUNT(id) > 1";
1722
-				$list_of_set = $wpdb->get_results( $query );
1723
-				foreach ( $list_of_set as $set_infos ) {
1724
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id );
1725
-					$wpdb->query( $query );
1722
+				$list_of_set = $wpdb->get_results($query);
1723
+				foreach ($list_of_set as $set_infos) {
1724
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id);
1725
+					$wpdb->query($query);
1726 1726
 				}
1727
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_SET );
1727
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_SET);
1728 1728
 
1729 1729
 				/**	Get and delete attribute set section	*/
1730 1730
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " )";
1731
-				$wpdb->query( $query );
1732
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_GROUP );
1731
+				$wpdb->query($query);
1732
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_GROUP);
1733 1733
 
1734 1734
 				/**	Get and delete attribute set details	*/
1735 1735
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " ) OR attribute_group_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " )";
1736
-				$wpdb->query( $query );
1737
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1736
+				$wpdb->query($query);
1737
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1738 1738
 
1739 1739
 				$query = "SELECT attribute_set_id, attribute_group_id, attribute_id, MIN(id) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " GROUP BY attribute_set_id, attribute_group_id, attribute_id HAVING COUNT(id) > 1";
1740
-				$affectation_list = $wpdb->get_results( $query );
1741
-				foreach ( $affectation_list as $affectation_to_treat ) {
1742
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d AND id != %d", $affectation_to_treat->attribute_set_id, $affectation_to_treat->attribute_group_id, $affectation_to_treat->attribute_id, $affectation_to_treat->min_id );
1743
-					$wpdb->query( $query );
1740
+				$affectation_list = $wpdb->get_results($query);
1741
+				foreach ($affectation_list as $affectation_to_treat) {
1742
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d AND id != %d", $affectation_to_treat->attribute_set_id, $affectation_to_treat->attribute_group_id, $affectation_to_treat->attribute_id, $affectation_to_treat->min_id);
1743
+					$wpdb->query($query);
1744 1744
 				}
1745
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1745
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1746 1746
 
1747 1747
 				/**	Get and delete double unit	*/
1748 1748
 				$query = "SELECT DISTINCT( unit ) AS unit, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " GROUP BY unit HAVING COUNT(id) > 1";
1749
-				$list_of_set = $wpdb->get_results( $query );
1750
-				foreach ( $list_of_set as $set_infos ) {
1751
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " WHERE unit = %s AND id != %d", $set_infos->unit, $set_infos->min_id );
1752
-					$wpdb->query( $query );
1749
+				$list_of_set = $wpdb->get_results($query);
1750
+				foreach ($list_of_set as $set_infos) {
1751
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT . " WHERE unit = %s AND id != %d", $set_infos->unit, $set_infos->min_id);
1752
+					$wpdb->query($query);
1753 1753
 				}
1754
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT );
1754
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT);
1755 1755
 
1756 1756
 				$query = "SELECT DISTINCT( name ) AS name, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " GROUP BY name HAVING COUNT(id) > 1";
1757
-				$list_of_set = $wpdb->get_results( $query );
1758
-				foreach ( $list_of_set as $set_infos ) {
1759
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id );
1760
-					$wpdb->query( $query );
1757
+				$list_of_set = $wpdb->get_results($query);
1758
+				foreach ($list_of_set as $set_infos) {
1759
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " WHERE name = %s AND id != %d", $set_infos->name, $set_infos->min_id);
1760
+					$wpdb->query($query);
1761 1761
 				}
1762
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP );
1762
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP);
1763 1763
 
1764 1764
 				/**	Get and delete attribute set details	*/
1765 1765
 				$query = "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_set_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " ) OR attribute_group_id NOT IN ( SELECT DISTINCT(id) FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " )";
1766
-				$wpdb->query( $query );
1766
+				$wpdb->query($query);
1767 1767
 				$query = "SELECT GROUP_CONCAT( id ) AS list_id, MIN( id ) as min_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " GROUP BY attribute_set_id, attribute_group_id, attribute_id HAVING COUNT(id) > 1";
1768
-				$affectation_list = $wpdb->get_results( $query );
1769
-				foreach ( $affectation_list as $list ) {
1770
-					$query = $wpdb->prepare( "DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE id IN (" . ( substr($list->list_id, -1) == ',' ? substr($list->list_id, 0, -1) : $list->list_id ) . ") AND id != %d", $list->min_id , '');
1771
-					$wpdb->query( $query );
1768
+				$affectation_list = $wpdb->get_results($query);
1769
+				foreach ($affectation_list as $list) {
1770
+					$query = $wpdb->prepare("DELETE FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE id IN (" . (substr($list->list_id, -1) == ',' ? substr($list->list_id, 0, -1) : $list->list_id) . ") AND id != %d", $list->min_id, '');
1771
+					$wpdb->query($query);
1772 1772
 				}
1773
-				$wpdb->query( "OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS );
1773
+				$wpdb->query("OPTIMIZE TABLE " . WPSHOP_DBT_ATTRIBUTE_DETAILS);
1774 1774
 
1775 1775
 				return true;
1776 1776
 			break;
1777 1777
 
1778 1778
 			case '42' :
1779
-				$available_downloadable_product = get_option( 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' );
1780
-				if ( empty($available_downloadable_product) ) {
1781
-					wps_message_ctr::createMessage( 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' );
1779
+				$available_downloadable_product = get_option('WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE');
1780
+				if (empty($available_downloadable_product)) {
1781
+					wps_message_ctr::createMessage('WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE');
1782 1782
 				}
1783 1783
 				return true;
1784 1784
 			break;
1785 1785
 
1786 1786
 			case '43' :
1787
-				$available_downloadable_product = get_option( 'WPSHOP_ORDER_IS_CANCELED' );
1788
-				if ( empty($available_downloadable_product) ) {
1789
-					wps_message_ctr::createMessage( 'WPSHOP_ORDER_IS_CANCELED' );
1787
+				$available_downloadable_product = get_option('WPSHOP_ORDER_IS_CANCELED');
1788
+				if (empty($available_downloadable_product)) {
1789
+					wps_message_ctr::createMessage('WPSHOP_ORDER_IS_CANCELED');
1790 1790
 				}
1791 1791
 				return true;
1792 1792
 			break;
1793 1793
 
1794 1794
 			case '44' :
1795 1795
 				$display_option = get_option('wpshop_display_option');
1796
-				if ( !empty($display_option) && empty($display_option['latest_products_ordered']) ) {
1796
+				if (!empty($display_option) && empty($display_option['latest_products_ordered'])) {
1797 1797
 					$display_option['latest_products_ordered'] = 3;
1798 1798
 					update_option('wpshop_display_option', $display_option);
1799 1799
 				}
1800 1800
 
1801 1801
 				/** Check messages for customization **/
1802
-				$messages = array( 'WPSHOP_SIGNUP_MESSAGE' => WPSHOP_SIGNUP_MESSAGE, 'WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE' => WPSHOP_SHIPPING_CONFIRMATION_MESSAGE, 'WPSHOP_ORDER_UPDATE_MESSAGE' => WPSHOP_ORDER_UPDATE_MESSAGE, 'WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE' => WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE, 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' => WPSHOP_NEW_ORDER_ADMIN_MESSAGE, 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' => WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' => WPSHOP_QUOTATION_CONFIRMATION_MESSAGE, 'WPSHOP_QUOTATION_UPDATE_MESSAGE' => WPSHOP_QUOTATION_UPDATE_MESSAGE, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' => WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE, 'WPSHOP_ORDER_IS_CANCELED' => WPSHOP_ORDER_IS_CANCELED);
1803
-				if ( !empty( $messages) ) {
1804
-					foreach ($messages as $key => $message ) {
1805
-						$message_option = get_option( $key );
1806
-						if ( !empty( $message_option) ) {
1807
-							$post_message =  get_post( $message_option );
1808
-							$original_message = ( !empty($post_message) && !empty($post_message->post_content) ) ? $post_message->post_content : '';
1802
+				$messages = array('WPSHOP_SIGNUP_MESSAGE' => WPSHOP_SIGNUP_MESSAGE, 'WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_PAYPAL_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE' => WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE, 'WPSHOP_SHIPPING_CONFIRMATION_MESSAGE' => WPSHOP_SHIPPING_CONFIRMATION_MESSAGE, 'WPSHOP_ORDER_UPDATE_MESSAGE' => WPSHOP_ORDER_UPDATE_MESSAGE, 'WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE' => WPSHOP_ORDER_UPDATE_PRIVATE_MESSAGE, 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE' => WPSHOP_NEW_ORDER_ADMIN_MESSAGE, 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' => WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE' => WPSHOP_QUOTATION_CONFIRMATION_MESSAGE, 'WPSHOP_QUOTATION_UPDATE_MESSAGE' => WPSHOP_QUOTATION_UPDATE_MESSAGE, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE' => WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE, 'WPSHOP_ORDER_IS_CANCELED' => WPSHOP_ORDER_IS_CANCELED);
1803
+				if (!empty($messages)) {
1804
+					foreach ($messages as $key => $message) {
1805
+						$message_option = get_option($key);
1806
+						if (!empty($message_option)) {
1807
+							$post_message = get_post($message_option);
1808
+							$original_message = (!empty($post_message) && !empty($post_message->post_content)) ? $post_message->post_content : '';
1809 1809
 							$tags = array('<p>', '</p>');
1810
-							if ( str_replace( $tags, '', $original_message) == str_replace( $tags, '', __( $message, 'wpshop' ) ) ) {
1811
-								wp_update_post( array( 'ID' => $message_option, 'post_content' => wps_message_ctr::customize_message($original_message) ) );
1810
+							if (str_replace($tags, '', $original_message) == str_replace($tags, '', __($message, 'wpshop'))) {
1811
+								wp_update_post(array('ID' => $message_option, 'post_content' => wps_message_ctr::customize_message($original_message)));
1812 1812
 							}
1813 1813
 						}
1814 1814
 					}
@@ -1824,8 +1824,8 @@  discard block
 block discarded – undo
1824 1824
 			break;
1825 1825
 
1826 1826
 			case '46':
1827
-				wps_message_ctr::createMessage( 'WPSHOP_FORGOT_PASSWORD_MESSAGE' );
1828
-				wps_message_ctr::customize_message( WPSHOP_FORGOT_PASSWORD_MESSAGE );
1827
+				wps_message_ctr::createMessage('WPSHOP_FORGOT_PASSWORD_MESSAGE');
1828
+				wps_message_ctr::customize_message(WPSHOP_FORGOT_PASSWORD_MESSAGE);
1829 1829
 				return true;
1830 1830
 			break;
1831 1831
 
@@ -1838,17 +1838,17 @@  discard block
 block discarded – undo
1838 1838
 				@ini_set('max_execution_time', '500');
1839 1839
 
1840 1840
 				$count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
1841
-				$output_type_option = get_option( 'wpshop_display_option' );
1841
+				$output_type_option = get_option('wpshop_display_option');
1842 1842
 				$output_type = $output_type_option['wpshop_display_list_type'];
1843 1843
 
1844
-				for( $i = 0; $i <= $count_products->publish; $i+= 20 ) {
1845
-					$query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' );
1846
-					$products = $wpdb->get_results( $query );
1847
-					if ( !empty($products) ) {
1848
-						foreach( $products as $product ) {
1844
+				for ($i = 0; $i <= $count_products->publish; $i += 20) {
1845
+					$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
1846
+					$products = $wpdb->get_results($query);
1847
+					if (!empty($products)) {
1848
+						foreach ($products as $product) {
1849 1849
 							$p = wpshop_products::get_product_data($product->ID);
1850
-							$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type) );
1851
-							update_post_meta(  $product->ID, '_wps_price_infos', $price );
1850
+							$price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type));
1851
+							update_post_meta($product->ID, '_wps_price_infos', $price);
1852 1852
 						}
1853 1853
 					}
1854 1854
 				}
@@ -1857,15 +1857,15 @@  discard block
 block discarded – undo
1857 1857
 			break;
1858 1858
 
1859 1859
 			case '49' :
1860
-				update_option( 'wpshop_send_invoice', true);
1860
+				update_option('wpshop_send_invoice', true);
1861 1861
 				return true;
1862 1862
 			break;
1863 1863
 
1864 1864
 			case '50' :
1865
-				$price_display_option = get_option( 'wpshop_catalog_product_option' );
1865
+				$price_display_option = get_option('wpshop_catalog_product_option');
1866 1866
 				$price_display_option['price_display']['text_from'] = 'on';
1867 1867
 				$price_display_option['price_display']['lower_price'] = 'on';
1868
-				update_option( 'wpshop_catalog_product_option', $price_display_option );
1868
+				update_option('wpshop_catalog_product_option', $price_display_option);
1869 1869
 
1870 1870
  				self::wpshop_insert_default_pages();
1871 1871
 
@@ -1874,45 +1874,45 @@  discard block
 block discarded – undo
1874 1874
 
1875 1875
 			case '51' :
1876 1876
 				/**	Insert new message for direct payment link	*/
1877
-				$direct_payment_link_message = get_option( 'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE' );
1878
-				if ( empty($direct_payment_link_message) ) {
1879
-					wps_message_ctr::createMessage( 'WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE' );
1877
+				$direct_payment_link_message = get_option('WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE');
1878
+				if (empty($direct_payment_link_message)) {
1879
+					wps_message_ctr::createMessage('WPSHOP_DIRECT_PAYMENT_LINK_MESSAGE');
1880 1880
 				}
1881 1881
 				return true;
1882 1882
 			break;
1883 1883
 
1884 1884
 			case '52' :
1885
-				$account_page_option = get_option( 'wpshop_myaccount_page_id' );
1886
-				if( !empty($account_page_option) ) {
1887
-					$page_account = get_post( $account_page_option );
1888
-					$page_content = ( !empty($page_account) && !empty($page_account->post_content) ) ? str_replace( '[wpshop_myaccount]', '[wps_account_dashboard]', $page_account->post_content ) : '[wps_account_dashboard]';
1889
-					wp_update_post( array('ID' => $account_page_option, 'post_content' => $page_content ) );
1885
+				$account_page_option = get_option('wpshop_myaccount_page_id');
1886
+				if (!empty($account_page_option)) {
1887
+					$page_account = get_post($account_page_option);
1888
+					$page_content = (!empty($page_account) && !empty($page_account->post_content)) ? str_replace('[wpshop_myaccount]', '[wps_account_dashboard]', $page_account->post_content) : '[wps_account_dashboard]';
1889
+					wp_update_post(array('ID' => $account_page_option, 'post_content' => $page_content));
1890 1890
 				}
1891 1891
 				return true;
1892 1892
 			break;
1893 1893
 
1894 1894
 			case '53' :
1895
-				$payment_modes_option = get_option( 'wps_payment_mode' );
1896
-				if( !empty($payment_modes_option) && !empty($payment_modes_option['mode']) ) {
1895
+				$payment_modes_option = get_option('wps_payment_mode');
1896
+				if (!empty($payment_modes_option) && !empty($payment_modes_option['mode'])) {
1897 1897
 					$payment_modes_option['mode']['cash_on_delivery'] = array(
1898
-							'name' => __( 'Cash on delivery', 'wpshop'),
1899
-							'logo' => WPSHOP_TEMPLATES_URL.'wpshop/cheque.png',
1900
-							'description' => __( 'Pay your order on delivery', 'wpshop') );
1898
+							'name' => __('Cash on delivery', 'wpshop'),
1899
+							'logo' => WPSHOP_TEMPLATES_URL . 'wpshop/cheque.png',
1900
+							'description' => __('Pay your order on delivery', 'wpshop') );
1901 1901
 
1902
-					update_option( 'wps_payment_mode' ,$payment_modes_option );
1902
+					update_option('wps_payment_mode', $payment_modes_option);
1903 1903
 				}
1904 1904
 
1905 1905
 				// Mass action on products to add a flag on variation definition
1906
-				$products = get_posts( array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) );
1907
-				if( !empty($products) ) {
1908
-					foreach( $products as $p ) {
1906
+				$products = get_posts(array('posts_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT));
1907
+				if (!empty($products)) {
1908
+					foreach ($products as $p) {
1909 1909
 						$post_id = $p->ID;
1910
-						$check_product_have_variations = wpshop_products::get_variation( $post_id );
1911
-						if( !empty($check_product_have_variations) ) {
1912
-							$variation_flag =  wpshop_products::check_variation_type( $post_id );
1913
-							$variation_defining = get_post_meta( $post_id, '_wpshop_variation_defining', true );
1910
+						$check_product_have_variations = wpshop_products::get_variation($post_id);
1911
+						if (!empty($check_product_have_variations)) {
1912
+							$variation_flag = wpshop_products::check_variation_type($post_id);
1913
+							$variation_defining = get_post_meta($post_id, '_wpshop_variation_defining', true);
1914 1914
 							$variation_defining['variation_type'] = $variation_flag;
1915
-							update_post_meta( $post_id, '_wpshop_variation_defining', $variation_defining );
1915
+							update_post_meta($post_id, '_wpshop_variation_defining', $variation_defining);
1916 1916
 						}
1917 1917
 					}
1918 1918
 				}
@@ -1921,28 +1921,28 @@  discard block
 block discarded – undo
1921 1921
 
1922 1922
 			case '54' :
1923 1923
 				// Change shortcode of sign up page
1924
-				$signup_page_id = get_option( 'wpshop_signup_page_id' );
1925
-				if( !empty($signup_page_id) ) {
1926
-					$signup_page = get_post( $signup_page_id );
1927
-					$signup_page_content = ( !empty($signup_page) && !empty($signup_page->post_content) ) ? str_replace( '[wpshop_signup]', '[wps_account_dashboard]', $signup_page->post_content ) : '[wps_account_dashboard]';
1928
-					wp_update_post( array('ID' => $signup_page_id, 'post_content' => $signup_page_content ) );
1924
+				$signup_page_id = get_option('wpshop_signup_page_id');
1925
+				if (!empty($signup_page_id)) {
1926
+					$signup_page = get_post($signup_page_id);
1927
+					$signup_page_content = (!empty($signup_page) && !empty($signup_page->post_content)) ? str_replace('[wpshop_signup]', '[wps_account_dashboard]', $signup_page->post_content) : '[wps_account_dashboard]';
1928
+					wp_update_post(array('ID' => $signup_page_id, 'post_content' => $signup_page_content));
1929 1929
 				}
1930 1930
 
1931 1931
 				// Change Terms of sale default content
1932
-				$terms_page_id = get_option( 'wpshop_terms_of_sale_page_id' );
1933
-				if( !empty($terms_page_id) ) {
1934
-					$terms_sale_page = get_post( $terms_page_id );
1935
-					if( !empty($terms_sale_page) && !empty($terms_sale_page->post_content) && $terms_sale_page->post_content == '[wpshop_terms_of_sale]' ) {
1936
-						$data  = '<h1>'.__( 'Your terms of sale', 'wpshop' ).'</h1>';
1937
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 1</h3>';
1932
+				$terms_page_id = get_option('wpshop_terms_of_sale_page_id');
1933
+				if (!empty($terms_page_id)) {
1934
+					$terms_sale_page = get_post($terms_page_id);
1935
+					if (!empty($terms_sale_page) && !empty($terms_sale_page->post_content) && $terms_sale_page->post_content == '[wpshop_terms_of_sale]') {
1936
+						$data  = '<h1>' . __('Your terms of sale', 'wpshop') . '</h1>';
1937
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 1</h3>';
1938 1938
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1939
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 2</h3>';
1939
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 2</h3>';
1940 1940
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1941
-						$data .= '<h3>'.__( 'Rule', 'wpshop' ).' 3</h3>';
1941
+						$data .= '<h3>' . __('Rule', 'wpshop') . ' 3</h3>';
1942 1942
 						$data .= '<p>Ut enim quisque sibi plurimum confidit et ut quisque maxime virtute et sapientia sic munitus est, ut nullo egeat suaque omnia in se ipso posita iudicet, ita in amicitiis expetendis colendisque maxime excellit.</p>';
1943
-						$data .= '<h3>'.__( 'Credits', 'wpshop' ).'</h3>';
1944
-						$data .= sprintf( __( '%s uses <a href="http://www.wpshop.fr/" target="_blank" title="%s uses WPShop e-commerce plug-in for Wordpress">WPShop e-commerce for Wordpress</a>', 'wpshop'), get_bloginfo('name'), get_bloginfo('name') );
1945
-						wp_update_post( array('ID' => $terms_page_id, 'post_content' => $data ) );
1943
+						$data .= '<h3>' . __('Credits', 'wpshop') . '</h3>';
1944
+						$data .= sprintf(__('%s uses <a href="http://www.wpshop.fr/" target="_blank" title="%s uses WPShop e-commerce plug-in for Wordpress">WPShop e-commerce for Wordpress</a>', 'wpshop'), get_bloginfo('name'), get_bloginfo('name'));
1945
+						wp_update_post(array('ID' => $terms_page_id, 'post_content' => $data));
1946 1946
 					}
1947 1947
 				}
1948 1948
 
@@ -1951,58 +1951,58 @@  discard block
 block discarded – undo
1951 1951
 
1952 1952
 
1953 1953
 			case '55' :
1954
-				$checkout_page_id = get_option( 'wpshop_checkout_page_id' );
1955
-				$checkout_page = get_post( $checkout_page_id );
1956
-				$checkout_page_content = ( !empty($checkout_page) && !empty($checkout_page->post_content) ) ? str_replace( '[wpshop_checkout]', '[wps_checkout]', $checkout_page->post_content ) : '[wps_checkout]';
1957
-				wp_update_post( array('ID' => $checkout_page_id, 'post_content' => $checkout_page_content ) );
1954
+				$checkout_page_id = get_option('wpshop_checkout_page_id');
1955
+				$checkout_page = get_post($checkout_page_id);
1956
+				$checkout_page_content = (!empty($checkout_page) && !empty($checkout_page->post_content)) ? str_replace('[wpshop_checkout]', '[wps_checkout]', $checkout_page->post_content) : '[wps_checkout]';
1957
+				wp_update_post(array('ID' => $checkout_page_id, 'post_content' => $checkout_page_content));
1958 1958
 
1959 1959
 				// Update cart page id
1960
-				update_option( 'wpshop_cart_page_id', $checkout_page_id );
1960
+				update_option('wpshop_cart_page_id', $checkout_page_id);
1961 1961
 				return true;
1962 1962
 			break;
1963 1963
 
1964 1964
 
1965 1965
 			case '56' :
1966 1966
 				$wps_entities = new wpshop_entities();
1967
-				$customer_entity_id = $wps_entities->get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
1968
-				$query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d ORDER BY id LIMIT 1', $customer_entity_id );
1969
-				$set = $wpdb->get_row( $query );
1970
-				if( !empty($set) ) {
1971
-					$wpdb->update( WPSHOP_DBT_ATTRIBUTE_SET,
1972
-							array( 'default_set' => 'yes' ),
1973
-							array( 'id' => $set->id) );
1967
+				$customer_entity_id = $wps_entities->get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
1968
+				$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d ORDER BY id LIMIT 1', $customer_entity_id);
1969
+				$set = $wpdb->get_row($query);
1970
+				if (!empty($set)) {
1971
+					$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET,
1972
+							array('default_set' => 'yes'),
1973
+							array('id' => $set->id));
1974 1974
 				}
1975 1975
 				// Update Opinions activation option
1976
-				update_option( 'wps_opinion', array( 'active' => 'on') );
1976
+				update_option('wps_opinion', array('active' => 'on'));
1977 1977
 				return true;
1978 1978
 			break;
1979 1979
 
1980 1980
 			case '57' :
1981
-				$wpshop_cart_option = get_option( 'wpshop_cart_option' );
1981
+				$wpshop_cart_option = get_option('wpshop_cart_option');
1982 1982
 				$wpshop_cart_option['display_newsletter']['site_subscription'][] = 'yes';
1983 1983
 				$wpshop_cart_option['display_newsletter']['partner_subscription'][] = 'yes';
1984 1984
 
1985
-				update_option( 'wpshop_cart_option', $wpshop_cart_option );
1985
+				update_option('wpshop_cart_option', $wpshop_cart_option);
1986 1986
 				return true;
1987 1987
 			break;
1988 1988
 
1989 1989
 			case '58' :
1990 1990
 				/** Turn customers publish into draft **/
1991
-				$query = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_status = %s WHERE post_type = %s", "draft", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
1992
-				$wpdb->query( $query );
1991
+				$query = $wpdb->prepare("UPDATE {$wpdb->posts} SET post_status = %s WHERE post_type = %s", "draft", WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
1992
+				$wpdb->query($query);
1993 1993
 
1994 1994
 				$attribute_def = wpshop_attributes::getElement('tx_tva', "'valid'", 'code');
1995 1995
 				/** Check if the 0% VAT Rate is not already created **/
1996
-				$query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d AND value = %s',  $attribute_def->id, '0');
1997
-				$exist_vat_rate = $wpdb->get_results( $query );
1996
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d AND value = %s', $attribute_def->id, '0');
1997
+				$exist_vat_rate = $wpdb->get_results($query);
1998 1998
 
1999
-				if ( empty($exist_vat_rate) ) {
1999
+				if (empty($exist_vat_rate)) {
2000 2000
 					/** Get Max Position **/
2001
-					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d', $attribute_def->id);
2002
-					$max_position = $wpdb->get_var( $query );
2001
+					$query = $wpdb->prepare('SELECT MAX(position) as max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d', $attribute_def->id);
2002
+					$max_position = $wpdb->get_var($query);
2003 2003
 
2004
-					if ( !empty( $attribute_def) && !empty($attribute_def->id)  ) {
2005
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '0', 'label' => '0') );
2004
+					if (!empty($attribute_def) && !empty($attribute_def->id)) {
2005
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' =>  $attribute_def->id, 'position' => (int)$max_position + 1, 'value' => '0', 'label' => '0'));
2006 2006
 					}
2007 2007
 				}
2008 2008
 				return true;
@@ -2014,31 +2014,31 @@  discard block
 block discarded – undo
2014 2014
 				$args = array(
2015 2015
 						'posts_per_page'   => -1,
2016 2016
 						'post_type'        => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT,
2017
-						'post_status'	   => array( 'publish', 'draft', 'trash' ),
2017
+						'post_status'	   => array('publish', 'draft', 'trash'),
2018 2018
 				);
2019
-				$posts = get_posts( $args );
2019
+				$posts = get_posts($args);
2020 2020
 				$result = array();
2021
-				foreach( $posts as $post ) {
2021
+				foreach ($posts as $post) {
2022 2022
 					$array = array();
2023 2023
 					$array['Post'] = $post;
2024
-					$array['PrincipalThumbnailID'] = get_post_meta( $post->ID, '_thumbnail_id', true);
2025
-					$array['Attachments'] = get_attached_media( $allowed, $post->ID );
2026
-					$array['TrueAttachmentsString'] = get_post_meta( $post->ID, '_wps_product_media', true );
2027
-					if( !empty( $array['TrueAttachmentsString'] ) ) {
2028
-						$TrueAttachments_id = explode( ',', $array['TrueAttachmentsString'] );
2024
+					$array['PrincipalThumbnailID'] = get_post_meta($post->ID, '_thumbnail_id', true);
2025
+					$array['Attachments'] = get_attached_media($allowed, $post->ID);
2026
+					$array['TrueAttachmentsString'] = get_post_meta($post->ID, '_wps_product_media', true);
2027
+					if (!empty($array['TrueAttachmentsString'])) {
2028
+						$TrueAttachments_id = explode(',', $array['TrueAttachmentsString']);
2029 2029
 					}
2030 2030
 					$array['OldAttachmentsString'] = '';
2031
-					foreach( $array['Attachments'] as $attachment ) {
2032
-						$filename =  basename( get_attached_file( $attachment->ID ) );
2033
-						$pos_ext = strrpos( $filename, '.' );
2034
-						$filename_no_ext = substr( $filename, 0, $pos_ext );
2035
-						if( ( empty($TrueAttachments_id) || !in_array( $attachment->ID, $TrueAttachments_id ) ) && !( preg_match('#'.$filename_no_ext.'#', $post->post_content) ) && ( ( empty( $array['PrincipalThumbnailID'] ) || $attachment->ID != $array['PrincipalThumbnailID'] ) ) ) {
2031
+					foreach ($array['Attachments'] as $attachment) {
2032
+						$filename = basename(get_attached_file($attachment->ID));
2033
+						$pos_ext = strrpos($filename, '.');
2034
+						$filename_no_ext = substr($filename, 0, $pos_ext);
2035
+						if ((empty($TrueAttachments_id) || !in_array($attachment->ID, $TrueAttachments_id)) && !(preg_match('#' . $filename_no_ext . '#', $post->post_content)) && ((empty($array['PrincipalThumbnailID']) || $attachment->ID != $array['PrincipalThumbnailID']))) {
2036 2036
 							$array['OldAttachmentsString'] .= $attachment->ID . ',';
2037 2037
 						}
2038 2038
 					}
2039 2039
 					unset($TrueAttachments_id);
2040 2040
 					$result[$post->ID] = $array['TrueAttachmentsString'] . $array['OldAttachmentsString'];
2041
-					update_post_meta( $post->ID, '_wps_product_media', $result[$post->ID] );
2041
+					update_post_meta($post->ID, '_wps_product_media', $result[$post->ID]);
2042 2042
 				}
2043 2043
 				return true;
2044 2044
 			break;
@@ -2048,26 +2048,26 @@  discard block
 block discarded – undo
2048 2048
 				wps_message_ctr::create_default_message();
2049 2049
 
2050 2050
 				/** Update entries for quick add */
2051
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_required = "yes", is_used_in_quick_add_form = "yes" WHERE code = "barcode"');
2052
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "product_stock"');
2053
-				$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "manage_stock"');
2054
-				switch( WPSHOP_PRODUCT_PRICE_PILOT ) {
2051
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_required = "yes", is_used_in_quick_add_form = "yes" WHERE code = "barcode"');
2052
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "product_stock"');
2053
+				$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "manage_stock"');
2054
+				switch (WPSHOP_PRODUCT_PRICE_PILOT) {
2055 2055
 					case 'HT':
2056
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
2057
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
2058
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
2056
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "price_ht"');
2057
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no" WHERE code = "tx_tva"');
2058
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "product_price"');
2059 2059
 						break;
2060 2060
 					default:
2061
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
2062
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
2063
-						$query = $wpdb->query('UPDATE ' .WPSHOP_DBT_ATTRIBUTE.' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
2061
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes", is_used_in_variation = "yes" WHERE code = "product_price"');
2062
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "yes" WHERE code = "tx_tva"');
2063
+						$query = $wpdb->query('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET is_used_in_quick_add_form = "no", is_used_in_variation = "no" WHERE code = "price_ht"');
2064 2064
 						break;
2065 2065
 				}
2066 2066
 
2067 2067
 				/* Default country with WP language */
2068 2068
 				$wpshop_country_default_choice_option = get_option('wpshop_country_default_choice');
2069
-				if ( empty($wpshop_country_default_choice_option) ) {
2070
-					update_option( 'wpshop_country_default_choice', substr( get_bloginfo( 'language' ), 3) );
2069
+				if (empty($wpshop_country_default_choice_option)) {
2070
+					update_option('wpshop_country_default_choice', substr(get_bloginfo('language'), 3));
2071 2071
 				}
2072 2072
 				return true;
2073 2073
 			break;
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 
2079 2079
  				/* Hide admin bar */
2080 2080
  				$wpshop_display_option = get_option('wpshop_display_option');
2081
- 				if( !empty($wpshop_display_option) && empty($wpshop_display_option['wpshop_hide_admin_bar']) ) {
2081
+ 				if (!empty($wpshop_display_option) && empty($wpshop_display_option['wpshop_hide_admin_bar'])) {
2082 2082
  					$wpshop_display_option['wpshop_hide_admin_bar'] = 'on';
2083
- 					update_option( 'wpshop_display_option', $wpshop_display_option );
2083
+ 					update_option('wpshop_display_option', $wpshop_display_option);
2084 2084
  				}
2085 2085
 
2086 2086
 				return true;
@@ -2094,30 +2094,30 @@  discard block
 block discarded – undo
2094 2094
 			break;
2095 2095
 
2096 2096
 			case '63':
2097
-				$data = get_option( 'wps_shipping_mode' );
2098
-				if ( empty($data['modes']['default_shipping_mode_for_pos']) ) {
2097
+				$data = get_option('wps_shipping_mode');
2098
+				if (empty($data['modes']['default_shipping_mode_for_pos'])) {
2099 2099
 					$data['modes']['default_shipping_mode_for_pos']['name'] = __('No Delivery', 'wpshop');
2100 2100
 					$data['modes']['default_shipping_mode_for_pos']['explanation'] = __('Delivery method for point of sale.', 'wpshop');
2101
-					update_option( 'wps_shipping_mode', $data );
2101
+					update_option('wps_shipping_mode', $data);
2102 2102
 				}
2103 2103
 				return true;
2104 2104
 			break;
2105 2105
 
2106 2106
 			case '64':
2107
-				$options = get_option( 'wpshop_catalog_product_option' );
2108
-				if ( !empty( $options['wpshop_catalog_product_slug_with_category'] ) ) {
2109
-					unset( $options['wpshop_catalog_product_slug_with_category'] );
2110
-					update_option( 'wpshop_catalog_product_option', $options );
2107
+				$options = get_option('wpshop_catalog_product_option');
2108
+				if (!empty($options['wpshop_catalog_product_slug_with_category'])) {
2109
+					unset($options['wpshop_catalog_product_slug_with_category']);
2110
+					update_option('wpshop_catalog_product_option', $options);
2111 2111
 				}
2112 2112
 				return true;
2113 2113
 			break;
2114 2114
 			
2115 2115
 			case '65':
2116
-				$entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
2117
-				$query = $wpdb->prepare( 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'company_customer', $entity_id );
2118
-				$company_id = $wpdb->get_var( $query );
2119
-				if( !isset( $company_id ) ) {
2120
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE, array(
2116
+				$entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
2117
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'company_customer', $entity_id);
2118
+				$company_id = $wpdb->get_var($query);
2119
+				if (!isset($company_id)) {
2120
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE, array(
2121 2121
 						'is_visible_in_front' => 'no',
2122 2122
 						'is_visible_in_front_listing' => 'yes',
2123 2123
 						'is_global' => 'no',
@@ -2160,14 +2160,14 @@  discard block
 block discarded – undo
2160 2160
 						'backend_css_class' => NULL,
2161 2161
 						'frontend_help_message' => NULL,
2162 2162
 						'entity_id' => $entity_id
2163
-					) );
2163
+					));
2164 2164
 					$company_id = $wpdb->insert_id;
2165 2165
 				}
2166 2166
 				
2167
-				$query = $wpdb->prepare( 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'is_provider', $entity_id );
2168
-				$is_provider_id = $wpdb->get_var( $query );
2169
-				if( !isset( $is_provider_id ) ) {
2170
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE, array(
2167
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s AND entity_id = %d', 'is_provider', $entity_id);
2168
+				$is_provider_id = $wpdb->get_var($query);
2169
+				if (!isset($is_provider_id)) {
2170
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE, array(
2171 2171
 						'is_visible_in_front' => 'no',
2172 2172
 						'is_visible_in_front_listing' => 'yes',
2173 2173
 						'is_global' => 'no',
@@ -2210,80 +2210,80 @@  discard block
 block discarded – undo
2210 2210
 						'backend_css_class' => NULL,
2211 2211
 						'frontend_help_message' => NULL,
2212 2212
 						'entity_id' => $entity_id
2213
-					) );
2213
+					));
2214 2214
 					$is_provider_id = $wpdb->insert_id;
2215
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2215
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2216 2216
 						'status'				=> 'valid',
2217 2217
 						'attribute_id' 			=> $is_provider_id,
2218 2218
 						'creation_date_value' 	=> current_time('mysql'),
2219 2219
 						'value' 				=> 'yes',
2220 2220
 						'label' 				=> 'Yes',
2221
-					) );
2222
-					$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2221
+					));
2222
+					$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array(
2223 2223
 						'status'				=> 'valid',
2224 2224
 						'attribute_id' 			=> $is_provider_id,
2225 2225
 						'creation_date_value' 	=> current_time('mysql'),
2226 2226
 						'value' 				=> 'no',
2227 2227
 						'label' 				=> 'No',
2228
-					) );
2228
+					));
2229 2229
 					$default_value = $wpdb->insert_id;
2230
-					$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array( 'default_value' => $default_value ), array( 'id' => $is_provider_id ) );
2230
+					$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('default_value' => $default_value), array('id' => $is_provider_id));
2231 2231
 				}
2232 2232
 				
2233
-				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $company_id );
2233
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $company_id);
2234 2234
 				$company_section_detail_id = $wpdb->get_var($query);
2235 2235
 				
2236
-				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $is_provider_id );
2236
+				$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %s', $is_provider_id);
2237 2237
 				$is_provider_section_detail_id = $wpdb->get_var($query);
2238 2238
 				
2239
-				if( !isset( $is_provider_section_detail_id ) || !isset( $company_section_detail_id ) ) {
2240
-					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id );
2239
+				if (!isset($is_provider_section_detail_id) || !isset($company_section_detail_id)) {
2240
+					$query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
2241 2241
 					$attribute_set_id = $wpdb->get_var($query);
2242 2242
 					
2243 2243
 					$query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_GROUP . " WHERE attribute_set_id = %d AND code = LOWER(%s)", $attribute_set_id, 'account');
2244 2244
 					$attribute_set_section_id = $wpdb->get_var($query);
2245 2245
 					
2246
-					$query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_id, $attribute_set_id, $attribute_set_section_id );
2247
-					$attributes_set_details = $wpdb->get_results( $query );
2246
+					$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_id, $attribute_set_id, $attribute_set_section_id);
2247
+					$attributes_set_details = $wpdb->get_results($query);
2248 2248
 					$set_details_id_postion_order = array();
2249
-					foreach( $attributes_set_details as $attribute_set_detail ) {
2250
-						$query = $wpdb->prepare( 'SELECT code FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d', $attribute_set_detail->attribute_id );
2251
-						$attribute_set_detail_code = $wpdb->get_var( $query );
2252
-						if( $attribute_set_detail_code == 'last_name' ) {
2249
+					foreach ($attributes_set_details as $attribute_set_detail) {
2250
+						$query = $wpdb->prepare('SELECT code FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d', $attribute_set_detail->attribute_id);
2251
+						$attribute_set_detail_code = $wpdb->get_var($query);
2252
+						if ($attribute_set_detail_code == 'last_name') {
2253 2253
 							$set_details_id_postion_order[1] = $attribute_set_detail->attribute_id;
2254 2254
 						}
2255
-						if( $attribute_set_detail_code == 'first_name' ) {
2255
+						if ($attribute_set_detail_code == 'first_name') {
2256 2256
 							$set_details_id_postion_order[2] = $attribute_set_detail->attribute_id;
2257 2257
 						}
2258
-						if( $attribute_set_detail_code == 'user_email' ) {
2258
+						if ($attribute_set_detail_code == 'user_email') {
2259 2259
 							$set_details_id_postion_order[3] = $attribute_set_detail->attribute_id;
2260 2260
 						}
2261
-						if( $attribute_set_detail_code == 'user_pass' ) {
2261
+						if ($attribute_set_detail_code == 'user_pass') {
2262 2262
 							$set_details_id_postion_order[4] = $attribute_set_detail->attribute_id;
2263 2263
 						}
2264 2264
 					}
2265
-					$max_position = count( $set_details_id_postion_order );
2265
+					$max_position = count($set_details_id_postion_order);
2266 2266
 					
2267
-					if( !isset( $company_section_detail_id ) ) {
2267
+					if (!isset($company_section_detail_id)) {
2268 2268
 						$max_position = $max_position + 1;
2269
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $company_id, 'position' => (int)$max_position ) );
2269
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $company_id, 'position' => (int)$max_position));
2270 2270
 						$set_details_id_postion_order[$max_position] = $company_id;
2271 2271
 						$company_section_detail_id = $wpdb->insert_id;
2272 2272
 					}
2273 2273
 					
2274
-					if( !isset( $is_provider_section_detail_id ) ) {
2274
+					if (!isset($is_provider_section_detail_id)) {
2275 2275
 						$max_position = $max_position + 1;
2276
-						$wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $is_provider_id, 'position' => (int)$max_position ) );
2276
+						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id, 'attribute_id' => $is_provider_id, 'position' => (int)$max_position));
2277 2277
 						$set_details_id_postion_order[$max_position] = $is_provider_id;
2278 2278
 						$is_provider_section_detail_id = $wpdb->insert_id;
2279 2279
 					}
2280 2280
 					
2281
-					foreach( $set_details_id_postion_order as $pos => $attr_id ) {
2282
-						$wpdb->update( WPSHOP_DBT_ATTRIBUTE_DETAILS, array( 'position' => $pos ), array( 'attribute_id' => $attr_id, 'attribute_set_id' => $attribute_set_id, 'entity_type_id' => $entity_id, 'attribute_group_id' => $attribute_set_section_id ), array( '%d' ), array( '%d', '%d', '%d', '%d' ) );
2281
+					foreach ($set_details_id_postion_order as $pos => $attr_id) {
2282
+						$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('position' => $pos), array('attribute_id' => $attr_id, 'attribute_set_id' => $attribute_set_id, 'entity_type_id' => $entity_id, 'attribute_group_id' => $attribute_set_section_id), array('%d'), array('%d', '%d', '%d', '%d'));
2283 2283
 					}
2284 2284
 				}
2285 2285
 				
2286
-				$wpdb->update( WPSHOP_DBT_ATTRIBUTE_SET, array( 'name' => __( 'Free product', 'wpshop' ), 'slug' => 'free_product' ), array( 'name' => 'free_product' ), array( '%s', '%s' ), array( '%s' ) );
2286
+				$wpdb->update(WPSHOP_DBT_ATTRIBUTE_SET, array('name' => __('Free product', 'wpshop'), 'slug' => 'free_product'), array('name' => 'free_product'), array('%s', '%s'), array('%s'));
2287 2287
 				
2288 2288
 				return true;
2289 2289
 			break;
@@ -2307,23 +2307,23 @@  discard block
 block discarded – undo
2307 2307
 	 * Method called when deactivating the plugin
2308 2308
 	 * @see register_deactivation_hook()
2309 2309
 	 */
2310
-	function uninstall_wpshop(){
2310
+	function uninstall_wpshop() {
2311 2311
 		global $wpdb;
2312 2312
 
2313
-		if(WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION && in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))){
2313
+		if (WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION && in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) {
2314 2314
 			$query = $wpdb->query("DROP TABLE `wp_wpshop__attribute`, `wp_wpshop__attributes_unit`, `wp_wpshop__attributes_unit_groups`, `wp_wpshop__attribute_set`, `wp_wpshop__attribute_set_section`, `wp_wpshop__attribute_set_section_details`, `wp_wpshop__attribute_value_datetime`, `wp_wpshop__attribute_value_decimal`, `wp_wpshop__attribute_value_integer`, `wp_wpshop__attribute_value_text`, `wp_wpshop__attribute_value_varchar`, `wp_wpshop__attribute_value__histo`, `wp_wpshop__cart`, `wp_wpshop__cart_contents`, `wp_wpshop__documentation`, `wp_wpshop__entity`, `wp_wpshop__historique`, `wp_wpshop__message`, `wp_wpshop__attribute_value_options`;");
2315 2315
 			$query = $wpdb->query("DELETE FROM " . $wpdb->options . " WHERE `option_name` LIKE '%wpshop%';");
2316 2316
 
2317 2317
 			$wpshop_products_posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type LIKE 'wpshop_%';");
2318 2318
 			$list = '  ';
2319
-			foreach($wpshop_products_posts as $post){
2319
+			foreach ($wpshop_products_posts as $post) {
2320 2320
 				$list .= "'" . $post->ID . "', ";
2321 2321
 			}
2322 2322
 			$list = substr($list, 0, -2);
2323 2323
 
2324 2324
 			$wpshop_products_posts = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_parent IN (" . $list . ");");
2325 2325
 			$list_attachment = '  ';
2326
-			foreach($wpshop_products_posts as $post){
2326
+			foreach ($wpshop_products_posts as $post) {
2327 2327
 				$list_attachment .= "'" . $post->ID . "', ";
2328 2328
 			}
2329 2329
 			$list_attachment = substr($list_attachment, 0, -2);
@@ -2337,9 +2337,9 @@  discard block
 block discarded – undo
2337 2337
 
2338 2338
 		/*	Unset administrator permission	*/
2339 2339
 		$adminRole = get_role('administrator');
2340
-		foreach($adminRole->capabilities as $capabilityName => $capability){
2341
-			if(substr($capabilityName, 0, 7) == 'wpshop_'){
2342
-				if($adminRole->has_cap($capabilityName)){
2340
+		foreach ($adminRole->capabilities as $capabilityName => $capability) {
2341
+			if (substr($capabilityName, 0, 7) == 'wpshop_') {
2342
+				if ($adminRole->has_cap($capabilityName)) {
2343 2343
 					$adminRole->remove_cap($capabilityName);
2344 2344
 				}
2345 2345
 			}
Please login to merge, or discard this patch.
Braces   +21 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -142,10 +144,12 @@  discard block
 block discarded – undo
142 144
 		$defined_sample_datas = new SimpleXMLElement( $sample_datas, LIBXML_NOCDATA );
143 145
 
144 146
 		$namespaces = $defined_sample_datas->getDocNamespaces();
145
-		if ( ! isset( $namespaces['wp'] ) )
146
-			$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
147
-		if ( ! isset( $namespaces['excerpt'] ) )
148
-			$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
147
+		if ( ! isset( $namespaces['wp'] ) ) {
148
+					$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
149
+		}
150
+		if ( ! isset( $namespaces['excerpt'] ) ) {
151
+					$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
152
+		}
149 153
 
150 154
 		foreach ( $defined_sample_datas->xpath( '//wpshop_products/wpshop_product' ) as $product ) {
151 155
 			$dc = $product->children( 'http://purl.org/dc/elements/1.1/' );
@@ -509,8 +513,7 @@  discard block
 block discarded – undo
509 513
 									$new_set_section_infos['attribute_set_id'] = $attribute_set_id;
510 514
 									$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos);
511 515
 									$attribute_set_section_id = $wpdb->insert_id;
512
-								}
513
-								else{
516
+								} else{
514 517
 									$new_set_section_infos = $set_group_infos;
515 518
 									$new_set_section_infos['last_update_date'] = current_time('mysql', 0);
516 519
 									$wpdb->update(WPSHOP_DBT_ATTRIBUTE_GROUP, $new_set_section_infos, array('id' => $attribute_set_section_id));
@@ -519,8 +522,7 @@  discard block
 block discarded – undo
519 522
 								if(($attribute_set_section_id > 0) && (isset($set_group_infos_details) && is_array($set_group_infos_details))){
520 523
 									if(count($set_group_infos_details) <= 0){
521 524
 										$wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('last_update_date' => current_time('mysql', 0), 'status' => 'deleted'), array('entity_type_id' => $entity_id, 'attribute_set_id' => $attribute_set_id, 'attribute_group_id' => $attribute_set_section_id));
522
-									}
523
-									else{
525
+									} else{
524 526
 										$query = $wpdb->prepare("SELECT MAX(position) AS position FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d", $entity_id, $attribute_set_id, $attribute_set_section_id);
525 527
 										$last_position = $wpdb->get_var($query);
526 528
 										$position = (int)$last_position + 1;
@@ -582,8 +584,7 @@  discard block
 block discarded – undo
582 584
 							$wpdb->update( $wpdb->usermeta, array( 'meta_value' => serialize( $current_order ), ), array( 'umeta_id' => $customer_metabox_order->umeta_id ) );
583 585
 						}
584 586
 					}
585
-				}
586
-				else {
587
+				} else {
587 588
 					$users = get_users( array( 'role' => 'administrator', ) );
588 589
 					if ( !empty( $users ) ) {
589 590
 						foreach ( $users as $user ) {
@@ -960,7 +961,9 @@  discard block
 block discarded – undo
960 961
 						$options_args = array();
961 962
 						$options_args[$addon_name]['activate'] = $addon_state;
962 963
 						$options_args[$addon_name]['activation_date'] = current_time('mysql', 0);
963
-						if (! $addon_state ) $options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
964
+						if (! $addon_state ) {
965
+							$options_args[$addon_name]['deactivation_date'] = current_time('mysql', 0);
966
+						}
964 967
 						add_option(WPSHOP_ADDONS_OPTION_NAME, $options_args);
965 968
 					}
966 969
 					delete_option('wpshop_addons_state');
@@ -1028,8 +1031,7 @@  discard block
 block discarded – undo
1028 1031
 									$civility = $miss_id;
1029 1032
 								break;
1030 1033
 							}
1031
-						}
1032
-						else {
1034
+						} else {
1033 1035
 							$civility = $mister_id ;
1034 1036
 						}
1035 1037
 						$billing_address = array('address_title' => $billing_title,
@@ -1076,8 +1078,7 @@  discard block
 block discarded – undo
1076 1078
 									$civility = $miss_id;
1077 1079
 									break;
1078 1080
 							}
1079
-						}
1080
-						else {
1081
+						} else {
1081 1082
 							$civility = $mister_id ;
1082 1083
 						}
1083 1084
 						$shipping_address = array();
@@ -1130,8 +1131,7 @@  discard block
 block discarded – undo
1130 1131
 									$civility = $mister_id ;
1131 1132
 									break;
1132 1133
 							}
1133
-						}
1134
-						else {
1134
+						} else {
1135 1135
 							$civility = $mister_id ;
1136 1136
 						}
1137 1137
 						$billing_address = array('address_title' => $billing_title,
@@ -1164,8 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 									$civility = $miss_id;
1165 1165
 									break;
1166 1166
 							}
1167
-						}
1168
-						else {
1167
+						} else {
1169 1168
 							$civility = $mister_id ;
1170 1169
 						}
1171 1170
 						$shipping_address = array('address_title' => $shipping_title,
@@ -1295,8 +1294,7 @@  discard block
 block discarded – undo
1295 1294
 									$civility = $mister_id ;
1296 1295
 									break;
1297 1296
 							}
1298
-						}
1299
-						else {
1297
+						} else {
1300 1298
 							$civility = $mister_id ;
1301 1299
 						}
1302 1300
 						$billing_address = array('address_title' => $billing_title,
@@ -1332,8 +1330,7 @@  discard block
 block discarded – undo
1332 1330
 									$civility = $miss_id;
1333 1331
 									break;
1334 1332
 							}
1335
-						}
1336
-						else {
1333
+						} else {
1337 1334
 							$civility = $mister_id;
1338 1335
 						}
1339 1336
 						$shipping_address = array('address_title' => $shipping_title,
Please login to merge, or discard this patch.
includes/librairies/payments/cic.class.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -79,6 +79,9 @@  discard block
 block discarded – undo
79 79
 	//
80 80
 	// ----------------------------------------------------------------------------
81 81
 
82
+	/**
83
+	 * @param string[] $aConstants
84
+	 */
82 85
 	private function _checkTpeParams($aConstants) {
83 86
 
84 87
 		for ($i = 0; $i < count($aConstants); $i++)
@@ -105,6 +108,9 @@  discard block
 block discarded – undo
105 108
 	//
106 109
 	// ----------------------------------------------------------------------------
107 110
 
111
+	/**
112
+	 * @param CMCIC_Tpe $oTpe
113
+	 */
108 114
 	function __construct($oTpe) {
109 115
 
110 116
 		$this->_sUsableKey = $this->_getUsableKey($oTpe);
@@ -147,6 +153,9 @@  discard block
 block discarded – undo
147 153
 	//
148 154
 	// ----------------------------------------------------------------------------
149 155
 
156
+	/**
157
+	 * @param string $sData
158
+	 */
150 159
 	public function computeHmac($sData) {
151 160
 
152 161
 		return strtolower(hash_hmac("sha1", $sData, $this->_sUsableKey));
@@ -196,6 +205,9 @@  discard block
 block discarded – undo
196 205
 //                           ********************
197 206
 //              Encodage des caract�res sp�ciaux au format HTML
198 207
 // ----------------------------------------------------------------------------
208
+/**
209
+ * @param string $data
210
+ */
199 211
 function HtmlEncode ($data)
200 212
 {
201 213
     $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -198,22 +198,22 @@
 block discarded – undo
198 198
 // ----------------------------------------------------------------------------
199 199
 function HtmlEncode ($data)
200 200
 {
201
-    $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
-    $encoded_data = "";
203
-    $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
205
-    {
206
-        if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
-            $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
-            $result .= "&#x" . $var . ";";
211
-        }
212
-        else
213
-            $result .= $data{$i};
214
-
215
-    }
216
-    return $result;
201
+	$SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202
+	$encoded_data = "";
203
+	$result = "";
204
+	for ($i=0; $i<strlen($data); $i++)
205
+	{
206
+		if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207
+			$result .= $data{$i};
208
+		}
209
+		else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210
+			$result .= "&#x" . $var . ";";
211
+		}
212
+		else
213
+			$result .= $data{$i};
214
+
215
+	}
216
+	return $result;
217 217
 }
218 218
 
219 219
 class wpshop_CIC {
Please login to merge, or discard this patch.
Braces   +18 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -81,9 +83,10 @@  discard block
 block discarded – undo
81 83
 
82 84
 	private function _checkTpeParams($aConstants) {
83 85
 
84
-		for ($i = 0; $i < count($aConstants); $i++)
85
-			if (!defined($aConstants[$i]))
86
+		for ($i = 0; $i < count($aConstants); $i++) {
87
+					if (!defined($aConstants[$i]))
86 88
 				die ("Erreur param�tre " . $aConstants[$i] . " ind�fini");
89
+		}
87 90
 	}
88 91
 
89 92
 }
@@ -126,13 +129,14 @@  discard block
 block discarded – undo
126 129
 
127 130
 		$cca0=ord($hexFinal);
128 131
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
131
-		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
133
-				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134
-			else
135
-				$hexStrKey .= substr($hexFinal, 0, 2);
132
+		if ($cca0>70 && $cca0<97) {
133
+					$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
134
+		} else {
135
+			if (substr($hexFinal, 1, 1)=="M") {
136
+							$hexStrKey .= substr($hexFinal, 0, 1) . "0";
137
+			} else {
138
+							$hexStrKey .= substr($hexFinal, 0, 2);
139
+			}
136 140
 		}
137 141
 
138 142
 		return pack("H*", $hexStrKey);
@@ -205,12 +209,11 @@  discard block
 block discarded – undo
205 209
     {
206 210
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 211
             $result .= $data{$i};
208
-        }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
212
+        } else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
210 213
             $result .= "&#x" . $var . ";";
214
+        } else {
215
+                    $result .= $data{$i};
211 216
         }
212
-        else
213
-            $result .= $data{$i};
214 217
 
215 218
     }
216 219
     return $result;
@@ -329,8 +332,7 @@  discard block
 block discarded – undo
329 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
330 333
 
331 334
 			$receipt = CMCIC_CGI2_MACOK;
332
-		}
333
-		else {
335
+		} else {
334 336
 			// your code if the HMAC doesn't match
335 337
 			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
336 338
 		}
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 ***************************************************************************************/
14 14
 
15 15
 
16
-define("CMCIC_CTLHMAC","V1.04.sha1.php--[CtlHmac%s%s]-%s");
16
+define("CMCIC_CTLHMAC", "V1.04.sha1.php--[CtlHmac%s%s]-%s");
17 17
 define("CMCIC_CTLHMACSTR", "CtlHmac%s%s");
18
-define("CMCIC_CGI2_RECEIPT","version=2\ncdr=%s");
19
-define("CMCIC_CGI2_MACOK","0");
20
-define("CMCIC_CGI2_MACNOTOK","1\n");
18
+define("CMCIC_CGI2_RECEIPT", "version=2\ncdr=%s");
19
+define("CMCIC_CGI2_MACOK", "0");
20
+define("CMCIC_CGI2_MACNOTOK", "1\n");
21 21
 define("CMCIC_CGI2_FIELDS", "%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*");
22 22
 define("CMCIC_CGI1_FIELDS", "%s*%s*%s%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s");
23 23
 define("CMCIC_URLPAIEMENT", "paiement.cgi");
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 class CMCIC_Tpe {
26 26
 
27 27
 
28
-	public $sVersion;	// Version du TPE - TPE Version (Ex : 3.0)
29
-	public $sNumero;	// Numero du TPE - TPE Number (Ex : 1234567)
30
-	public $sCodeSociete;	// Code Societe - Company code (Ex : companyname)
31
-	public $sLangue;	// Langue - Language (Ex : FR, DE, EN, ..)
32
-	public $sUrlOK;		// Url de retour OK - Return URL OK
33
-	public $sUrlKO;		// Url de retour KO - Return URL KO
34
-	public $sUrlPaiement;	// Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
28
+	public $sVersion; // Version du TPE - TPE Version (Ex : 3.0)
29
+	public $sNumero; // Numero du TPE - TPE Number (Ex : 1234567)
30
+	public $sCodeSociete; // Code Societe - Company code (Ex : companyname)
31
+	public $sLangue; // Langue - Language (Ex : FR, DE, EN, ..)
32
+	public $sUrlOK; // Url de retour OK - Return URL OK
33
+	public $sUrlKO; // Url de retour KO - Return URL KO
34
+	public $sUrlPaiement; // Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi)
35 35
 
36
-	private $_sCle;		// La cl� - The Key
36
+	private $_sCle; // La cl� - The Key
37 37
 
38 38
 
39 39
 	// Constructeur / Constructor
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 		$this->sCodeSociete = CMCIC_CODESOCIETE;
53 53
 		$this->sLangue = $sLangue;
54 54
 
55
-		$this->sUrlOK = wpshop_payment::get_success_payment_url();;
56
-		$this->sUrlKO = wpshop_payment::get_cancel_payment_url();;
55
+		$this->sUrlOK = wpshop_payment::get_success_payment_url(); ;
56
+		$this->sUrlKO = wpshop_payment::get_cancel_payment_url(); ;
57 57
 
58 58
 	}
59 59
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 class CMCIC_Hmac {
99 99
 
100
-	private $_sUsableKey;	// La cl� du TPE en format op�rationnel / The usable TPE key
100
+	private $_sUsableKey; // La cl� du TPE en format op�rationnel / The usable TPE key
101 101
 
102 102
 	// ----------------------------------------------------------------------------
103 103
 	//
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	//
120 120
 	// ----------------------------------------------------------------------------
121 121
 
122
-	private function _getUsableKey($oTpe){
122
+	private function _getUsableKey($oTpe) {
123 123
 
124 124
 		$hexStrKey  = substr($oTpe->getCle(), 0, 38);
125 125
 		$hexFinal   = "" . substr($oTpe->getCle(), 38, 2) . "00";
126 126
 
127
-		$cca0=ord($hexFinal);
127
+		$cca0 = ord($hexFinal);
128 128
 
129
-		if ($cca0>70 && $cca0<97)
130
-			$hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1);
129
+		if ($cca0 > 70 && $cca0 < 97)
130
+			$hexStrKey .= chr($cca0 - 23) . substr($hexFinal, 1, 1);
131 131
 		else {
132
-			if (substr($hexFinal, 1, 1)=="M")
132
+			if (substr($hexFinal, 1, 1) == "M")
133 133
 				$hexStrKey .= substr($hexFinal, 0, 1) . "0";
134 134
 			else
135 135
 				$hexStrKey .= substr($hexFinal, 0, 2);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	//
171 171
 	// ----------------------------------------------------------------------------
172 172
 
173
-	public function hmac_sha1 ($key, $data) {
173
+	public function hmac_sha1($key, $data) {
174 174
 
175 175
 		$length = 64; // block length for SHA1
176
-		if (strlen($key) > $length) { $key = pack("H*",sha1($key)); }
176
+		if (strlen($key) > $length) { $key = pack("H*", sha1($key)); }
177 177
 		$key  = str_pad($key, $length, chr(0x00));
178 178
 		$ipad = str_pad('', $length, chr(0x36));
179 179
 		$opad = str_pad('', $length, chr(0x5c));
180
-		$k_ipad = $key ^ $ipad ;
180
+		$k_ipad = $key ^ $ipad;
181 181
 		$k_opad = $key ^ $opad;
182 182
 
183
-		return sha1($k_opad  . pack("H*",sha1($k_ipad . $data)));
183
+		return sha1($k_opad . pack("H*", sha1($k_ipad . $data)));
184 184
 	}
185 185
 
186 186
 }
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 //                           ********************
197 197
 //              Encodage des caract�res sp�ciaux au format HTML
198 198
 // ----------------------------------------------------------------------------
199
-function HtmlEncode ($data)
199
+function HtmlEncode($data)
200 200
 {
201 201
     $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-";
202 202
     $encoded_data = "";
203 203
     $result = "";
204
-    for ($i=0; $i<strlen($data); $i++)
204
+    for ($i = 0; $i < strlen($data); $i++)
205 205
     {
206 206
         if (strchr($SAFE_OUT_CHARS, $data{$i})) {
207 207
             $result .= $data{$i};
208 208
         }
209
-        else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){
209
+        else if (($var = bin2hex(substr($data, $i, 1))) <= "7F") {
210 210
             $result .= "&#x" . $var . ";";
211 211
         }
212 212
         else
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
 
221 221
 	public function __construct() {
222 222
 		global $wpshop;
223
-		$cic_option = get_option( 'wpshop_addons' );
224
-		if ( !empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']) ) {
223
+		$cic_option = get_option('wpshop_addons');
224
+		if (!empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC'])) {
225 225
 			/** Check if SystemPay is registred in Payment Main Option **/
226
-			$payment_option = get_option( 'wps_payment_mode' );
227
-			if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode']) ) {
226
+			$payment_option = get_option('wps_payment_mode');
227
+			if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode'])) {
228 228
 				$payment_option['mode']['cic']['name'] = __('CIC', 'wpshop');
229
-				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/cic_payment_logo.jpg';
229
+				$payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg';
230 230
 				$payment_option['mode']['cic']['description'] = __('Reservation of products upon confirmation of payment.', 'wpshop');
231
-				update_option( 'wps_payment_mode', $payment_option );
231
+				update_option('wps_payment_mode', $payment_option);
232 232
 			}
233 233
 		}
234 234
 
235
-		$paymentListener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : '';
235
+		$paymentListener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : '';
236 236
 
237
-		if(!empty($paymentListener) && $paymentListener=='cic') {
237
+		if (!empty($paymentListener) && $paymentListener == 'cic') {
238 238
 			header("Pragma: no-cache");
239 239
 			header("Content-type: text/plain");
240 240
 			self::display_response();
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC'])) {
279 279
 			wpshop_payment::save_payment_return_data($CMCIC_bruteVars['reference']);
280 280
 			$payment_status = 'denied';
281
-			switch($CMCIC_bruteVars['code-retour']) {
281
+			switch ($CMCIC_bruteVars['code-retour']) {
282 282
 				case "Annulation" :
283 283
 					// Attention : an autorization may still be delivered for this payment
284 284
 					//wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'denied');
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 				break;
320 320
 			}
321 321
 
322
-			$order_meta = get_post_meta( $CMCIC_bruteVars['reference'], '_order_postmeta', true);
322
+			$order_meta = get_post_meta($CMCIC_bruteVars['reference'], '_order_postmeta', true);
323 323
 			$params_array = array(
324 324
 				'method' => 'cic',
325
-				'waited_amount' => number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
-				'status' => (($payment_status == 'completed') ? ( ( number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' ) ) ? 'payment_received' : 'incorrect_amount' ) : $payment_status),
325
+				'waited_amount' => number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', ''),
326
+				'status' => (($payment_status == 'completed') ? ((number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')) ? 'payment_received' : 'incorrect_amount') : $payment_status),
327 327
 				'author' => $order_meta['customer_id'],
328 328
 				'payment_reference' => $CMCIC_bruteVars['numauto'],
329 329
 				'date' => current_time('mysql', 0),
330
-				'received_amount' => number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' )
330
+				'received_amount' => number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')
331 331
 			);
332 332
 			wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status);
333 333
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		}
336 336
 		else {
337 337
 			// your code if the HMAC doesn't match
338
-			$receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields;
338
+			$receipt = CMCIC_CGI2_MACNOTOK . $cgi2_fields;
339 339
 		}
340 340
 
341 341
 		// Send receipt to CMCIC server
342
-		printf (CMCIC_CGI2_RECEIPT, $receipt);
342
+		printf(CMCIC_CGI2_RECEIPT, $receipt);
343 343
 	}
344 344
 
345 345
 	public static function display_form($oid) {
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 		$order_customer_info = get_post_meta($oid, '_order_info', true);
350 350
 		//$currency_code = wpshop_tools::wpshop_get_currency($code=true);
351 351
 		$current_currency = get_option('wpshop_shop_default_currency');
352
-		$query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency );
353
-		$currency_code = $wpdb->get_var( $query );
352
+		$query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency);
353
+		$currency_code = $wpdb->get_var($query);
354 354
 
355
-		if(!empty($order) && !empty($currency_code)) {
355
+		if (!empty($order) && !empty($currency_code)) {
356 356
 
357 357
 			$sOptions = "";
358 358
 			// ----------------------------------------------------------------------------
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 			//  That's your job to set actual order fields. Here is a stub.
361 361
 			// -----------------------------------------------------------------------------
362 362
 			$sReference = $oid; // Reference: unique, alphaNum (A-Z a-z 0-9), 12 characters max
363
-			$sMontant = number_format($order['order_grand_total'],2,'.',''); // Amount : format  "xxxxx.yy" (no spaces)
363
+			$sMontant = number_format($order['order_grand_total'], 2, '.', ''); // Amount : format  "xxxxx.yy" (no spaces)
364 364
 			$sDevise  = $currency_code; // Currency : ISO 4217 compliant
365 365
 			$sTexteLibre = ""; // free texte : a bigger reference, session context for the return on the merchant website
366 366
 			$sDate = date("d/m/Y:H:i:s"); // transaction date : format d/m/y:h:m:s
367 367
 			$sLangue = "FR"; // Language of the company code
368
-			$sEmail = $order_customer_info['billing']['address']['address_user_email'];//"[email protected]"; // customer email
368
+			$sEmail = $order_customer_info['billing']['address']['address_user_email']; //"[email protected]"; // customer email
369 369
 			///////////////////////////////////////////////////////////////////////////////////////////
370 370
 			$sNbrEch = ""; //$sNbrEch = "4"; // between 2 and 4
371 371
 			$sDateEcheance1 = ""; // date echeance 1 - format dd/mm/yyyy //$sDateEcheance1 = date("d/m/Y");
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			$CtlHmac = sprintf(CMCIC_CTLHMAC, $oTpe->sVersion, $oTpe->sNumero, $oHmac->computeHmac(sprintf(CMCIC_CTLHMACSTR, $oTpe->sVersion, $oTpe->sNumero)));
387 387
 
388 388
 			// Data to certify
389
-			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS,     $oTpe->sNumero,
389
+			$PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS, $oTpe->sNumero,
390 390
 															$sDate,
391 391
 															$sMontant,
392 392
 															$sDevise,
@@ -413,30 +413,30 @@  discard block
 block discarded – undo
413 413
 		?>
414 414
 		<script type="text/javascript">jQuery(document).ready(function(){ jQuery('#PaymentRequest_cic').submit(); });</script>
415 415
 		<div class="paypalPaymentLoading"><span><?php _e('Redirect to the CIC site in progress, please wait...', 'wpshop'); ?></span></div>
416
-		<form action="<?php echo $oTpe->sUrlPaiement;?>" method="post" id="PaymentRequest_cic">
417
-			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion;?>" />
418
-			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero;?>" />
419
-			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate;?>" />
420
-			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise;?>" />
421
-			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference;?>" />
422
-			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC;?>" />
423
-			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO;?>" />
424
-			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK;?>" />
425
-			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO;?>" />
426
-			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue;?>" />
427
-			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete;?>" />
428
-			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre);?>" />
429
-			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail;?>" />
416
+		<form action="<?php echo $oTpe->sUrlPaiement; ?>" method="post" id="PaymentRequest_cic">
417
+			<input type="hidden" name="version"             id="version"        value="<?php echo $oTpe->sVersion; ?>" />
418
+			<input type="hidden" name="TPE"                 id="TPE"            value="<?php echo $oTpe->sNumero; ?>" />
419
+			<input type="hidden" name="date"                id="date"           value="<?php echo $sDate; ?>" />
420
+			<input type="hidden" name="montant"             id="montant"        value="<?php echo $sMontant . $sDevise; ?>" />
421
+			<input type="hidden" name="reference"           id="reference"      value="<?php echo $sReference; ?>" />
422
+			<input type="hidden" name="MAC"                 id="MAC"            value="<?php echo $sMAC; ?>" />
423
+			<input type="hidden" name="url_retour"          id="url_retour"     value="<?php echo $oTpe->sUrlKO; ?>" />
424
+			<input type="hidden" name="url_retour_ok"       id="url_retour_ok"  value="<?php echo $oTpe->sUrlOK; ?>" />
425
+			<input type="hidden" name="url_retour_err"      id="url_retour_err" value="<?php echo $oTpe->sUrlKO; ?>" />
426
+			<input type="hidden" name="lgue"                id="lgue"           value="<?php echo $oTpe->sLangue; ?>" />
427
+			<input type="hidden" name="societe"             id="societe"        value="<?php echo $oTpe->sCodeSociete; ?>" />
428
+			<input type="hidden" name="texte-libre"         id="texte-libre"    value="<?php echo HtmlEncode($sTexteLibre); ?>" />
429
+			<input type="hidden" name="mail"                id="mail"           value="<?php echo $sEmail; ?>" />
430 430
 			<!-- Uniquement pour le Paiement fractionn� -->
431
-			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch;?>" />
432
-			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1;?>" />
433
-			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1;?>" />
434
-			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2;?>" />
435
-			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2;?>" />
436
-			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3;?>" />
437
-			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3;?>" />
438
-			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4;?>" />
439
-			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4;?>" />
431
+			<input type="hidden" name="nbrech"              id="nbrech"         value="<?php echo $sNbrEch; ?>" />
432
+			<input type="hidden" name="dateech1"            id="dateech1"       value="<?php echo $sDateEcheance1; ?>" />
433
+			<input type="hidden" name="montantech1"         id="montantech1"    value="<?php echo $sMontantEcheance1; ?>" />
434
+			<input type="hidden" name="dateech2"            id="dateech2"       value="<?php echo $sDateEcheance2; ?>" />
435
+			<input type="hidden" name="montantech2"         id="montantech2"    value="<?php echo $sMontantEcheance2; ?>" />
436
+			<input type="hidden" name="dateech3"            id="dateech3"       value="<?php echo $sDateEcheance3; ?>" />
437
+			<input type="hidden" name="montantech3"         id="montantech3"    value="<?php echo $sMontantEcheance3; ?>" />
438
+			<input type="hidden" name="dateech4"            id="dateech4"       value="<?php echo $sDateEcheance4; ?>" />
439
+			<input type="hidden" name="montantech4"         id="montantech4"    value="<?php echo $sMontantEcheance4; ?>" />
440 440
 			<!-- -->
441 441
 			<noscript><input type="submit" name="bouton"              id="bouton"         value="Connexion / Connection" /></noscript>
442 442
 		</form>
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 	}
449 449
 
450 450
 
451
-	function display_admin_part( $k ) {
451
+	function display_admin_part($k) {
452 452
 		$cmcic_params = get_option('wpshop_cmcic_params', array());
453 453
 		$output = '';
454
-		$output .= '<h2>' .__('CIC configurations', 'wpshop'). '</h2>';
454
+		$output .= '<h2>' . __('CIC configurations', 'wpshop') . '</h2>';
455 455
 		$output .= '<div class="wps_shipping_mode_configuration_part">';
456
-		$output .= '<label class="simple_right">'.__('Key', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="'.$cmcic_params['cle'].'" /><br />';
457
-		$output .= '<label class="simple_right">'.__('TPE', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="'.$cmcic_params['tpe'].'" /><br />';
458
-		$output .= '<label class="simple_right">'.__('Version', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="'.$cmcic_params['version'].'" /> => 3.0<br />';
459
-		$output .= '<label class="simple_right">'.__('Serveur', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="'.$cmcic_params['serveur'].'" /><br />';
460
-		$output .= '<label class="simple_right">'.__('Company code', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="'.$cmcic_params['codesociete'].'" /><br />';
456
+		$output .= '<label class="simple_right">' . __('Key', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="' . $cmcic_params['cle'] . '" /><br />';
457
+		$output .= '<label class="simple_right">' . __('TPE', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="' . $cmcic_params['tpe'] . '" /><br />';
458
+		$output .= '<label class="simple_right">' . __('Version', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="' . $cmcic_params['version'] . '" /> => 3.0<br />';
459
+		$output .= '<label class="simple_right">' . __('Serveur', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="' . $cmcic_params['serveur'] . '" /><br />';
460
+		$output .= '<label class="simple_right">' . __('Company code', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="' . $cmcic_params['codesociete'] . '" /><br />';
461 461
 		$output .= '</div>';
462 462
 
463 463
 		return $output;
Please login to merge, or discard this patch.
includes/librairies/payments/payment.class.php 4 patches
Doc Comments   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,6 +38,10 @@  discard block
 block discarded – undo
38 38
 		return $url;
39 39
 	}
40 40
 
41
+	/**
42
+	 * @param string $param
43
+	 * @param string $value
44
+	 */
41 45
 	public static function construct_url_parameters($url, $param, $value) {
42 46
 		$interoguation_marker_pos = strpos($url, '?');
43 47
 		if($interoguation_marker_pos===false)
@@ -86,7 +90,7 @@  discard block
 block discarded – undo
86 90
 	 * Display the list of payment methods available
87 91
 	 *
88 92
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89
-	 * @return string The different payment method
93
+	 * @return string[] The different payment method
90 94
 	 */
91 95
 	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
92 96
 		$output = '';
@@ -377,7 +381,7 @@  discard block
 block discarded – undo
377 381
 	 * Allows to inform customer that he would pay a partial amount on this order
378 382
 	 *
379 383
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380
-	 * @return array The amount to pay / A html output with amount to pay and different information
384
+	 * @return string The amount to pay / A html output with amount to pay and different information
381 385
 	 */
382 386
 	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
383 387
 		$output = '';
@@ -482,6 +486,7 @@  discard block
 block discarded – undo
482 486
 	 * @param array $order_meta The complete order meta informations
483 487
 	 * @param integer $payment_index The payment to add/update data for
484 488
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
489
+	 * @param integer $order_id
485 490
 	 * @return array The order new meta informations
486 491
 	 */
487 492
 	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 	/**
221
-	* Reduce the stock regarding the order
222
-	*/
221
+	 * Reduce the stock regarding the order
222
+	 */
223 223
 	function the_order_payment_is_completed($order_id, $txn_id = null) {
224 224
 		// Donnees commandes
225 225
 		$order = get_post_meta($order_id, '_order_postmeta', true);
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Get payment method
297
-	*/
296
+	 * Get payment method
297
+	 */
298 298
 	function get_payment_method($post_id){
299 299
 		$pm = __('Nc','wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Set payment transaction number
325
-	*/
324
+	 * Set payment transaction number
325
+	 */
326 326
 	function display_payment_receiver_interface($post_id) {
327 327
 		$payment_validation = '';
328 328
 		$display_button = false;
Please login to merge, or discard this patch.
Braces   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -40,9 +42,11 @@  discard block
 block discarded – undo
40 42
 
41 43
 	public static function construct_url_parameters($url, $param, $value) {
42 44
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
45
+		if($interoguation_marker_pos===false) {
46
+					return $url.'?'.$param.'='.$value;
47
+		} else {
48
+			return $url.'&'.$param.'='.$value;
49
+		}
46 50
 	}
47 51
 
48 52
 	/**
@@ -167,8 +171,7 @@  discard block
 block discarded – undo
167 171
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168 172
 					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169 173
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
170
-					}
171
-					else {
174
+					} else {
172 175
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
173 176
 					}
174 177
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
@@ -200,8 +203,7 @@  discard block
 block discarded – undo
200 203
 
201 204
 						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202 205
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
203
-						}
204
-						else {
206
+						} else {
205 207
 							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
206 208
 						}
207 209
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
@@ -629,8 +631,7 @@  discard block
 block discarded – undo
629 631
 					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
630 632
 						$payment_status = 'pos';
631 633
 					}
632
-				}
633
-				else {
634
+				} else {
634 635
 					$payment_status = 'partially_paid';
635 636
 				}
636 637
 
@@ -655,16 +656,14 @@  discard block
 block discarded – undo
655 656
 				}
656 657
 
657 658
 				$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
658
-			}
659
-			else {
659
+			} else {
660 660
 				$payment_status = $bank_response;
661 661
 			}
662 662
 
663 663
 			$order_meta['order_status'] = $payment_status;
664 664
 			if( !$save_metadata ) {
665 665
 				return 	$order_meta;
666
-			}
667
-			else {
666
+			} else {
668 667
 				update_post_meta( $order_id, '_order_postmeta', $order_meta);
669 668
 			}
670 669
 			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
Please login to merge, or discard this patch.
Spacing   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$wpshop_paypal = new wpshop_paypal();
22 22
 		// If the CIC payment method is active
23
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
24
-		if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) {
23
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
24
+		if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) {
25 25
 			$wpshop_cic = new wpshop_CIC();
26 26
 		}
27
-		wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse');
27
+		wpshop_tools::create_custom_hook('wpshop_bankserver_reponse');
28 28
 
29 29
 	}
30 30
 
31 31
 	public static function get_success_payment_url() {
32
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) );
32
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id')));
33 33
 		return self::construct_url_parameters($url, 'paymentResult', 'success');
34 34
 	}
35 35
 
36 36
 	public static function get_cancel_payment_url() {
37
-		$url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) );
37
+		$url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id')));
38 38
 		return $url;
39 39
 	}
40 40
 
41 41
 	public static function construct_url_parameters($url, $param, $value) {
42 42
 		$interoguation_marker_pos = strpos($url, '?');
43
-		if($interoguation_marker_pos===false)
44
-			return $url.'?'.$param.'='.$value;
45
-		else return $url.'&'.$param.'='.$value;
43
+		if ($interoguation_marker_pos === false)
44
+			return $url . '?' . $param . '=' . $value;
45
+		else return $url . '&' . $param . '=' . $value;
46 46
 	}
47 47
 
48 48
 	/**
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
 	public static function wpshop_payment_result() {
52 52
 		global $wpdb;
53 53
 		$user_ID = get_current_user_id();
54
-		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
-		$order_post_id = $wpdb->get_var( $query );
56
-		if ( !empty($order_post_id) ) {
57
-			$order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true);
58
-			if ( !empty($order_postmeta) ) {
59
-				switch ( $order_postmeta ) {
54
+		$query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID);
55
+		$order_post_id = $wpdb->get_var($query);
56
+		if (!empty($order_post_id)) {
57
+			$order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true);
58
+			if (!empty($order_postmeta)) {
59
+				switch ($order_postmeta) {
60 60
 					case 'awaiting_payment':
61
-						echo __('We wait your payment.','wpshop');
61
+						echo __('We wait your payment.', 'wpshop');
62 62
 					break;
63 63
 					case 'completed':
64
-						echo __('Thank you ! Your payment has been recorded.','wpshop');
64
+						echo __('Thank you ! Your payment has been recorded.', 'wpshop');
65 65
 					break;
66 66
 					case 'partially_paid':
67
-						echo __('Thank you ! Your first payment has been recorded.','wpshop');
67
+						echo __('Thank you ! Your first payment has been recorded.', 'wpshop');
68 68
 					break;
69 69
 					default:
70
-						echo __('Your payment and your order has been cancelled.','wpshop');
70
+						echo __('Your payment and your order has been cancelled.', 'wpshop');
71 71
 					break;
72 72
 				}
73 73
 			}
@@ -88,56 +88,56 @@  discard block
 block discarded – undo
88 88
 	 * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later
89 89
 	 * @return string The different payment method
90 90
 	 */
91
-	function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
91
+	function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
92 92
 		$output = '';
93 93
 		/**	Get available payment method	*/
94 94
 		$paymentMethod = get_option('wpshop_paymentMethod', array());
95 95
 
96
-		if(!empty($order_id) && is_numeric($order_id)) {
97
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
96
+		if (!empty($order_id) && is_numeric($order_id)) {
97
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
98 98
 		}
99 99
 
100 100
 		if ($cart_type == 'cart') {
101 101
 			$payment_methods = array();
102
-			if(!empty($paymentMethod['paypal'])) {
102
+			if (!empty($paymentMethod['paypal'])) {
103 103
 				$payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'),
104 104
 														'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png',
105
-														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop')
105
+														'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop')
106 106
 								 );
107 107
 			}
108
-			if(!empty($paymentMethod['checks'])) {
108
+			if (!empty($paymentMethod['checks'])) {
109 109
 				$payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'),
110 110
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
111
-						'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop')
111
+						'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop')
112 112
 				);
113 113
 			}
114
-			if(!empty($paymentMethod['banktransfer'])) {
114
+			if (!empty($paymentMethod['banktransfer'])) {
115 115
 				$payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'),
116 116
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png',
117
-						'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop')
117
+						'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop')
118 118
 				);
119 119
 			}
120
-			if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
120
+			if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) {
121 121
 				$payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'),
122 122
 						'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg',
123
-						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop')
123
+						'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop')
124 124
 				);
125 125
 			}
126 126
 			$payment_methods = apply_filters('wpshop_payment_method', $payment_methods);
127 127
 
128 128
 			$payment_method_table = array();
129 129
 
130
-			if ( !empty( $paymentMethod['display_position'] ) ) {
130
+			if (!empty($paymentMethod['display_position'])) {
131 131
 				$position_determinated = false;
132
-				foreach ( $paymentMethod['display_position'] as $key => $position) {
133
-					if ( $position != null) {
132
+				foreach ($paymentMethod['display_position'] as $key => $position) {
133
+					if ($position != null) {
134 134
 						$position_determinated = true;
135 135
 					}
136 136
 				}
137
-				if ( $position_determinated ) {
138
-					for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) {
139
-						foreach ( $paymentMethod['display_position'] as $key => $position ) {
140
-							if ( $position == $i  && !empty($paymentMethod[$key])) {
137
+				if ($position_determinated) {
138
+					for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) {
139
+						foreach ($paymentMethod['display_position'] as $key => $position) {
140
+							if ($position == $i && !empty($paymentMethod[$key])) {
141 141
 								if ($key == 'checks') {
142 142
 									$key = 'check';
143 143
 								}
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 					$payment_methods = $payment_method_table;
149 149
 				}
150 150
 			}
151
-			if (!empty($payment_methods) ) {
151
+			if (!empty($payment_methods)) {
152 152
 
153
-				foreach( $payment_methods as  $payment_method_identifier =>  $payment_method_def ) {
153
+				foreach ($payment_methods as  $payment_method_identifier =>  $payment_method_def) {
154 154
 					$tpl_component = array();
155 155
 					$checked = $active = '';
156 156
 					$payment_identifier_for_test = $payment_method_identifier;
157 157
 					if ($payment_method_identifier == 'check') {
158 158
 						$payment_identifier_for_test = 'checks';
159 159
 					}
160
-					if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
160
+					if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) {
161 161
 						$checked = ' checked="checked"';
162 162
 						$active = ' active';
163 163
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active;
166 166
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked;
167 167
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier;
168
-					if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) {
169
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : '';
168
+					if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) {
169
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : '';
170 170
 					}
171 171
 					else {
172
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : '';
172
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : '';
173 173
 					}
174 174
 					//$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon'];
175 175
 					$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name'];
@@ -180,32 +180,32 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 		}
182 182
 
183
-		return array( $output, $paymentMethod['mode'] );
183
+		return array($output, $paymentMethod['mode']);
184 184
 	}
185 185
 
186 186
 
187
-	public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') {
188
-		$payment_option = get_option( 'wps_payment_mode' );
187
+	public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') {
188
+		$payment_option = get_option('wps_payment_mode');
189 189
 		$output = '';
190
-		if(!empty($order_id) && is_numeric($order_id)) {
191
-			$output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />';
190
+		if (!empty($order_id) && is_numeric($order_id)) {
191
+			$output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />';
192 192
 		}
193
-		if( $cart_type == 'cart' ) {
194
-			if ( !empty($payment_option) && !empty($payment_option['mode']) ) {
195
-				foreach( $payment_option['mode'] as $payment_id => $payment_config ) {
196
-					if( !empty($payment_config['active']) ) {
197
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : '');
198
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : '');
193
+		if ($cart_type == 'cart') {
194
+			if (!empty($payment_option) && !empty($payment_option['mode'])) {
195
+				foreach ($payment_option['mode'] as $payment_id => $payment_config) {
196
+					if (!empty($payment_config['active'])) {
197
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : '');
198
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : '');
199 199
 						$tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id;
200 200
 
201
-						if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) {
202
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : '';
201
+						if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) {
202
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : '';
203 203
 						}
204 204
 						else {
205
-							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : '';
205
+							$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : '';
206 206
 						}
207
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : '';
208
-						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : '';
207
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : '';
208
+						$tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : '';
209 209
 						$output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id));
210 210
 						unset($tpl_component);
211 211
 					}
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$wps_message = new wps_message_ctr();
229 229
 
230
-		if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
-			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' );
232
-			$first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
233
-			$last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
230
+		if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) {
231
+			$email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '');
232
+			$first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
233
+			$last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
234 234
 
235 235
 			// Envoie du message de confirmation de paiement au client
236
-			switch($order['payment_method']) {
236
+			switch ($order['payment_method']) {
237 237
 				case 'check':
238 238
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']));
239 239
 				break;
@@ -250,24 +250,24 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 
253
-	function setOrderPaymentStatus( $order_id, $payment_status ) {
253
+	function setOrderPaymentStatus($order_id, $payment_status) {
254 254
 		/**	Get order main information	*/
255 255
 		$order = get_post_meta($order_id, '_order_postmeta', true);
256 256
 		$send_email = false;
257 257
 
258
-		if ( !empty($order) ) {
258
+		if (!empty($order)) {
259 259
 			/**	Change order status to given status	*/
260 260
 			$order['order_status'] = strtolower($payment_status);
261 261
 			/**	Put order status into a single meta, allowing to use it easily later	*/
262 262
 			update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
263 263
 
264 264
 			/**	In case the set status is completed, make specific treatment: add the completed date	*/
265
-			if ( $payment_status == 'completed' ) {
265
+			if ($payment_status == 'completed') {
266 266
 				/**	Read order items list, if not empty and check if each item is set to manage stock or not */
267 267
 				if (!empty($order['order_items'])) {
268 268
 					foreach ($order['order_items'] as $o) {
269
-						$product = wpshop_products::get_product_data( $o['item_id'] );
270
-						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) {
269
+						$product = wpshop_products::get_product_data($o['item_id']);
270
+						if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) {
271 271
 							wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']);
272 272
 						}
273 273
 					}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			/**	Send email to customer when specific case need it	*/
284
-			if ( $send_email ) {
284
+			if ($send_email) {
285 285
 				/**	Get information about customer that make the order	*/
286 286
 				$order_info = get_post_meta($order_id, '_order_info', true);
287 287
 				$mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']);
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
 	/**
296 296
 	* Get payment method
297 297
 	*/
298
-	function get_payment_method($post_id){
299
-		$pm = __('Nc','wpshop');
298
+	function get_payment_method($post_id) {
299
+		$pm = __('Nc', 'wpshop');
300 300
 		$order_postmeta = get_post_meta($post_id, '_order_postmeta', true);
301
-		if ( !empty($order_postmeta['payment_method']) ) {
302
-			switch($order_postmeta['payment_method']){
301
+		if (!empty($order_postmeta['payment_method'])) {
302
+			switch ($order_postmeta['payment_method']) {
303 303
 				case 'check':
304
-					$pm = __('Check','wpshop');
304
+					$pm = __('Check', 'wpshop');
305 305
 				break;
306 306
 				case 'paypal':
307
-					$pm = __('Paypal','wpshop');
307
+					$pm = __('Paypal', 'wpshop');
308 308
 				break;
309 309
 				case 'banktransfer':
310
-					$pm = __('Bank transfer','wpshop');
310
+					$pm = __('Bank transfer', 'wpshop');
311 311
 				break;
312 312
 				case 'cic':
313
-					$pm = __('Credit card','wpshop');
313
+					$pm = __('Credit card', 'wpshop');
314 314
 				break;
315 315
 				default:
316
-					$pm = __('Nc','wpshop');
316
+					$pm = __('Nc', 'wpshop');
317 317
 				break;
318 318
 			}
319 319
 		}
@@ -333,38 +333,38 @@  discard block
 block discarded – undo
333 333
 
334 334
 		$paymentMethod = $paymentMethod['mode'];
335 335
 		$payment_validation .= '
336
-<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" >
337
-	<input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
-	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
336
+<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" >
337
+	<input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/>
338
+	<input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>';
339 339
 
340
-		if(!empty($order_postmeta['payment_method'])){
340
+		if (!empty($order_postmeta['payment_method'])) {
341 341
 			$payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>';
342 342
 		}
343 343
 
344
-		if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
344
+		if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) {
345 345
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>';
346 346
 			$display_button = true;
347 347
 		}
348 348
 
349
-		if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
349
+		if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) {
350 350
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>';
351 351
 			$display_button = true;
352 352
 		}
353 353
 
354
-		$wpshop_paymentMethod = get_option( 'wps_payment_mode' );
355
-		if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) {
354
+		$wpshop_paymentMethod = get_option('wps_payment_mode');
355
+		if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) {
356 356
 			$payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>';
357 357
 			$display_button = true;
358 358
 		}
359 359
 
360
-		if(empty($payment_transaction)){
361
-			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />';
360
+		if (empty($payment_transaction)) {
361
+			$payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . '&nbsp;:&nbsp;<input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />';
362 362
 			$display_button = true;
363 363
 		}
364 364
 
365
-		if($display_button){
365
+		if ($display_button) {
366 366
 			$payment_validation .= '
367
-		<br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>';
367
+		<br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>';
368 368
 		}
369 369
 
370 370
 		$payment_validation .= '
@@ -379,21 +379,21 @@  discard block
 block discarded – undo
379 379
 	 * @param float $current_order_total The current order total to pay before partial amount calcul
380 380
 	 * @return array The amount to pay / A html output with amount to pay and different information
381 381
 	 */
382
-	function partial_payment_calcul( $current_order_total, $for = 'for_all' ) {
382
+	function partial_payment_calcul($current_order_total, $for = 'for_all') {
383 383
 		$output = '';
384 384
 		$tpl_component = array();
385 385
 
386 386
 		/**	Get current configuration	*/
387 387
 		$partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array()));
388
-		if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) {
388
+		if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) {
389 389
 			$amount_of_partial_payment = 0;
390
-			if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) {
390
+			if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) {
391 391
 				$amount_of_partial_payment = $partial_payment_configuration[$for]['value'];
392 392
 			}
393 393
 
394 394
 			$partial_amount_to_pay = 0;
395 395
 			$type_of_partial_payment = null;
396
-			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) {
396
+			if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) {
397 397
 				switch ($partial_payment_configuration[$for]['type']) {
398 398
 					case 'percentage':
399 399
 						$type_of_partial_payment = '%';
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	function set_payment_transaction_number($order_id, $transaction_number) {
454 454
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
455 455
 
456
-		if ( !empty($order_postmeta['order_payment']['received']) ) {
456
+		if (!empty($order_postmeta['order_payment']['received'])) {
457 457
 			if (count($order_postmeta['order_payment']['received']) == 1) {
458 458
 				$order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number;
459 459
 			}
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param integer $order_id
469 469
 	 */
470
-	function save_payment_return_data( $order_id ) {
470
+	function save_payment_return_data($order_id) {
471 471
 		$data = wpshop_tools::getMethode();
472 472
 
473
-		$current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true);
473
+		$current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true);
474 474
 		$current_payment_return[] = $data;
475 475
 
476 476
 		update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return);
@@ -484,23 +484,23 @@  discard block
 block discarded – undo
484 484
 	 * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount')
485 485
 	 * @return array The order new meta informations
486 486
 	 */
487
-	public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) {
488
-
489
-		$order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null;
490
-		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null;
491
-		$order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null;
492
-		$order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id();
493
-		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null;
494
-		$order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null;
495
-		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null;
487
+	public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) {
488
+
489
+		$order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null;
490
+		$order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null;
491
+		$order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null;
492
+		$order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id();
493
+		$order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null;
494
+		$order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null;
495
+		$order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null;
496 496
 		$order_meta['order_payment']['received'][$payment_index]['comment'] = '';
497 497
 
498 498
 		$order_info = get_post_meta($order_id, '_order_info', true);
499
-		if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
499
+		if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) {
500 500
 
501 501
 			/**	Generate an invoice number for the current payment. Check if the payment is complete or not	*/
502
-			if ( empty($order_meta['order_invoice_ref']) ) {
503
-				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id );
502
+			if (empty($order_meta['order_invoice_ref'])) {
503
+				$order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id);
504 504
 			}
505 505
 		}
506 506
 
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
 	 * @param string $payment_method
514 514
 	 * @return integer $key : array id of [order_payment][received] in the order postmeta
515 515
 	 */
516
-	public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) {
516
+	public static function get_order_waiting_payment_array_id($oid, $payment_method) {
517 517
 		$key = 0;
518
-		$order_meta = get_post_meta( $oid, '_order_postmeta', true);
519
-		if ( !empty($order_meta) ) {
520
-			$key = count( $order_meta['order_payment']['received'] );
521
-			foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) {
522
-				if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) {
518
+		$order_meta = get_post_meta($oid, '_order_postmeta', true);
519
+		if (!empty($order_meta)) {
520
+			$key = count($order_meta['order_payment']['received']);
521
+			foreach ($order_meta['order_payment']['received'] as $k => $payment_test) {
522
+				if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) {
523 523
 					$key = $k;
524 524
 				}
525 525
 			}
@@ -534,52 +534,52 @@  discard block
 block discarded – undo
534 534
 	 * @param array $params_array
535 535
 	 * @return string
536 536
 	 */
537
-	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) {
537
+	public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) {
538 538
 		global $wpshop_payment; global $wpdb;
539
-		$order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true);
539
+		$order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true);
540 540
 
541 541
 		$wps_message = new wps_message_ctr();
542
-		if ( !empty($order_meta) ) {
542
+		if (!empty($order_meta)) {
543 543
 			$order_info = get_post_meta($order_id, '_order_info', true);
544
-			$user_data = get_userdata( $order_meta['customer_id'] );
545
-			$email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : '';
544
+			$user_data = get_userdata($order_meta['customer_id']);
545
+			$email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : '';
546 546
 // 			$email = ( !empty($order_info) &&  !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ;
547
-			$first_name = (!empty($order_info) && !empty($order_info['billing']) &&  !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' );
548
-			$last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' );
547
+			$first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '');
548
+			$last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '');
549 549
 
550
-			$key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']);
550
+			$key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']);
551 551
 			$order_grand_total = $order_meta['order_grand_total'];
552
-			$total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 );
553
-			foreach ( $order_meta['order_payment']['received'] as $received ) {
554
-				$total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 );
552
+			$total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0);
553
+			foreach ($order_meta['order_payment']['received'] as $received) {
554
+				$total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0);
555 555
 			}
556 556
 			$order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received;
557
-			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response );
557
+			$order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response);
558 558
 
559 559
 			if ($bank_response == 'completed') {
560 560
 
561
-				if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) {
561
+				if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) {
562 562
 					$payment_status = 'completed';
563 563
 
564
-					$order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : $order_meta['order_invoice_ref'] ;
564
+					$order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : $order_meta['order_invoice_ref'];
565 565
 					$order_meta['order_invoice_date'] = current_time('mysql', 0);
566 566
 
567 567
 					if (!empty($order_meta['order_items'])) {
568 568
 						foreach ($order_meta['order_items'] as $item_id => $o) {
569 569
 							$pid = $o['item_id'];
570
-							if (strpos($item_id,'__') !== false) {
571
-								$product_data_id = explode( '__', $item_id );
572
-								$pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid;
570
+							if (strpos($item_id, '__') !== false) {
571
+								$product_data_id = explode('__', $item_id);
572
+								$pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid;
573 573
 							}
574
-							$product = wpshop_products::get_product_data( $pid );
575
-							if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
576
-								$parent_def = wpshop_products::get_parent_variation ( $pid );
574
+							$product = wpshop_products::get_product_data($pid);
575
+							if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
576
+								$parent_def = wpshop_products::get_parent_variation($pid);
577 577
 								$parent_post = $parent_def['parent_post'];
578
-								$product = wpshop_products::get_product_data( $parent_post->ID );
578
+								$product = wpshop_products::get_product_data($parent_post->ID);
579 579
 							}
580 580
 
581
-							if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) {
582
-								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid );
581
+							if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) {
582
+								wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid);
583 583
 							}
584 584
 						}
585 585
 					}
@@ -588,45 +588,45 @@  discard block
 block discarded – undo
588 588
 					update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0));
589 589
 
590 590
 					/** Check if the order content a downloadable product **/
591
-					if ( !empty($order_meta['order_items']) ) {
592
-						foreach( $order_meta['order_items'] as $key_value => $item ) {
591
+					if (!empty($order_meta['order_items'])) {
592
+						foreach ($order_meta['order_items'] as $key_value => $item) {
593 593
 							$key_value = $item['item_id'];
594 594
 							/** Check if it's a product with signle variation, check the parent product **/
595
-							if ( !empty($item['item_id']) && get_post_type( $item['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
596
-								$parent_item = wpshop_products::get_parent_variation( $item['item_id'] );
595
+							if (!empty($item['item_id']) && get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
596
+								$parent_item = wpshop_products::get_parent_variation($item['item_id']);
597 597
 								$key_value = $parent_item['parent_post']->ID;
598 598
 								$parent_post_metadata = $parent_item['parent_post_meta'];
599
-								if ( !empty($parent_post_metadata['is_downloadable_']) ) {
600
-									$query = $wpdb->prepare( 'SELECT value FROM '. WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS .' WHERE id = %d', $parent_post_metadata['is_downloadable_'] );
601
-									$downloadable_option_value = $wpdb->get_var( $query );
602
-									if ( !empty( $downloadable_option_value) ) {
599
+								if (!empty($parent_post_metadata['is_downloadable_'])) {
600
+									$query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_post_metadata['is_downloadable_']);
601
+									$downloadable_option_value = $wpdb->get_var($query);
602
+									if (!empty($downloadable_option_value)) {
603 603
 										$item['item_is_downloadable_'] = $downloadable_option_value;
604 604
 									}
605 605
 
606 606
 								}
607 607
 							}
608 608
 
609
-							if ( !empty($item) && !empty($item['item_is_downloadable_']) && ( __( $item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __( $item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop') ) ) {
610
-								$download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_'.$order_id, true);
609
+							if (!empty($item) && !empty($item['item_is_downloadable_']) && (__($item['item_is_downloadable_'], 'wpshop') == __('Yes', 'wpshop') || __($item['item_is_downloadable_'], 'wpshop') == __('yes', 'wpshop'))) {
610
+								$download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_' . $order_id, true);
611 611
 
612
-								if ( !empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code']) ) {
613
-									$link = '<a href="' . admin_url( 'admin-post.php?action=download_file&amp;oid=' . $order_id . '&amp;download=' . $download_codes[$key_value]['download_code'] ) . '">' . __('Download','wpshop') . '</a>';
614
-									$wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array() );
612
+								if (!empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code'])) {
613
+									$link = '<a href="' . admin_url('admin-post.php?action=download_file&amp;oid=' . $order_id . '&amp;download=' . $download_codes[$key_value]['download_code']) . '">' . __('Download', 'wpshop') . '</a>';
614
+									$wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array());
615 615
 								}
616 616
 							}
617 617
 						}
618 618
 					}
619 619
 
620 620
 					// Send confirmation e-mail to administrator
621
-					if ( empty($_SESSION['wps-pos-addon']) ) {
621
+					if (empty($_SESSION['wps-pos-addon'])) {
622 622
 						$email_option = get_option('wpshop_emails');
623
-						if(  !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){
624
-							wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data );
623
+						if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) {
624
+							wpshop_checkout::send_order_email_to_administrator($order_id, $user_data);
625 625
 						}
626 626
 					}
627 627
 
628 628
 					// POS Status
629
-					if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) {
629
+					if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') {
630 630
 						$payment_status = 'pos';
631 631
 					}
632 632
 				}
@@ -635,23 +635,23 @@  discard block
 block discarded – undo
635 635
 				}
636 636
 
637 637
 				$order_meta['order_status'] = $payment_status;
638
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
638
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
639 639
 				$save_metadata = false;
640 640
 
641
-				$allow_send_invoice = get_option( 'wpshop_send_invoice' );
642
-				$invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : '';
641
+				$allow_send_invoice = get_option('wpshop_send_invoice');
642
+				$invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, $order_meta['order_payment']['received'][$key]['invoice_ref']) : '';
643 643
 
644
-				$email_option = get_option( 'wpshop_emails' );
644
+				$email_option = get_option('wpshop_emails');
645 645
 
646
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
647
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
646
+				$shipping_mode_option = get_option('wps_shipping_mode');
647
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
648 648
 
649
-				$payment_method_option = get_option( 'wps_payment_mode' );
650
-				$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode'])  && !empty($order_meta['order_payment']['customer_choice']['method'])  && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
649
+				$payment_method_option = get_option('wps_payment_mode');
650
+				$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
651 651
 
652 652
 
653
-				if ( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' ) {
654
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method ) );
653
+				if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed') {
654
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method));
655 655
 				}
656 656
 
657 657
 				$wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file);
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
 			}
662 662
 
663 663
 			$order_meta['order_status'] = $payment_status;
664
-			if( !$save_metadata ) {
664
+			if (!$save_metadata) {
665 665
 				return 	$order_meta;
666 666
 			}
667 667
 			else {
668
-				update_post_meta( $order_id, '_order_postmeta', $order_meta);
668
+				update_post_meta($order_id, '_order_postmeta', $order_meta);
669 669
 			}
670
-			update_post_meta( $order_id, '_wpshop_order_status', $payment_status);
670
+			update_post_meta($order_id, '_wpshop_order_status', $payment_status);
671 671
 		}
672 672
 	}
673 673
 
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 	 * @param integer $order_id The order identifier we want to get the old transaction reference for
680 680
 	 * @return integer
681 681
 	 */
682
-	public static function get_payment_transaction_number_old_way($order_id){
682
+	public static function get_payment_transaction_number_old_way($order_id) {
683 683
 		$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
684 684
 		$transaction_indentifier = 0;
685
-		if(!empty($order_postmeta['payment_method'])){
686
-			switch($order_postmeta['payment_method']){
685
+		if (!empty($order_postmeta['payment_method'])) {
686
+			switch ($order_postmeta['payment_method']) {
687 687
 				case 'check':
688 688
 					$transaction_indentifier = get_post_meta($order_id, '_order_check_number', true);
689 689
 					break;
@@ -702,26 +702,26 @@  discard block
 block discarded – undo
702 702
 		return $transaction_indentifier;
703 703
 	}
704 704
 
705
-	public static function reverify_payment_invoice_ref( $order_id, $index_payment ) {
705
+	public static function reverify_payment_invoice_ref($order_id, $index_payment) {
706 706
 		$status = false;
707
-		$order_meta = get_post_meta( $order_id, '_order_postmeta', true );
708
-		if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) {
707
+		$order_meta = get_post_meta($order_id, '_order_postmeta', true);
708
+		if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) {
709 709
 			$order_invoice = $invoice_ref = false;
710 710
 
711
-			end( $order_meta['order_payment']['received'] );
712
-			$last_payment = key( $order_meta['order_payment']['received'] );
713
-			if( $last_payment == $index_payment ) {
711
+			end($order_meta['order_payment']['received']);
712
+			$last_payment = key($order_meta['order_payment']['received']);
713
+			if ($last_payment == $index_payment) {
714 714
 				$payments = 0;
715
-				foreach( $order_meta['order_payment']['received'] as $payment ) {
716
-					$payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0;
715
+				foreach ($order_meta['order_payment']['received'] as $payment) {
716
+					$payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0;
717 717
 				}
718
-				if( $order_meta['order_grand_total'] <= $payments ) {
719
-					if( $order_meta['order_status'] == 'partially_paid' ) {
720
-						$order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true );
718
+				if ($order_meta['order_grand_total'] <= $payments) {
719
+					if ($order_meta['order_status'] == 'partially_paid') {
720
+						$order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true);
721 721
 						$order_meta['order_status'] = 'completed';
722
-						$status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' );
722
+						$status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed');
723 723
 					}
724
-					if( !empty( $order_meta['order_invoice_ref'] ) ) {
724
+					if (!empty($order_meta['order_invoice_ref'])) {
725 725
 						$invoice_ref = $order_meta['order_invoice_ref'];
726 726
 						$status = true;
727 727
 					} else {
@@ -732,16 +732,16 @@  discard block
 block discarded – undo
732 732
 				$status = true;
733 733
 			}
734 734
 
735
-			if( $status ) {
736
-				if( empty( $invoice_ref ) ) {
737
-					$invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id );
738
-					if( $order_invoice ) {
735
+			if ($status) {
736
+				if (empty($invoice_ref)) {
737
+					$invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id);
738
+					if ($order_invoice) {
739 739
 						$order_meta['order_invoice_ref'] = $invoice_ref;
740 740
 					}
741 741
 				}
742 742
 
743 743
 				$order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref;
744
-				$status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta );
744
+				$status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta);
745 745
 			}
746 746
 		}
747 747
 		return $status;
Please login to merge, or discard this patch.
includes/librairies/pdf/font/makefont/makefont.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -229,6 +229,10 @@
 block discarded – undo
229 229
 	return rtrim($s);
230 230
 }
231 231
 
232
+/**
233
+ * @param string $file
234
+ * @param string $s
235
+ */
232 236
 function SaveToFile($file, $s, $mode)
233 237
 {
234 238
 	$f=fopen($file,'w'.$mode);
Please login to merge, or discard this patch.
includes/librairies/pdf/fpdf.php 3 patches
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -165,6 +165,10 @@  discard block
 block discarded – undo
165 165
 	$this->PDFVersion='1.3';
166 166
 }
167 167
 
168
+/**
169
+ * @param double $left
170
+ * @param double $top
171
+ */
168 172
 function SetMargins($left, $top, $right=null)
169 173
 {
170 174
 	//Set left, top and right margins
@@ -195,6 +199,9 @@  discard block
 block discarded – undo
195 199
 	$this->rMargin=$margin;
196 200
 }
197 201
 
202
+/**
203
+ * @param boolean $auto
204
+ */
198 205
 function SetAutoPageBreak($auto, $margin=0)
199 206
 {
200 207
 	//Set auto page break mode and triggering margin
@@ -203,6 +210,9 @@  discard block
 block discarded – undo
203 210
 	$this->PageBreakTrigger=$this->h-$margin;
204 211
 }
205 212
 
213
+/**
214
+ * @param string $zoom
215
+ */
206 216
 function SetDisplayMode($zoom, $layout='continuous')
207 217
 {
208 218
 	//Set display mode in viewer
@@ -216,6 +226,9 @@  discard block
 block discarded – undo
216 226
 		$this->Error('Incorrect layout display mode: '.$layout);
217 227
 }
218 228
 
229
+/**
230
+ * @param boolean $compress
231
+ */
219 232
 function SetCompression($compress)
220 233
 {
221 234
 	//Set page compression
@@ -271,6 +284,9 @@  discard block
 block discarded – undo
271 284
 	$this->AliasNbPages=$alias;
272 285
 }
273 286
 
287
+/**
288
+ * @param string $msg
289
+ */
274 290
 function Error($msg)
275 291
 {
276 292
 	//Fatal error
@@ -444,6 +460,12 @@  discard block
 block discarded – undo
444 460
 	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
445 461
 }
446 462
 
463
+/**
464
+ * @param integer $x
465
+ * @param integer $y
466
+ * @param integer $w
467
+ * @param integer $h
468
+ */
447 469
 function Rect($x, $y, $w, $h, $style='')
448 470
 {
449 471
 	//Draw a rectangle
@@ -504,6 +526,9 @@  discard block
 block discarded – undo
504 526
 	}
505 527
 }
506 528
 
529
+/**
530
+ * @param string $family
531
+ */
507 532
 function SetFont($family, $style='', $size=0)
508 533
 {
509 534
 	//Select a font; size given in points
@@ -595,6 +620,10 @@  discard block
 block discarded – undo
595 620
 	$this->links[$link]=array($page, $y);
596 621
 }
597 622
 
623
+/**
624
+ * @param double $y
625
+ * @param string $link
626
+ */
598 627
 function Link($x, $y, $w, $h, $link)
599 628
 {
600 629
 	//Put a link on the page
@@ -697,6 +726,11 @@  discard block
 block discarded – undo
697 726
 		$this->x+=$w;
698 727
 }
699 728
 
729
+/**
730
+ * @param integer $w
731
+ * @param integer $h
732
+ * @param string $txt
733
+ */
700 734
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
701 735
 {
702 736
 	//Output text with automatic or explicit line breaks
@@ -988,6 +1022,10 @@  discard block
 block discarded – undo
988 1022
 		$this->y=$this->h+$y;
989 1023
 }
990 1024
 
1025
+/**
1026
+ * @param integer $x
1027
+ * @param integer $y
1028
+ */
991 1029
 function SetXY($x, $y)
992 1030
 {
993 1031
 	//Set x and y positions
@@ -1080,6 +1118,9 @@  discard block
 block discarded – undo
1080 1118
 		@set_magic_quotes_runtime(0);
1081 1119
 }
1082 1120
 
1121
+/**
1122
+ * @param string $format
1123
+ */
1083 1124
 function _getpageformat($format)
1084 1125
 {
1085 1126
 	$format=strtolower($format);
@@ -1096,6 +1137,10 @@  discard block
 block discarded – undo
1096 1137
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1138
 }
1098 1139
 
1140
+/**
1141
+ * @param string $orientation
1142
+ * @param string $format
1143
+ */
1099 1144
 function _beginpage($orientation, $format)
1100 1145
 {
1101 1146
 	$this->page++;
@@ -1226,6 +1271,9 @@  discard block
 block discarded – undo
1226 1271
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1272
 }
1228 1273
 
1274
+/**
1275
+ * @param string $file
1276
+ */
1229 1277
 function _parsepng($file)
1230 1278
 {
1231 1279
 	//Extract info from a PNG file
Please login to merge, or discard this patch.
Spacing   +861 added lines, -861 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /*******************************************************************************
@@ -13,360 +13,360 @@  discard block
 block discarded – undo
13 13
 * Auteur :  Olivier PLATHEY                                                    *
14 14
 *******************************************************************************/
15 15
 
16
-define('FPDF_VERSION','1.6');
16
+define('FPDF_VERSION', '1.6');
17 17
 
18 18
 class wpshop_FPDF
19 19
 {
20
-var $page;               //current page number
21
-var $n;                  //current object number
22
-var $offsets;            //array of object offsets
23
-var $buffer;             //buffer holding in-memory PDF
24
-var $pages;              //array containing pages
25
-var $state;              //current document state
26
-var $compress;           //compression flag
27
-var $k;                  //scale factor (number of points in user unit)
28
-var $DefOrientation;     //default orientation
29
-var $CurOrientation;     //current orientation
30
-var $PageFormats;        //available page formats
31
-var $DefPageFormat;      //default page format
32
-var $CurPageFormat;      //current page format
33
-var $PageSizes;          //array storing non-default page sizes
34
-var $wPt,$hPt;           //dimensions of current page in points
35
-var $w,$h;               //dimensions of current page in user unit
36
-var $lMargin;            //left margin
37
-var $tMargin;            //top margin
38
-var $rMargin;            //right margin
39
-var $bMargin;            //page break margin
40
-var $cMargin;            //cell margin
41
-var $x,$y;               //current position in user unit
42
-var $lasth;              //height of last printed cell
43
-var $LineWidth;          //line width in user unit
44
-var $CoreFonts;          //array of standard font names
45
-var $fonts;              //array of used fonts
46
-var $FontFiles;          //array of font files
47
-var $diffs;              //array of encoding differences
48
-var $FontFamily;         //current font family
49
-var $FontStyle;          //current font style
50
-var $underline;          //underlining flag
51
-var $CurrentFont;        //current font info
52
-var $FontSizePt;         //current font size in points
53
-var $FontSize;           //current font size in user unit
54
-var $DrawColor;          //commands for drawing color
55
-var $FillColor;          //commands for filling color
56
-var $TextColor;          //commands for text color
57
-var $ColorFlag;          //indicates whether fill and text colors are different
58
-var $ws;                 //word spacing
59
-var $images;             //array of used images
60
-var $PageLinks;          //array of links in pages
61
-var $links;              //array of internal links
62
-var $AutoPageBreak;      //automatic page breaking
63
-var $PageBreakTrigger;   //threshold used to trigger page breaks
64
-var $InHeader;           //flag set when processing header
65
-var $InFooter;           //flag set when processing footer
66
-var $ZoomMode;           //zoom display mode
67
-var $LayoutMode;         //layout display mode
68
-var $title;              //title
69
-var $subject;            //subject
70
-var $author;             //author
71
-var $keywords;           //keywords
72
-var $creator;            //creator
73
-var $AliasNbPages;       //alias for total number of pages
74
-var $PDFVersion;         //PDF version number
20
+var $page; //current page number
21
+var $n; //current object number
22
+var $offsets; //array of object offsets
23
+var $buffer; //buffer holding in-memory PDF
24
+var $pages; //array containing pages
25
+var $state; //current document state
26
+var $compress; //compression flag
27
+var $k; //scale factor (number of points in user unit)
28
+var $DefOrientation; //default orientation
29
+var $CurOrientation; //current orientation
30
+var $PageFormats; //available page formats
31
+var $DefPageFormat; //default page format
32
+var $CurPageFormat; //current page format
33
+var $PageSizes; //array storing non-default page sizes
34
+var $wPt, $hPt; //dimensions of current page in points
35
+var $w, $h; //dimensions of current page in user unit
36
+var $lMargin; //left margin
37
+var $tMargin; //top margin
38
+var $rMargin; //right margin
39
+var $bMargin; //page break margin
40
+var $cMargin; //cell margin
41
+var $x, $y; //current position in user unit
42
+var $lasth; //height of last printed cell
43
+var $LineWidth; //line width in user unit
44
+var $CoreFonts; //array of standard font names
45
+var $fonts; //array of used fonts
46
+var $FontFiles; //array of font files
47
+var $diffs; //array of encoding differences
48
+var $FontFamily; //current font family
49
+var $FontStyle; //current font style
50
+var $underline; //underlining flag
51
+var $CurrentFont; //current font info
52
+var $FontSizePt; //current font size in points
53
+var $FontSize; //current font size in user unit
54
+var $DrawColor; //commands for drawing color
55
+var $FillColor; //commands for filling color
56
+var $TextColor; //commands for text color
57
+var $ColorFlag; //indicates whether fill and text colors are different
58
+var $ws; //word spacing
59
+var $images; //array of used images
60
+var $PageLinks; //array of links in pages
61
+var $links; //array of internal links
62
+var $AutoPageBreak; //automatic page breaking
63
+var $PageBreakTrigger; //threshold used to trigger page breaks
64
+var $InHeader; //flag set when processing header
65
+var $InFooter; //flag set when processing footer
66
+var $ZoomMode; //zoom display mode
67
+var $LayoutMode; //layout display mode
68
+var $title; //title
69
+var $subject; //subject
70
+var $author; //author
71
+var $keywords; //keywords
72
+var $creator; //creator
73
+var $AliasNbPages; //alias for total number of pages
74
+var $PDFVersion; //PDF version number
75 75
 
76 76
 /*******************************************************************************
77 77
 *                                                                              *
78 78
 *                               Public methods                                 *
79 79
 *                                                                              *
80 80
 *******************************************************************************/
81
-function wpshop_FPDF($orientation='P', $unit='mm', $format='A4')
81
+function wpshop_FPDF($orientation = 'P', $unit = 'mm', $format = 'A4')
82 82
 {
83 83
 	//Some checks
84 84
 	$this->_dochecks();
85 85
 	//Initialization of properties
86
-	$this->page=0;
87
-	$this->n=2;
88
-	$this->buffer='';
89
-	$this->pages=array();
90
-	$this->PageSizes=array();
91
-	$this->state=0;
92
-	$this->fonts=array();
93
-	$this->FontFiles=array();
94
-	$this->diffs=array();
95
-	$this->images=array();
96
-	$this->links=array();
97
-	$this->InHeader=false;
98
-	$this->InFooter=false;
99
-	$this->lasth=0;
100
-	$this->FontFamily='';
101
-	$this->FontStyle='';
102
-	$this->FontSizePt=12;
103
-	$this->underline=false;
104
-	$this->DrawColor='0 G';
105
-	$this->FillColor='0 g';
106
-	$this->TextColor='0 g';
107
-	$this->ColorFlag=false;
108
-	$this->ws=0;
86
+	$this->page = 0;
87
+	$this->n = 2;
88
+	$this->buffer = '';
89
+	$this->pages = array();
90
+	$this->PageSizes = array();
91
+	$this->state = 0;
92
+	$this->fonts = array();
93
+	$this->FontFiles = array();
94
+	$this->diffs = array();
95
+	$this->images = array();
96
+	$this->links = array();
97
+	$this->InHeader = false;
98
+	$this->InFooter = false;
99
+	$this->lasth = 0;
100
+	$this->FontFamily = '';
101
+	$this->FontStyle = '';
102
+	$this->FontSizePt = 12;
103
+	$this->underline = false;
104
+	$this->DrawColor = '0 G';
105
+	$this->FillColor = '0 g';
106
+	$this->TextColor = '0 g';
107
+	$this->ColorFlag = false;
108
+	$this->ws = 0;
109 109
 	//Standard fonts
110
-	$this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
110
+	$this->CoreFonts = array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
111 111
 		'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
112 112
 		'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
113 113
 		'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
114 114
 	//Scale factor
115
-	if($unit=='pt')
116
-		$this->k=1;
117
-	elseif($unit=='mm')
118
-		$this->k=72/25.4;
119
-	elseif($unit=='cm')
120
-		$this->k=72/2.54;
121
-	elseif($unit=='in')
122
-		$this->k=72;
115
+	if ($unit == 'pt')
116
+		$this->k = 1;
117
+	elseif ($unit == 'mm')
118
+		$this->k = 72 / 25.4;
119
+	elseif ($unit == 'cm')
120
+		$this->k = 72 / 2.54;
121
+	elseif ($unit == 'in')
122
+		$this->k = 72;
123 123
 	else
124
-		$this->Error('Incorrect unit: '.$unit);
124
+		$this->Error('Incorrect unit: ' . $unit);
125 125
 	//Page format
126
-	$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
127
-		'letter'=>array(612,792), 'legal'=>array(612,1008));
128
-	if(is_string($format))
129
-		$format=$this->_getpageformat($format);
130
-	$this->DefPageFormat=$format;
131
-	$this->CurPageFormat=$format;
126
+	$this->PageFormats = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28),
127
+		'letter'=>array(612, 792), 'legal'=>array(612, 1008));
128
+	if (is_string($format))
129
+		$format = $this->_getpageformat($format);
130
+	$this->DefPageFormat = $format;
131
+	$this->CurPageFormat = $format;
132 132
 	//Page orientation
133
-	$orientation=strtolower($orientation);
134
-	if($orientation=='p' || $orientation=='portrait')
133
+	$orientation = strtolower($orientation);
134
+	if ($orientation == 'p' || $orientation == 'portrait')
135 135
 	{
136
-		$this->DefOrientation='P';
137
-		$this->w=$this->DefPageFormat[0];
138
-		$this->h=$this->DefPageFormat[1];
136
+		$this->DefOrientation = 'P';
137
+		$this->w = $this->DefPageFormat[0];
138
+		$this->h = $this->DefPageFormat[1];
139 139
 	}
140
-	elseif($orientation=='l' || $orientation=='landscape')
140
+	elseif ($orientation == 'l' || $orientation == 'landscape')
141 141
 	{
142
-		$this->DefOrientation='L';
143
-		$this->w=$this->DefPageFormat[1];
144
-		$this->h=$this->DefPageFormat[0];
142
+		$this->DefOrientation = 'L';
143
+		$this->w = $this->DefPageFormat[1];
144
+		$this->h = $this->DefPageFormat[0];
145 145
 	}
146 146
 	else
147
-		$this->Error('Incorrect orientation: '.$orientation);
148
-	$this->CurOrientation=$this->DefOrientation;
149
-	$this->wPt=$this->w*$this->k;
150
-	$this->hPt=$this->h*$this->k;
147
+		$this->Error('Incorrect orientation: ' . $orientation);
148
+	$this->CurOrientation = $this->DefOrientation;
149
+	$this->wPt = $this->w * $this->k;
150
+	$this->hPt = $this->h * $this->k;
151 151
 	//Page margins (1 cm)
152
-	$margin=28.35/$this->k;
153
-	$this->SetMargins($margin,$margin);
152
+	$margin = 28.35 / $this->k;
153
+	$this->SetMargins($margin, $margin);
154 154
 	//Interior cell margin (1 mm)
155
-	$this->cMargin=$margin/10;
155
+	$this->cMargin = $margin / 10;
156 156
 	//Line width (0.2 mm)
157
-	$this->LineWidth=.567/$this->k;
157
+	$this->LineWidth = .567 / $this->k;
158 158
 	//Automatic page break
159
-	$this->SetAutoPageBreak(true,2*$margin);
159
+	$this->SetAutoPageBreak(true, 2 * $margin);
160 160
 	//Full width display mode
161 161
 	$this->SetDisplayMode('fullwidth');
162 162
 	//Enable compression
163 163
 	$this->SetCompression(true);
164 164
 	//Set default PDF version number
165
-	$this->PDFVersion='1.3';
165
+	$this->PDFVersion = '1.3';
166 166
 }
167 167
 
168
-function SetMargins($left, $top, $right=null)
168
+function SetMargins($left, $top, $right = null)
169 169
 {
170 170
 	//Set left, top and right margins
171
-	$this->lMargin=$left;
172
-	$this->tMargin=$top;
173
-	if($right===null)
174
-		$right=$left;
175
-	$this->rMargin=$right;
171
+	$this->lMargin = $left;
172
+	$this->tMargin = $top;
173
+	if ($right === null)
174
+		$right = $left;
175
+	$this->rMargin = $right;
176 176
 }
177 177
 
178 178
 function SetLeftMargin($margin)
179 179
 {
180 180
 	//Set left margin
181
-	$this->lMargin=$margin;
182
-	if($this->page>0 && $this->x<$margin)
183
-		$this->x=$margin;
181
+	$this->lMargin = $margin;
182
+	if ($this->page > 0 && $this->x < $margin)
183
+		$this->x = $margin;
184 184
 }
185 185
 
186 186
 function SetTopMargin($margin)
187 187
 {
188 188
 	//Set top margin
189
-	$this->tMargin=$margin;
189
+	$this->tMargin = $margin;
190 190
 }
191 191
 
192 192
 function SetRightMargin($margin)
193 193
 {
194 194
 	//Set right margin
195
-	$this->rMargin=$margin;
195
+	$this->rMargin = $margin;
196 196
 }
197 197
 
198
-function SetAutoPageBreak($auto, $margin=0)
198
+function SetAutoPageBreak($auto, $margin = 0)
199 199
 {
200 200
 	//Set auto page break mode and triggering margin
201
-	$this->AutoPageBreak=$auto;
202
-	$this->bMargin=$margin;
203
-	$this->PageBreakTrigger=$this->h-$margin;
201
+	$this->AutoPageBreak = $auto;
202
+	$this->bMargin = $margin;
203
+	$this->PageBreakTrigger = $this->h - $margin;
204 204
 }
205 205
 
206
-function SetDisplayMode($zoom, $layout='continuous')
206
+function SetDisplayMode($zoom, $layout = 'continuous')
207 207
 {
208 208
 	//Set display mode in viewer
209
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
210
-		$this->ZoomMode=$zoom;
209
+	if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom))
210
+		$this->ZoomMode = $zoom;
211 211
 	else
212
-		$this->Error('Incorrect zoom display mode: '.$zoom);
213
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
214
-		$this->LayoutMode=$layout;
212
+		$this->Error('Incorrect zoom display mode: ' . $zoom);
213
+	if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default')
214
+		$this->LayoutMode = $layout;
215 215
 	else
216
-		$this->Error('Incorrect layout display mode: '.$layout);
216
+		$this->Error('Incorrect layout display mode: ' . $layout);
217 217
 }
218 218
 
219 219
 function SetCompression($compress)
220 220
 {
221 221
 	//Set page compression
222
-	if(function_exists('gzcompress'))
223
-		$this->compress=$compress;
222
+	if (function_exists('gzcompress'))
223
+		$this->compress = $compress;
224 224
 	else
225
-		$this->compress=false;
225
+		$this->compress = false;
226 226
 }
227 227
 
228
-function SetTitle($title, $isUTF8=false)
228
+function SetTitle($title, $isUTF8 = false)
229 229
 {
230 230
 	//Title of document
231
-	if($isUTF8)
232
-		$title=$this->_UTF8toUTF16($title);
233
-	$this->title=$title;
231
+	if ($isUTF8)
232
+		$title = $this->_UTF8toUTF16($title);
233
+	$this->title = $title;
234 234
 }
235 235
 
236
-function SetSubject($subject, $isUTF8=false)
236
+function SetSubject($subject, $isUTF8 = false)
237 237
 {
238 238
 	//Subject of document
239
-	if($isUTF8)
240
-		$subject=$this->_UTF8toUTF16($subject);
241
-	$this->subject=$subject;
239
+	if ($isUTF8)
240
+		$subject = $this->_UTF8toUTF16($subject);
241
+	$this->subject = $subject;
242 242
 }
243 243
 
244
-function SetAuthor($author, $isUTF8=false)
244
+function SetAuthor($author, $isUTF8 = false)
245 245
 {
246 246
 	//Author of document
247
-	if($isUTF8)
248
-		$author=$this->_UTF8toUTF16($author);
249
-	$this->author=$author;
247
+	if ($isUTF8)
248
+		$author = $this->_UTF8toUTF16($author);
249
+	$this->author = $author;
250 250
 }
251 251
 
252
-function SetKeywords($keywords, $isUTF8=false)
252
+function SetKeywords($keywords, $isUTF8 = false)
253 253
 {
254 254
 	//Keywords of document
255
-	if($isUTF8)
256
-		$keywords=$this->_UTF8toUTF16($keywords);
257
-	$this->keywords=$keywords;
255
+	if ($isUTF8)
256
+		$keywords = $this->_UTF8toUTF16($keywords);
257
+	$this->keywords = $keywords;
258 258
 }
259 259
 
260
-function SetCreator($creator, $isUTF8=false)
260
+function SetCreator($creator, $isUTF8 = false)
261 261
 {
262 262
 	//Creator of document
263
-	if($isUTF8)
264
-		$creator=$this->_UTF8toUTF16($creator);
265
-	$this->creator=$creator;
263
+	if ($isUTF8)
264
+		$creator = $this->_UTF8toUTF16($creator);
265
+	$this->creator = $creator;
266 266
 }
267 267
 
268
-function AliasNbPages($alias='{nb}')
268
+function AliasNbPages($alias = '{nb}')
269 269
 {
270 270
 	//Define an alias for total number of pages
271
-	$this->AliasNbPages=$alias;
271
+	$this->AliasNbPages = $alias;
272 272
 }
273 273
 
274 274
 function Error($msg)
275 275
 {
276 276
 	//Fatal error
277
-	die('<b>FPDF error:</b> '.$msg);
277
+	die('<b>FPDF error:</b> ' . $msg);
278 278
 }
279 279
 
280 280
 function Open()
281 281
 {
282 282
 	//Begin document
283
-	$this->state=1;
283
+	$this->state = 1;
284 284
 }
285 285
 
286 286
 function Close()
287 287
 {
288 288
 	//Terminate document
289
-	if($this->state==3)
289
+	if ($this->state == 3)
290 290
 		return;
291
-	if($this->page==0)
291
+	if ($this->page == 0)
292 292
 		$this->AddPage();
293 293
 	//Page footer
294
-	$this->InFooter=true;
294
+	$this->InFooter = true;
295 295
 	$this->Footer();
296
-	$this->InFooter=false;
296
+	$this->InFooter = false;
297 297
 	//Close page
298 298
 	$this->_endpage();
299 299
 	//Close document
300 300
 	$this->_enddoc();
301 301
 }
302 302
 
303
-function AddPage($orientation='', $format='')
303
+function AddPage($orientation = '', $format = '')
304 304
 {
305 305
 	//Start a new page
306
-	if($this->state==0)
306
+	if ($this->state == 0)
307 307
 		$this->Open();
308
-	$family=$this->FontFamily;
309
-	$style=$this->FontStyle.($this->underline ? 'U' : '');
310
-	$size=$this->FontSizePt;
311
-	$lw=$this->LineWidth;
312
-	$dc=$this->DrawColor;
313
-	$fc=$this->FillColor;
314
-	$tc=$this->TextColor;
315
-	$cf=$this->ColorFlag;
316
-	if($this->page>0)
308
+	$family = $this->FontFamily;
309
+	$style = $this->FontStyle . ($this->underline ? 'U' : '');
310
+	$size = $this->FontSizePt;
311
+	$lw = $this->LineWidth;
312
+	$dc = $this->DrawColor;
313
+	$fc = $this->FillColor;
314
+	$tc = $this->TextColor;
315
+	$cf = $this->ColorFlag;
316
+	if ($this->page > 0)
317 317
 	{
318 318
 		//Page footer
319
-		$this->InFooter=true;
319
+		$this->InFooter = true;
320 320
 		$this->Footer();
321
-		$this->InFooter=false;
321
+		$this->InFooter = false;
322 322
 		//Close page
323 323
 		$this->_endpage();
324 324
 	}
325 325
 	//Start new page
326
-	$this->_beginpage($orientation,$format);
326
+	$this->_beginpage($orientation, $format);
327 327
 	//Set line cap style to square
328 328
 	$this->_out('2 J');
329 329
 	//Set line width
330
-	$this->LineWidth=$lw;
331
-	$this->_out(sprintf('%.2F w',$lw*$this->k));
330
+	$this->LineWidth = $lw;
331
+	$this->_out(sprintf('%.2F w', $lw * $this->k));
332 332
 	//Set font
333
-	if($family)
334
-		$this->SetFont($family,$style,$size);
333
+	if ($family)
334
+		$this->SetFont($family, $style, $size);
335 335
 	//Set colors
336
-	$this->DrawColor=$dc;
337
-	if($dc!='0 G')
336
+	$this->DrawColor = $dc;
337
+	if ($dc != '0 G')
338 338
 		$this->_out($dc);
339
-	$this->FillColor=$fc;
340
-	if($fc!='0 g')
339
+	$this->FillColor = $fc;
340
+	if ($fc != '0 g')
341 341
 		$this->_out($fc);
342
-	$this->TextColor=$tc;
343
-	$this->ColorFlag=$cf;
342
+	$this->TextColor = $tc;
343
+	$this->ColorFlag = $cf;
344 344
 	//Page header
345
-	$this->InHeader=true;
345
+	$this->InHeader = true;
346 346
 	$this->Header();
347
-	$this->InHeader=false;
347
+	$this->InHeader = false;
348 348
 	//Restore line width
349
-	if($this->LineWidth!=$lw)
349
+	if ($this->LineWidth != $lw)
350 350
 	{
351
-		$this->LineWidth=$lw;
352
-		$this->_out(sprintf('%.2F w',$lw*$this->k));
351
+		$this->LineWidth = $lw;
352
+		$this->_out(sprintf('%.2F w', $lw * $this->k));
353 353
 	}
354 354
 	//Restore font
355
-	if($family)
356
-		$this->SetFont($family,$style,$size);
355
+	if ($family)
356
+		$this->SetFont($family, $style, $size);
357 357
 	//Restore colors
358
-	if($this->DrawColor!=$dc)
358
+	if ($this->DrawColor != $dc)
359 359
 	{
360
-		$this->DrawColor=$dc;
360
+		$this->DrawColor = $dc;
361 361
 		$this->_out($dc);
362 362
 	}
363
-	if($this->FillColor!=$fc)
363
+	if ($this->FillColor != $fc)
364 364
 	{
365
-		$this->FillColor=$fc;
365
+		$this->FillColor = $fc;
366 366
 		$this->_out($fc);
367 367
 	}
368
-	$this->TextColor=$tc;
369
-	$this->ColorFlag=$cf;
368
+	$this->TextColor = $tc;
369
+	$this->ColorFlag = $cf;
370 370
 }
371 371
 
372 372
 function Header()
@@ -385,230 +385,230 @@  discard block
 block discarded – undo
385 385
 	return $this->page;
386 386
 }
387 387
 
388
-function SetDrawColor($r, $g=null, $b=null)
388
+function SetDrawColor($r, $g = null, $b = null)
389 389
 {
390 390
 	//Set color for all stroking operations
391
-	if(($r==0 && $g==0 && $b==0) || $g===null)
392
-		$this->DrawColor=sprintf('%.3F G',$r/255);
391
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
392
+		$this->DrawColor = sprintf('%.3F G', $r / 255);
393 393
 	else
394
-		$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
395
-	if($this->page>0)
394
+		$this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255);
395
+	if ($this->page > 0)
396 396
 		$this->_out($this->DrawColor);
397 397
 }
398 398
 
399
-function SetFillColor($r, $g=null, $b=null)
399
+function SetFillColor($r, $g = null, $b = null)
400 400
 {
401 401
 	//Set color for all filling operations
402
-	if(($r==0 && $g==0 && $b==0) || $g===null)
403
-		$this->FillColor=sprintf('%.3F g',$r/255);
402
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
403
+		$this->FillColor = sprintf('%.3F g', $r / 255);
404 404
 	else
405
-		$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
406
-	$this->ColorFlag=($this->FillColor!=$this->TextColor);
407
-	if($this->page>0)
405
+		$this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
406
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
407
+	if ($this->page > 0)
408 408
 		$this->_out($this->FillColor);
409 409
 }
410 410
 
411
-function SetTextColor($r, $g=null, $b=null)
411
+function SetTextColor($r, $g = null, $b = null)
412 412
 {
413 413
 	//Set color for text
414
-	if(($r==0 && $g==0 && $b==0) || $g===null)
415
-		$this->TextColor=sprintf('%.3F g',$r/255);
414
+	if (($r == 0 && $g == 0 && $b == 0) || $g === null)
415
+		$this->TextColor = sprintf('%.3F g', $r / 255);
416 416
 	else
417
-		$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
418
-	$this->ColorFlag=($this->FillColor!=$this->TextColor);
417
+		$this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255);
418
+	$this->ColorFlag = ($this->FillColor != $this->TextColor);
419 419
 }
420 420
 
421 421
 function GetStringWidth($s)
422 422
 {
423 423
 	//Get width of a string in the current font
424
-	$s=(string)$s;
425
-	$cw=&$this->CurrentFont['cw'];
426
-	$w=0;
427
-	$l=strlen($s);
428
-	for($i=0;$i<$l;$i++)
429
-		$w+=$cw[$s[$i]];
430
-	return $w*$this->FontSize/1000;
424
+	$s = (string)$s;
425
+	$cw = &$this->CurrentFont['cw'];
426
+	$w = 0;
427
+	$l = strlen($s);
428
+	for ($i = 0; $i < $l; $i++)
429
+		$w += $cw[$s[$i]];
430
+	return $w * $this->FontSize / 1000;
431 431
 }
432 432
 
433 433
 function SetLineWidth($width)
434 434
 {
435 435
 	//Set line width
436
-	$this->LineWidth=$width;
437
-	if($this->page>0)
438
-		$this->_out(sprintf('%.2F w',$width*$this->k));
436
+	$this->LineWidth = $width;
437
+	if ($this->page > 0)
438
+		$this->_out(sprintf('%.2F w', $width * $this->k));
439 439
 }
440 440
 
441 441
 function Line($x1, $y1, $x2, $y2)
442 442
 {
443 443
 	//Draw a line
444
-	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
444
+	$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k));
445 445
 }
446 446
 
447
-function Rect($x, $y, $w, $h, $style='')
447
+function Rect($x, $y, $w, $h, $style = '')
448 448
 {
449 449
 	//Draw a rectangle
450
-	if($style=='F')
451
-		$op='f';
452
-	elseif($style=='FD' || $style=='DF')
453
-		$op='B';
450
+	if ($style == 'F')
451
+		$op = 'f';
452
+	elseif ($style == 'FD' || $style == 'DF')
453
+		$op = 'B';
454 454
 	else
455
-		$op='S';
456
-	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
455
+		$op = 'S';
456
+	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op));
457 457
 }
458 458
 
459
-function AddFont($family, $style='', $file='')
459
+function AddFont($family, $style = '', $file = '')
460 460
 {
461 461
 	//Add a TrueType or Type1 font
462
-	$family=strtolower($family);
463
-	if($file=='')
464
-		$file=str_replace(' ','',$family).strtolower($style).'.php';
465
-	if($family=='arial')
466
-		$family='helvetica';
467
-	$style=strtoupper($style);
468
-	if($style=='IB')
469
-		$style='BI';
470
-	$fontkey=$family.$style;
471
-	if(isset($this->fonts[$fontkey]))
462
+	$family = strtolower($family);
463
+	if ($file == '')
464
+		$file = str_replace(' ', '', $family) . strtolower($style) . '.php';
465
+	if ($family == 'arial')
466
+		$family = 'helvetica';
467
+	$style = strtoupper($style);
468
+	if ($style == 'IB')
469
+		$style = 'BI';
470
+	$fontkey = $family . $style;
471
+	if (isset($this->fonts[$fontkey]))
472 472
 		return;
473
-	include($this->_getfontpath().$file);
474
-	if(!isset($name))
473
+	include($this->_getfontpath() . $file);
474
+	if (!isset($name))
475 475
 		$this->Error('Could not include font definition file');
476
-	$i=count($this->fonts)+1;
477
-	$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478
-	if($diff)
476
+	$i = count($this->fonts) + 1;
477
+	$this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478
+	if ($diff)
479 479
 	{
480 480
 		//Search existing encodings
481
-		$d=0;
482
-		$nb=count($this->diffs);
483
-		for($i=1;$i<=$nb;$i++)
481
+		$d = 0;
482
+		$nb = count($this->diffs);
483
+		for ($i = 1; $i <= $nb; $i++)
484 484
 		{
485
-			if($this->diffs[$i]==$diff)
485
+			if ($this->diffs[$i] == $diff)
486 486
 			{
487
-				$d=$i;
487
+				$d = $i;
488 488
 				break;
489 489
 			}
490 490
 		}
491
-		if($d==0)
491
+		if ($d == 0)
492 492
 		{
493
-			$d=$nb+1;
494
-			$this->diffs[$d]=$diff;
493
+			$d = $nb + 1;
494
+			$this->diffs[$d] = $diff;
495 495
 		}
496
-		$this->fonts[$fontkey]['diff']=$d;
496
+		$this->fonts[$fontkey]['diff'] = $d;
497 497
 	}
498
-	if($file)
498
+	if ($file)
499 499
 	{
500
-		if($type=='TrueType')
501
-			$this->FontFiles[$file]=array('length1'=>$originalsize);
500
+		if ($type == 'TrueType')
501
+			$this->FontFiles[$file] = array('length1'=>$originalsize);
502 502
 		else
503
-			$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
503
+			$this->FontFiles[$file] = array('length1'=>$size1, 'length2'=>$size2);
504 504
 	}
505 505
 }
506 506
 
507
-function SetFont($family, $style='', $size=0)
507
+function SetFont($family, $style = '', $size = 0)
508 508
 {
509 509
 	//Select a font; size given in points
510 510
 	global $fpdf_charwidths;
511 511
 
512
-	$family=strtolower($family);
513
-	if($family=='')
514
-		$family=$this->FontFamily;
515
-	if($family=='arial')
516
-		$family='helvetica';
517
-	elseif($family=='symbol' || $family=='zapfdingbats')
518
-		$style='';
519
-	$style=strtoupper($style);
520
-	if(strpos($style,'U')!==false)
512
+	$family = strtolower($family);
513
+	if ($family == '')
514
+		$family = $this->FontFamily;
515
+	if ($family == 'arial')
516
+		$family = 'helvetica';
517
+	elseif ($family == 'symbol' || $family == 'zapfdingbats')
518
+		$style = '';
519
+	$style = strtoupper($style);
520
+	if (strpos($style, 'U') !== false)
521 521
 	{
522
-		$this->underline=true;
523
-		$style=str_replace('U','',$style);
522
+		$this->underline = true;
523
+		$style = str_replace('U', '', $style);
524 524
 	}
525 525
 	else
526
-		$this->underline=false;
527
-	if($style=='IB')
528
-		$style='BI';
529
-	if($size==0)
530
-		$size=$this->FontSizePt;
526
+		$this->underline = false;
527
+	if ($style == 'IB')
528
+		$style = 'BI';
529
+	if ($size == 0)
530
+		$size = $this->FontSizePt;
531 531
 	//Test if font is already selected
532
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
532
+	if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size)
533 533
 		return;
534 534
 	//Test if used for the first time
535
-	$fontkey=$family.$style;
536
-	if(!isset($this->fonts[$fontkey]))
535
+	$fontkey = $family . $style;
536
+	if (!isset($this->fonts[$fontkey]))
537 537
 	{
538 538
 		//Check if one of the standard fonts
539
-		if(isset($this->CoreFonts[$fontkey]))
539
+		if (isset($this->CoreFonts[$fontkey]))
540 540
 		{
541
-			if(!isset($fpdf_charwidths[$fontkey]))
541
+			if (!isset($fpdf_charwidths[$fontkey]))
542 542
 			{
543 543
 				//Load metric file
544
-				$file=$family;
545
-				if($family=='times' || $family=='helvetica')
546
-					$file.=strtolower($style);
547
-				include($this->_getfontpath().$file.'.php');
548
-				if(!isset($fpdf_charwidths[$fontkey]))
544
+				$file = $family;
545
+				if ($family == 'times' || $family == 'helvetica')
546
+					$file .= strtolower($style);
547
+				include($this->_getfontpath() . $file . '.php');
548
+				if (!isset($fpdf_charwidths[$fontkey]))
549 549
 					$this->Error('Could not include font metric file');
550 550
 			}
551
-			$i=count($this->fonts)+1;
552
-			$name=$this->CoreFonts[$fontkey];
553
-			$cw=$fpdf_charwidths[$fontkey];
554
-			$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
551
+			$i = count($this->fonts) + 1;
552
+			$name = $this->CoreFonts[$fontkey];
553
+			$cw = $fpdf_charwidths[$fontkey];
554
+			$this->fonts[$fontkey] = array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
555 555
 		}
556 556
 		else
557
-			$this->Error('Undefined font: '.$family.' '.$style);
557
+			$this->Error('Undefined font: ' . $family . ' ' . $style);
558 558
 	}
559 559
 	//Select it
560
-	$this->FontFamily=$family;
561
-	$this->FontStyle=$style;
562
-	$this->FontSizePt=$size;
563
-	$this->FontSize=$size/$this->k;
564
-	$this->CurrentFont=&$this->fonts[$fontkey];
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
560
+	$this->FontFamily = $family;
561
+	$this->FontStyle = $style;
562
+	$this->FontSizePt = $size;
563
+	$this->FontSize = $size / $this->k;
564
+	$this->CurrentFont = &$this->fonts[$fontkey];
565
+	if ($this->page > 0)
566
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
567 567
 }
568 568
 
569 569
 function SetFontSize($size)
570 570
 {
571 571
 	//Set font size in points
572
-	if($this->FontSizePt==$size)
572
+	if ($this->FontSizePt == $size)
573 573
 		return;
574
-	$this->FontSizePt=$size;
575
-	$this->FontSize=$size/$this->k;
576
-	if($this->page>0)
577
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
574
+	$this->FontSizePt = $size;
575
+	$this->FontSize = $size / $this->k;
576
+	if ($this->page > 0)
577
+		$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
578 578
 }
579 579
 
580 580
 function AddLink()
581 581
 {
582 582
 	//Create a new internal link
583
-	$n=count($this->links)+1;
584
-	$this->links[$n]=array(0, 0);
583
+	$n = count($this->links) + 1;
584
+	$this->links[$n] = array(0, 0);
585 585
 	return $n;
586 586
 }
587 587
 
588
-function SetLink($link, $y=0, $page=-1)
588
+function SetLink($link, $y = 0, $page = -1)
589 589
 {
590 590
 	//Set destination of internal link
591
-	if($y==-1)
592
-		$y=$this->y;
593
-	if($page==-1)
594
-		$page=$this->page;
595
-	$this->links[$link]=array($page, $y);
591
+	if ($y == -1)
592
+		$y = $this->y;
593
+	if ($page == -1)
594
+		$page = $this->page;
595
+	$this->links[$link] = array($page, $y);
596 596
 }
597 597
 
598 598
 function Link($x, $y, $w, $h, $link)
599 599
 {
600 600
 	//Put a link on the page
601
-	$this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
601
+	$this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link);
602 602
 }
603 603
 
604 604
 function Text($x, $y, $txt)
605 605
 {
606 606
 	//Output a string
607
-	$s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
608
-	if($this->underline && $txt!='')
609
-		$s.=' '.$this->_dounderline($x,$y,$txt);
610
-	if($this->ColorFlag)
611
-		$s='q '.$this->TextColor.' '.$s.' Q';
607
+	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt));
608
+	if ($this->underline && $txt != '')
609
+		$s .= ' ' . $this->_dounderline($x, $y, $txt);
610
+	if ($this->ColorFlag)
611
+		$s = 'q ' . $this->TextColor . ' ' . $s . ' Q';
612 612
 	$this->_out($s);
613 613
 }
614 614
 
@@ -618,268 +618,268 @@  discard block
 block discarded – undo
618 618
 	return $this->AutoPageBreak;
619 619
 }
620 620
 
621
-function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
621
+function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
622 622
 {
623 623
 	//Output a cell
624
-	$k=$this->k;
625
-	if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
624
+	$k = $this->k;
625
+	if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
626 626
 	{
627 627
 		//Automatic page break
628
-		$x=$this->x;
629
-		$ws=$this->ws;
630
-		if($ws>0)
628
+		$x = $this->x;
629
+		$ws = $this->ws;
630
+		if ($ws > 0)
631 631
 		{
632
-			$this->ws=0;
632
+			$this->ws = 0;
633 633
 			$this->_out('0 Tw');
634 634
 		}
635
-		$this->AddPage($this->CurOrientation,$this->CurPageFormat);
636
-		$this->x=$x;
637
-		if($ws>0)
635
+		$this->AddPage($this->CurOrientation, $this->CurPageFormat);
636
+		$this->x = $x;
637
+		if ($ws > 0)
638 638
 		{
639
-			$this->ws=$ws;
640
-			$this->_out(sprintf('%.3F Tw',$ws*$k));
639
+			$this->ws = $ws;
640
+			$this->_out(sprintf('%.3F Tw', $ws * $k));
641 641
 		}
642 642
 	}
643
-	if($w==0)
644
-		$w=$this->w-$this->rMargin-$this->x;
645
-	$s='';
646
-	if($fill || $border==1)
643
+	if ($w == 0)
644
+		$w = $this->w - $this->rMargin - $this->x;
645
+	$s = '';
646
+	if ($fill || $border == 1)
647 647
 	{
648
-		if($fill)
649
-			$op=($border==1) ? 'B' : 'f';
648
+		if ($fill)
649
+			$op = ($border == 1) ? 'B' : 'f';
650 650
 		else
651
-			$op='S';
652
-		$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
651
+			$op = 'S';
652
+		$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
653 653
 	}
654
-	if(is_string($border))
654
+	if (is_string($border))
655 655
 	{
656
-		$x=$this->x;
657
-		$y=$this->y;
658
-		if(strpos($border,'L')!==false)
659
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
660
-		if(strpos($border,'T')!==false)
661
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
662
-		if(strpos($border,'R')!==false)
663
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
664
-		if(strpos($border,'B')!==false)
665
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
656
+		$x = $this->x;
657
+		$y = $this->y;
658
+		if (strpos($border, 'L') !== false)
659
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
660
+		if (strpos($border, 'T') !== false)
661
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
662
+		if (strpos($border, 'R') !== false)
663
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
664
+		if (strpos($border, 'B') !== false)
665
+			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
666 666
 	}
667
-	if($txt!=='')
667
+	if ($txt !== '')
668 668
 	{
669
-		if($align=='R')
670
-			$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
671
-		elseif($align=='C')
672
-			$dx=($w-$this->GetStringWidth($txt))/2;
669
+		if ($align == 'R')
670
+			$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
671
+		elseif ($align == 'C')
672
+			$dx = ($w - $this->GetStringWidth($txt)) / 2;
673 673
 		else
674
-			$dx=$this->cMargin;
675
-		if($this->ColorFlag)
676
-			$s.='q '.$this->TextColor.' ';
677
-		$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
678
-		$s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
679
-		if($this->underline)
680
-			$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
681
-		if($this->ColorFlag)
682
-			$s.=' Q';
683
-		if($link)
684
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
674
+			$dx = $this->cMargin;
675
+		if ($this->ColorFlag)
676
+			$s .= 'q ' . $this->TextColor . ' ';
677
+		$txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
678
+		$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2);
679
+		if ($this->underline)
680
+			$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
681
+		if ($this->ColorFlag)
682
+			$s .= ' Q';
683
+		if ($link)
684
+			$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link);
685 685
 	}
686
-	if($s)
686
+	if ($s)
687 687
 		$this->_out($s);
688
-	$this->lasth=$h;
689
-	if($ln>0)
688
+	$this->lasth = $h;
689
+	if ($ln > 0)
690 690
 	{
691 691
 		//Go to next line
692
-		$this->y+=$h;
693
-		if($ln==1)
694
-			$this->x=$this->lMargin;
692
+		$this->y += $h;
693
+		if ($ln == 1)
694
+			$this->x = $this->lMargin;
695 695
 	}
696 696
 	else
697
-		$this->x+=$w;
697
+		$this->x += $w;
698 698
 }
699 699
 
700
-function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
700
+function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false)
701 701
 {
702 702
 	//Output text with automatic or explicit line breaks
703
-	$cw=&$this->CurrentFont['cw'];
704
-	if($w==0)
705
-		$w=$this->w-$this->rMargin-$this->x;
706
-	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
707
-	$s=str_replace("\r",'',$txt);
708
-	$nb=strlen($s);
709
-	if($nb>0 && $s[$nb-1]=="\n")
703
+	$cw = &$this->CurrentFont['cw'];
704
+	if ($w == 0)
705
+		$w = $this->w - $this->rMargin - $this->x;
706
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
707
+	$s = str_replace("\r", '', $txt);
708
+	$nb = strlen($s);
709
+	if ($nb > 0 && $s[$nb - 1] == "\n")
710 710
 		$nb--;
711
-	$b=0;
712
-	if($border)
711
+	$b = 0;
712
+	if ($border)
713 713
 	{
714
-		if($border==1)
714
+		if ($border == 1)
715 715
 		{
716
-			$border='LTRB';
717
-			$b='LRT';
718
-			$b2='LR';
716
+			$border = 'LTRB';
717
+			$b = 'LRT';
718
+			$b2 = 'LR';
719 719
 		}
720 720
 		else
721 721
 		{
722
-			$b2='';
723
-			if(strpos($border,'L')!==false)
724
-				$b2.='L';
725
-			if(strpos($border,'R')!==false)
726
-				$b2.='R';
727
-			$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
722
+			$b2 = '';
723
+			if (strpos($border, 'L') !== false)
724
+				$b2 .= 'L';
725
+			if (strpos($border, 'R') !== false)
726
+				$b2 .= 'R';
727
+			$b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2;
728 728
 		}
729 729
 	}
730
-	$sep=-1;
731
-	$i=0;
732
-	$j=0;
733
-	$l=0;
734
-	$ns=0;
735
-	$nl=1;
736
-	while($i<$nb)
730
+	$sep = -1;
731
+	$i = 0;
732
+	$j = 0;
733
+	$l = 0;
734
+	$ns = 0;
735
+	$nl = 1;
736
+	while ($i < $nb)
737 737
 	{
738 738
 		//Get next character
739
-		$c=$s[$i];
740
-		if($c=="\n")
739
+		$c = $s[$i];
740
+		if ($c == "\n")
741 741
 		{
742 742
 			//Explicit line break
743
-			if($this->ws>0)
743
+			if ($this->ws > 0)
744 744
 			{
745
-				$this->ws=0;
745
+				$this->ws = 0;
746 746
 				$this->_out('0 Tw');
747 747
 			}
748
-			$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
748
+			$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
749 749
 			$i++;
750
-			$sep=-1;
751
-			$j=$i;
752
-			$l=0;
753
-			$ns=0;
750
+			$sep = -1;
751
+			$j = $i;
752
+			$l = 0;
753
+			$ns = 0;
754 754
 			$nl++;
755
-			if($border && $nl==2)
756
-				$b=$b2;
755
+			if ($border && $nl == 2)
756
+				$b = $b2;
757 757
 			continue;
758 758
 		}
759
-		if($c==' ')
759
+		if ($c == ' ')
760 760
 		{
761
-			$sep=$i;
762
-			$ls=$l;
761
+			$sep = $i;
762
+			$ls = $l;
763 763
 			$ns++;
764 764
 		}
765
-		$l+=$cw[$c];
766
-		if($l>$wmax)
765
+		$l += $cw[$c];
766
+		if ($l > $wmax)
767 767
 		{
768 768
 			//Automatic line break
769
-			if($sep==-1)
769
+			if ($sep == -1)
770 770
 			{
771
-				if($i==$j)
771
+				if ($i == $j)
772 772
 					$i++;
773
-				if($this->ws>0)
773
+				if ($this->ws > 0)
774 774
 				{
775
-					$this->ws=0;
775
+					$this->ws = 0;
776 776
 					$this->_out('0 Tw');
777 777
 				}
778
-				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
778
+				$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
779 779
 			}
780 780
 			else
781 781
 			{
782
-				if($align=='J')
782
+				if ($align == 'J')
783 783
 				{
784
-					$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
785
-					$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
784
+					$this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0;
785
+					$this->_out(sprintf('%.3F Tw', $this->ws * $this->k));
786 786
 				}
787
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
788
-				$i=$sep+1;
787
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill);
788
+				$i = $sep + 1;
789 789
 			}
790
-			$sep=-1;
791
-			$j=$i;
792
-			$l=0;
793
-			$ns=0;
790
+			$sep = -1;
791
+			$j = $i;
792
+			$l = 0;
793
+			$ns = 0;
794 794
 			$nl++;
795
-			if($border && $nl==2)
796
-				$b=$b2;
795
+			if ($border && $nl == 2)
796
+				$b = $b2;
797 797
 		}
798 798
 		else
799 799
 			$i++;
800 800
 	}
801 801
 	//Last chunk
802
-	if($this->ws>0)
802
+	if ($this->ws > 0)
803 803
 	{
804
-		$this->ws=0;
804
+		$this->ws = 0;
805 805
 		$this->_out('0 Tw');
806 806
 	}
807
-	if($border && strpos($border,'B')!==false)
808
-		$b.='B';
809
-	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
810
-	$this->x=$this->lMargin;
807
+	if ($border && strpos($border, 'B') !== false)
808
+		$b .= 'B';
809
+	$this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill);
810
+	$this->x = $this->lMargin;
811 811
 }
812 812
 
813
-function Write($h, $txt, $link='')
813
+function Write($h, $txt, $link = '')
814 814
 {
815 815
 	//Output text in flowing mode
816
-	$cw=&$this->CurrentFont['cw'];
817
-	$w=$this->w-$this->rMargin-$this->x;
818
-	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
819
-	$s=str_replace("\r",'',$txt);
820
-	$nb=strlen($s);
821
-	$sep=-1;
822
-	$i=0;
823
-	$j=0;
824
-	$l=0;
825
-	$nl=1;
826
-	while($i<$nb)
816
+	$cw = &$this->CurrentFont['cw'];
817
+	$w = $this->w - $this->rMargin - $this->x;
818
+	$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
819
+	$s = str_replace("\r", '', $txt);
820
+	$nb = strlen($s);
821
+	$sep = -1;
822
+	$i = 0;
823
+	$j = 0;
824
+	$l = 0;
825
+	$nl = 1;
826
+	while ($i < $nb)
827 827
 	{
828 828
 		//Get next character
829
-		$c=$s[$i];
830
-		if($c=="\n")
829
+		$c = $s[$i];
830
+		if ($c == "\n")
831 831
 		{
832 832
 			//Explicit line break
833
-			$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
833
+			$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
834 834
 			$i++;
835
-			$sep=-1;
836
-			$j=$i;
837
-			$l=0;
838
-			if($nl==1)
835
+			$sep = -1;
836
+			$j = $i;
837
+			$l = 0;
838
+			if ($nl == 1)
839 839
 			{
840
-				$this->x=$this->lMargin;
841
-				$w=$this->w-$this->rMargin-$this->x;
842
-				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
840
+				$this->x = $this->lMargin;
841
+				$w = $this->w - $this->rMargin - $this->x;
842
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
843 843
 			}
844 844
 			$nl++;
845 845
 			continue;
846 846
 		}
847
-		if($c==' ')
848
-			$sep=$i;
849
-		$l+=$cw[$c];
850
-		if($l>$wmax)
847
+		if ($c == ' ')
848
+			$sep = $i;
849
+		$l += $cw[$c];
850
+		if ($l > $wmax)
851 851
 		{
852 852
 			//Automatic line break
853
-			if($sep==-1)
853
+			if ($sep == -1)
854 854
 			{
855
-				if($this->x>$this->lMargin)
855
+				if ($this->x > $this->lMargin)
856 856
 				{
857 857
 					//Move to next line
858
-					$this->x=$this->lMargin;
859
-					$this->y+=$h;
860
-					$w=$this->w-$this->rMargin-$this->x;
861
-					$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
858
+					$this->x = $this->lMargin;
859
+					$this->y += $h;
860
+					$w = $this->w - $this->rMargin - $this->x;
861
+					$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
862 862
 					$i++;
863 863
 					$nl++;
864 864
 					continue;
865 865
 				}
866
-				if($i==$j)
866
+				if ($i == $j)
867 867
 					$i++;
868
-				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
868
+				$this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link);
869 869
 			}
870 870
 			else
871 871
 			{
872
-				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
873
-				$i=$sep+1;
872
+				$this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link);
873
+				$i = $sep + 1;
874 874
 			}
875
-			$sep=-1;
876
-			$j=$i;
877
-			$l=0;
878
-			if($nl==1)
875
+			$sep = -1;
876
+			$j = $i;
877
+			$l = 0;
878
+			if ($nl == 1)
879 879
 			{
880
-				$this->x=$this->lMargin;
881
-				$w=$this->w-$this->rMargin-$this->x;
882
-				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
880
+				$this->x = $this->lMargin;
881
+				$w = $this->w - $this->rMargin - $this->x;
882
+				$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
883 883
 			}
884 884
 			$nl++;
885 885
 		}
@@ -887,74 +887,74 @@  discard block
 block discarded – undo
887 887
 			$i++;
888 888
 	}
889 889
 	//Last chunk
890
-	if($i!=$j)
891
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
890
+	if ($i != $j)
891
+		$this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link);
892 892
 }
893 893
 
894
-function Ln($h=null)
894
+function Ln($h = null)
895 895
 {
896 896
 	//Line feed; default value is last cell height
897
-	$this->x=$this->lMargin;
898
-	if($h===null)
899
-		$this->y+=$this->lasth;
897
+	$this->x = $this->lMargin;
898
+	if ($h === null)
899
+		$this->y += $this->lasth;
900 900
 	else
901
-		$this->y+=$h;
901
+		$this->y += $h;
902 902
 }
903 903
 
904
-function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
904
+function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '')
905 905
 {
906 906
 	//Put an image on the page
907
-	if(!isset($this->images[$file]))
907
+	if (!isset($this->images[$file]))
908 908
 	{
909 909
 		//First use of this image, get info
910
-		if($type=='')
910
+		if ($type == '')
911 911
 		{
912
-			$pos=strrpos($file,'.');
913
-			if(!$pos)
914
-				$this->Error('Image file has no extension and no type was specified: '.$file);
915
-			$type=substr($file,$pos+1);
912
+			$pos = strrpos($file, '.');
913
+			if (!$pos)
914
+				$this->Error('Image file has no extension and no type was specified: ' . $file);
915
+			$type = substr($file, $pos + 1);
916 916
 		}
917
-		$type=strtolower($type);
918
-		if($type=='jpeg')
919
-			$type='jpg';
920
-		$mtd='_parse'.$type;
921
-		if(!method_exists($this,$mtd))
922
-			$this->Error('Unsupported image type: '.$type);
923
-		$info=$this->$mtd($file);
924
-		$info['i']=count($this->images)+1;
925
-		$this->images[$file]=$info;
917
+		$type = strtolower($type);
918
+		if ($type == 'jpeg')
919
+			$type = 'jpg';
920
+		$mtd = '_parse' . $type;
921
+		if (!method_exists($this, $mtd))
922
+			$this->Error('Unsupported image type: ' . $type);
923
+		$info = $this->$mtd($file);
924
+		$info['i'] = count($this->images) + 1;
925
+		$this->images[$file] = $info;
926 926
 	}
927 927
 	else
928
-		$info=$this->images[$file];
928
+		$info = $this->images[$file];
929 929
 	//Automatic width and height calculation if needed
930
-	if($w==0 && $h==0)
930
+	if ($w == 0 && $h == 0)
931 931
 	{
932 932
 		//Put image at 72 dpi
933
-		$w=$info['w']/$this->k;
934
-		$h=$info['h']/$this->k;
933
+		$w = $info['w'] / $this->k;
934
+		$h = $info['h'] / $this->k;
935 935
 	}
936
-	elseif($w==0)
937
-		$w=$h*$info['w']/$info['h'];
938
-	elseif($h==0)
939
-		$h=$w*$info['h']/$info['w'];
936
+	elseif ($w == 0)
937
+		$w = $h * $info['w'] / $info['h'];
938
+	elseif ($h == 0)
939
+		$h = $w * $info['h'] / $info['w'];
940 940
 	//Flowing mode
941
-	if($y===null)
941
+	if ($y === null)
942 942
 	{
943
-		if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
943
+		if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
944 944
 		{
945 945
 			//Automatic page break
946
-			$x2=$this->x;
947
-			$this->AddPage($this->CurOrientation,$this->CurPageFormat);
948
-			$this->x=$x2;
946
+			$x2 = $this->x;
947
+			$this->AddPage($this->CurOrientation, $this->CurPageFormat);
948
+			$this->x = $x2;
949 949
 		}
950
-		$y=$this->y;
951
-		$this->y+=$h;
950
+		$y = $this->y;
951
+		$this->y += $h;
952 952
 	}
953
-	if($x===null)
954
-		$x=$this->x;
955
-	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
956
-	if($link)
957
-		$this->Link($x,$y,$w,$h,$link);
953
+	if ($x === null)
954
+		$x = $this->x;
955
+	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i']));
956
+	if ($link)
957
+		$this->Link($x, $y, $w, $h, $link);
958 958
 }
959 959
 
960 960
 function GetX()
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
 function SetX($x)
967 967
 {
968 968
 	//Set x position
969
-	if($x>=0)
970
-		$this->x=$x;
969
+	if ($x >= 0)
970
+		$this->x = $x;
971 971
 	else
972
-		$this->x=$this->w+$x;
972
+		$this->x = $this->w + $x;
973 973
 }
974 974
 
975 975
 function GetY()
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
 function SetY($y)
982 982
 {
983 983
 	//Set y position and reset x
984
-	$this->x=$this->lMargin;
985
-	if($y>=0)
986
-		$this->y=$y;
984
+	$this->x = $this->lMargin;
985
+	if ($y >= 0)
986
+		$this->y = $y;
987 987
 	else
988
-		$this->y=$this->h+$y;
988
+		$this->y = $this->h + $y;
989 989
 }
990 990
 
991 991
 function SetXY($x, $y)
@@ -995,69 +995,69 @@  discard block
 block discarded – undo
995 995
 	$this->SetX($x);
996 996
 }
997 997
 
998
-function Output($name='', $dest='')
998
+function Output($name = '', $dest = '')
999 999
 {
1000 1000
 	//Output PDF to some destination
1001
-	if($this->state<3)
1001
+	if ($this->state < 3)
1002 1002
 		$this->Close();
1003
-	$dest=strtoupper($dest);
1004
-	if($dest=='')
1003
+	$dest = strtoupper($dest);
1004
+	if ($dest == '')
1005 1005
 	{
1006
-		if($name=='')
1006
+		if ($name == '')
1007 1007
 		{
1008
-			$name='doc.pdf';
1009
-			$dest='I';
1008
+			$name = 'doc.pdf';
1009
+			$dest = 'I';
1010 1010
 		}
1011 1011
 		else
1012
-			$dest='F';
1012
+			$dest = 'F';
1013 1013
 	}
1014
-	switch($dest)
1014
+	switch ($dest)
1015 1015
 	{
1016 1016
 		case 'I':
1017 1017
 			//Send to standard output
1018
-			if(ob_get_length())
1018
+			if (ob_get_length())
1019 1019
 				$this->Error('Some data has already been output, can\'t send PDF file');
1020
-			if(php_sapi_name()!='cli')
1020
+			if (php_sapi_name() != 'cli')
1021 1021
 			{
1022 1022
 				//We send to a browser
1023 1023
 				header('Content-Type: application/pdf');
1024
-				if(headers_sent())
1024
+				if (headers_sent())
1025 1025
 					$this->Error('Some data has already been output, can\'t send PDF file');
1026
-				header('Content-Length: '.strlen($this->buffer));
1027
-				header('Content-Disposition: inline; filename="'.$name.'"');
1026
+				header('Content-Length: ' . strlen($this->buffer));
1027
+				header('Content-Disposition: inline; filename="' . $name . '"');
1028 1028
 				header('Cache-Control: private, max-age=0, must-revalidate');
1029 1029
 				header('Pragma: public');
1030
-				ini_set('zlib.output_compression','0');
1030
+				ini_set('zlib.output_compression', '0');
1031 1031
 			}
1032 1032
 			echo $this->buffer;
1033 1033
 			break;
1034 1034
 		case 'D':
1035 1035
 			//Download file
1036
-			if(ob_get_length())
1036
+			if (ob_get_length())
1037 1037
 				$this->Error('Some data has already been output, can\'t send PDF file');
1038 1038
 			header('Content-Type: application/x-download');
1039
-			if(headers_sent())
1039
+			if (headers_sent())
1040 1040
 				$this->Error('Some data has already been output, can\'t send PDF file');
1041
-			header('Content-Length: '.strlen($this->buffer));
1042
-			header('Content-Disposition: attachment; filename="'.$name.'"');
1041
+			header('Content-Length: ' . strlen($this->buffer));
1042
+			header('Content-Disposition: attachment; filename="' . $name . '"');
1043 1043
 			header('Cache-Control: private, max-age=0, must-revalidate');
1044 1044
 			header('Pragma: public');
1045
-			ini_set('zlib.output_compression','0');
1045
+			ini_set('zlib.output_compression', '0');
1046 1046
 			echo $this->buffer;
1047 1047
 			break;
1048 1048
 		case 'F':
1049 1049
 			//Save to local file
1050
-			$f=fopen($name,'wb');
1051
-			if(!$f)
1052
-				$this->Error('Unable to create output file: '.$name);
1053
-			fwrite($f,$this->buffer,strlen($this->buffer));
1050
+			$f = fopen($name, 'wb');
1051
+			if (!$f)
1052
+				$this->Error('Unable to create output file: ' . $name);
1053
+			fwrite($f, $this->buffer, strlen($this->buffer));
1054 1054
 			fclose($f);
1055 1055
 			break;
1056 1056
 		case 'S':
1057 1057
 			//Return as a string
1058 1058
 			return $this->buffer;
1059 1059
 		default:
1060
-			$this->Error('Incorrect output destination: '.$dest);
1060
+			$this->Error('Incorrect output destination: ' . $dest);
1061 1061
 	}
1062 1062
 	return '';
1063 1063
 }
@@ -1070,124 +1070,124 @@  discard block
 block discarded – undo
1070 1070
 function _dochecks()
1071 1071
 {
1072 1072
 	//Check availability of %F
1073
-	if(sprintf('%.1F',1.0)!='1.0')
1073
+	if (sprintf('%.1F', 1.0) != '1.0')
1074 1074
 		$this->Error('This version of PHP is not supported');
1075 1075
 	//Check mbstring overloading
1076
-	if(ini_get('mbstring.func_overload') & 2)
1076
+	if (ini_get('mbstring.func_overload') & 2)
1077 1077
 		$this->Error('mbstring overloading must be disabled');
1078 1078
 	//Disable runtime magic quotes
1079
-	if(get_magic_quotes_runtime())
1079
+	if (get_magic_quotes_runtime())
1080 1080
 		@set_magic_quotes_runtime(0);
1081 1081
 }
1082 1082
 
1083 1083
 function _getpageformat($format)
1084 1084
 {
1085
-	$format=strtolower($format);
1086
-	if(!isset($this->PageFormats[$format]))
1087
-		$this->Error('Unknown page format: '.$format);
1088
-	$a=$this->PageFormats[$format];
1089
-	return array($a[0]/$this->k, $a[1]/$this->k);
1085
+	$format = strtolower($format);
1086
+	if (!isset($this->PageFormats[$format]))
1087
+		$this->Error('Unknown page format: ' . $format);
1088
+	$a = $this->PageFormats[$format];
1089
+	return array($a[0] / $this->k, $a[1] / $this->k);
1090 1090
 }
1091 1091
 
1092 1092
 function _getfontpath()
1093 1093
 {
1094
-	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
1095
-		define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1094
+	if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__) . '/font'))
1095
+		define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
1096 1096
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1097
 }
1098 1098
 
1099 1099
 function _beginpage($orientation, $format)
1100 1100
 {
1101 1101
 	$this->page++;
1102
-	$this->pages[$this->page]='';
1103
-	$this->state=2;
1104
-	$this->x=$this->lMargin;
1105
-	$this->y=$this->tMargin;
1106
-	$this->FontFamily='';
1102
+	$this->pages[$this->page] = '';
1103
+	$this->state = 2;
1104
+	$this->x = $this->lMargin;
1105
+	$this->y = $this->tMargin;
1106
+	$this->FontFamily = '';
1107 1107
 	//Check page size
1108
-	if($orientation=='')
1109
-		$orientation=$this->DefOrientation;
1108
+	if ($orientation == '')
1109
+		$orientation = $this->DefOrientation;
1110 1110
 	else
1111
-		$orientation=strtoupper($orientation[0]);
1112
-	if($format=='')
1113
-		$format=$this->DefPageFormat;
1111
+		$orientation = strtoupper($orientation[0]);
1112
+	if ($format == '')
1113
+		$format = $this->DefPageFormat;
1114 1114
 	else
1115 1115
 	{
1116
-		if(is_string($format))
1117
-			$format=$this->_getpageformat($format);
1116
+		if (is_string($format))
1117
+			$format = $this->_getpageformat($format);
1118 1118
 	}
1119
-	if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
1119
+	if ($orientation != $this->CurOrientation || $format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1])
1120 1120
 	{
1121 1121
 		//New size
1122
-		if($orientation=='P')
1122
+		if ($orientation == 'P')
1123 1123
 		{
1124
-			$this->w=$format[0];
1125
-			$this->h=$format[1];
1124
+			$this->w = $format[0];
1125
+			$this->h = $format[1];
1126 1126
 		}
1127 1127
 		else
1128 1128
 		{
1129
-			$this->w=$format[1];
1130
-			$this->h=$format[0];
1129
+			$this->w = $format[1];
1130
+			$this->h = $format[0];
1131 1131
 		}
1132
-		$this->wPt=$this->w*$this->k;
1133
-		$this->hPt=$this->h*$this->k;
1134
-		$this->PageBreakTrigger=$this->h-$this->bMargin;
1135
-		$this->CurOrientation=$orientation;
1136
-		$this->CurPageFormat=$format;
1132
+		$this->wPt = $this->w * $this->k;
1133
+		$this->hPt = $this->h * $this->k;
1134
+		$this->PageBreakTrigger = $this->h - $this->bMargin;
1135
+		$this->CurOrientation = $orientation;
1136
+		$this->CurPageFormat = $format;
1137 1137
 	}
1138
-	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
1139
-		$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1138
+	if ($orientation != $this->DefOrientation || $format[0] != $this->DefPageFormat[0] || $format[1] != $this->DefPageFormat[1])
1139
+		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
1140 1140
 }
1141 1141
 
1142 1142
 function _endpage()
1143 1143
 {
1144
-	$this->state=1;
1144
+	$this->state = 1;
1145 1145
 }
1146 1146
 
1147 1147
 function _escape($s)
1148 1148
 {
1149 1149
 	//Escape special characters in strings
1150
-	$s=str_replace('\\','\\\\',$s);
1151
-	$s=str_replace('(','\\(',$s);
1152
-	$s=str_replace(')','\\)',$s);
1153
-	$s=str_replace("\r",'\\r',$s);
1150
+	$s = str_replace('\\', '\\\\', $s);
1151
+	$s = str_replace('(', '\\(', $s);
1152
+	$s = str_replace(')', '\\)', $s);
1153
+	$s = str_replace("\r", '\\r', $s);
1154 1154
 	return $s;
1155 1155
 }
1156 1156
 
1157 1157
 function _textstring($s)
1158 1158
 {
1159 1159
 	//Format a text string
1160
-	return '('.$this->_escape($s).')';
1160
+	return '(' . $this->_escape($s) . ')';
1161 1161
 }
1162 1162
 
1163 1163
 function _UTF8toUTF16($s)
1164 1164
 {
1165 1165
 	//Convert UTF-8 to UTF-16BE with BOM
1166
-	$res="\xFE\xFF";
1167
-	$nb=strlen($s);
1168
-	$i=0;
1169
-	while($i<$nb)
1166
+	$res = "\xFE\xFF";
1167
+	$nb = strlen($s);
1168
+	$i = 0;
1169
+	while ($i < $nb)
1170 1170
 	{
1171
-		$c1=ord($s[$i++]);
1172
-		if($c1>=224)
1171
+		$c1 = ord($s[$i++]);
1172
+		if ($c1 >= 224)
1173 1173
 		{
1174 1174
 			//3-byte character
1175
-			$c2=ord($s[$i++]);
1176
-			$c3=ord($s[$i++]);
1177
-			$res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1178
-			$res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1175
+			$c2 = ord($s[$i++]);
1176
+			$c3 = ord($s[$i++]);
1177
+			$res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2));
1178
+			$res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F));
1179 1179
 		}
1180
-		elseif($c1>=192)
1180
+		elseif ($c1 >= 192)
1181 1181
 		{
1182 1182
 			//2-byte character
1183
-			$c2=ord($s[$i++]);
1184
-			$res.=chr(($c1 & 0x1C)>>2);
1185
-			$res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1183
+			$c2 = ord($s[$i++]);
1184
+			$res .= chr(($c1 & 0x1C) >> 2);
1185
+			$res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F));
1186 1186
 		}
1187 1187
 		else
1188 1188
 		{
1189 1189
 			//Single-byte character
1190
-			$res.="\0".chr($c1);
1190
+			$res .= "\0" . chr($c1);
1191 1191
 		}
1192 1192
 	}
1193 1193
 	return $res;
@@ -1196,32 +1196,32 @@  discard block
 block discarded – undo
1196 1196
 function _dounderline($x, $y, $txt)
1197 1197
 {
1198 1198
 	//Underline text
1199
-	$up=$this->CurrentFont['up'];
1200
-	$ut=$this->CurrentFont['ut'];
1201
-	$w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
1202
-	return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
1199
+	$up = $this->CurrentFont['up'];
1200
+	$ut = $this->CurrentFont['ut'];
1201
+	$w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' ');
1202
+	return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt);
1203 1203
 }
1204 1204
 
1205 1205
 function _parsejpg($file)
1206 1206
 {
1207 1207
 	//Extract info from a JPEG file
1208
-	$a=GetImageSize($file);
1209
-	if(!$a)
1210
-		$this->Error('Missing or incorrect image file: '.$file);
1211
-	if($a[2]!=2)
1212
-		$this->Error('Not a JPEG file: '.$file);
1213
-	if(!isset($a['channels']) || $a['channels']==3)
1214
-		$colspace='DeviceRGB';
1215
-	elseif($a['channels']==4)
1216
-		$colspace='DeviceCMYK';
1208
+	$a = GetImageSize($file);
1209
+	if (!$a)
1210
+		$this->Error('Missing or incorrect image file: ' . $file);
1211
+	if ($a[2] != 2)
1212
+		$this->Error('Not a JPEG file: ' . $file);
1213
+	if (!isset($a['channels']) || $a['channels'] == 3)
1214
+		$colspace = 'DeviceRGB';
1215
+	elseif ($a['channels'] == 4)
1216
+		$colspace = 'DeviceCMYK';
1217 1217
 	else
1218
-		$colspace='DeviceGray';
1219
-	$bpc=isset($a['bits']) ? $a['bits'] : 8;
1218
+		$colspace = 'DeviceGray';
1219
+	$bpc = isset($a['bits']) ? $a['bits'] : 8;
1220 1220
 	//Read whole file
1221
-	$f=fopen($file,'rb');
1222
-	$data='';
1223
-	while(!feof($f))
1224
-		$data.=fread($f,8192);
1221
+	$f = fopen($file, 'rb');
1222
+	$data = '';
1223
+	while (!feof($f))
1224
+		$data .= fread($f, 8192);
1225 1225
 	fclose($f);
1226 1226
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1227
 }
@@ -1229,82 +1229,82 @@  discard block
 block discarded – undo
1229 1229
 function _parsepng($file)
1230 1230
 {
1231 1231
 	//Extract info from a PNG file
1232
-	$f=fopen($file,'rb');
1233
-	if(!$f)
1234
-		$this->Error('Can\'t open image file: '.$file);
1232
+	$f = fopen($file, 'rb');
1233
+	if (!$f)
1234
+		$this->Error('Can\'t open image file: ' . $file);
1235 1235
 	//Check signature
1236
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1237
-		$this->Error('Not a PNG file: '.$file);
1236
+	if ($this->_readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10))
1237
+		$this->Error('Not a PNG file: ' . $file);
1238 1238
 	//Read header chunk
1239
-	$this->_readstream($f,4);
1240
-	if($this->_readstream($f,4)!='IHDR')
1241
-		$this->Error('Incorrect PNG file: '.$file);
1242
-	$w=$this->_readint($f);
1243
-	$h=$this->_readint($f);
1244
-	$bpc=ord($this->_readstream($f,1));
1245
-	if($bpc>8)
1246
-		$this->Error('16-bit depth not supported: '.$file);
1247
-	$ct=ord($this->_readstream($f,1));
1248
-	if($ct==0)
1249
-		$colspace='DeviceGray';
1250
-	elseif($ct==2)
1251
-		$colspace='DeviceRGB';
1252
-	elseif($ct==3)
1253
-		$colspace='Indexed';
1239
+	$this->_readstream($f, 4);
1240
+	if ($this->_readstream($f, 4) != 'IHDR')
1241
+		$this->Error('Incorrect PNG file: ' . $file);
1242
+	$w = $this->_readint($f);
1243
+	$h = $this->_readint($f);
1244
+	$bpc = ord($this->_readstream($f, 1));
1245
+	if ($bpc > 8)
1246
+		$this->Error('16-bit depth not supported: ' . $file);
1247
+	$ct = ord($this->_readstream($f, 1));
1248
+	if ($ct == 0)
1249
+		$colspace = 'DeviceGray';
1250
+	elseif ($ct == 2)
1251
+		$colspace = 'DeviceRGB';
1252
+	elseif ($ct == 3)
1253
+		$colspace = 'Indexed';
1254 1254
 	else
1255
-		$this->Error('Alpha channel not supported: '.$file);
1256
-	if(ord($this->_readstream($f,1))!=0)
1257
-		$this->Error('Unknown compression method: '.$file);
1258
-	if(ord($this->_readstream($f,1))!=0)
1259
-		$this->Error('Unknown filter method: '.$file);
1260
-	if(ord($this->_readstream($f,1))!=0)
1261
-		$this->Error('Interlacing not supported: '.$file);
1262
-	$this->_readstream($f,4);
1263
-	$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
1255
+		$this->Error('Alpha channel not supported: ' . $file);
1256
+	if (ord($this->_readstream($f, 1)) != 0)
1257
+		$this->Error('Unknown compression method: ' . $file);
1258
+	if (ord($this->_readstream($f, 1)) != 0)
1259
+		$this->Error('Unknown filter method: ' . $file);
1260
+	if (ord($this->_readstream($f, 1)) != 0)
1261
+		$this->Error('Interlacing not supported: ' . $file);
1262
+	$this->_readstream($f, 4);
1263
+	$parms = '/DecodeParms <</Predictor 15 /Colors ' . ($ct == 2 ? 3 : 1) . ' /BitsPerComponent ' . $bpc . ' /Columns ' . $w . '>>';
1264 1264
 	//Scan chunks looking for palette, transparency and image data
1265
-	$pal='';
1266
-	$trns='';
1267
-	$data='';
1265
+	$pal = '';
1266
+	$trns = '';
1267
+	$data = '';
1268 1268
 	do
1269 1269
 	{
1270
-		$n=$this->_readint($f);
1271
-		$type=$this->_readstream($f,4);
1272
-		if($type=='PLTE')
1270
+		$n = $this->_readint($f);
1271
+		$type = $this->_readstream($f, 4);
1272
+		if ($type == 'PLTE')
1273 1273
 		{
1274 1274
 			//Read palette
1275
-			$pal=$this->_readstream($f,$n);
1276
-			$this->_readstream($f,4);
1275
+			$pal = $this->_readstream($f, $n);
1276
+			$this->_readstream($f, 4);
1277 1277
 		}
1278
-		elseif($type=='tRNS')
1278
+		elseif ($type == 'tRNS')
1279 1279
 		{
1280 1280
 			//Read transparency info
1281
-			$t=$this->_readstream($f,$n);
1282
-			if($ct==0)
1283
-				$trns=array(ord(substr($t,1,1)));
1284
-			elseif($ct==2)
1285
-				$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1281
+			$t = $this->_readstream($f, $n);
1282
+			if ($ct == 0)
1283
+				$trns = array(ord(substr($t, 1, 1)));
1284
+			elseif ($ct == 2)
1285
+				$trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1)));
1286 1286
 			else
1287 1287
 			{
1288
-				$pos=strpos($t,chr(0));
1289
-				if($pos!==false)
1290
-					$trns=array($pos);
1288
+				$pos = strpos($t, chr(0));
1289
+				if ($pos !== false)
1290
+					$trns = array($pos);
1291 1291
 			}
1292
-			$this->_readstream($f,4);
1292
+			$this->_readstream($f, 4);
1293 1293
 		}
1294
-		elseif($type=='IDAT')
1294
+		elseif ($type == 'IDAT')
1295 1295
 		{
1296 1296
 			//Read image data block
1297
-			$data.=$this->_readstream($f,$n);
1298
-			$this->_readstream($f,4);
1297
+			$data .= $this->_readstream($f, $n);
1298
+			$this->_readstream($f, 4);
1299 1299
 		}
1300
-		elseif($type=='IEND')
1300
+		elseif ($type == 'IEND')
1301 1301
 			break;
1302 1302
 		else
1303
-			$this->_readstream($f,$n+4);
1303
+			$this->_readstream($f, $n + 4);
1304 1304
 	}
1305
-	while($n);
1306
-	if($colspace=='Indexed' && empty($pal))
1307
-		$this->Error('Missing palette in '.$file);
1305
+	while ($n);
1306
+	if ($colspace == 'Indexed' && empty($pal))
1307
+		$this->Error('Missing palette in ' . $file);
1308 1308
 	fclose($f);
1309 1309
 	return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
1310 1310
 }
@@ -1312,16 +1312,16 @@  discard block
 block discarded – undo
1312 1312
 function _readstream($f, $n)
1313 1313
 {
1314 1314
 	//Read n bytes from stream
1315
-	$res='';
1316
-	while($n>0 && !feof($f))
1315
+	$res = '';
1316
+	while ($n > 0 && !feof($f))
1317 1317
 	{
1318
-		$s=fread($f,$n);
1319
-		if($s===false)
1318
+		$s = fread($f, $n);
1319
+		if ($s === false)
1320 1320
 			$this->Error('Error while reading stream');
1321
-		$n-=strlen($s);
1322
-		$res.=$s;
1321
+		$n -= strlen($s);
1322
+		$res .= $s;
1323 1323
 	}
1324
-	if($n>0)
1324
+	if ($n > 0)
1325 1325
 		$this->Error('Unexpected end of stream');
1326 1326
 	return $res;
1327 1327
 }
@@ -1329,28 +1329,28 @@  discard block
 block discarded – undo
1329 1329
 function _readint($f)
1330 1330
 {
1331 1331
 	//Read a 4-byte integer from stream
1332
-	$a=unpack('Ni',$this->_readstream($f,4));
1332
+	$a = unpack('Ni', $this->_readstream($f, 4));
1333 1333
 	return $a['i'];
1334 1334
 }
1335 1335
 
1336 1336
 function _parsegif($file)
1337 1337
 {
1338 1338
 	//Extract info from a GIF file (via PNG conversion)
1339
-	if(!function_exists('imagepng'))
1339
+	if (!function_exists('imagepng'))
1340 1340
 		$this->Error('GD extension is required for GIF support');
1341
-	if(!function_exists('imagecreatefromgif'))
1341
+	if (!function_exists('imagecreatefromgif'))
1342 1342
 		$this->Error('GD has no GIF read support');
1343
-	$im=imagecreatefromgif($file);
1344
-	if(!$im)
1345
-		$this->Error('Missing or incorrect image file: '.$file);
1346
-	imageinterlace($im,0);
1347
-	$tmp=tempnam('.','gif');
1348
-	if(!$tmp)
1343
+	$im = imagecreatefromgif($file);
1344
+	if (!$im)
1345
+		$this->Error('Missing or incorrect image file: ' . $file);
1346
+	imageinterlace($im, 0);
1347
+	$tmp = tempnam('.', 'gif');
1348
+	if (!$tmp)
1349 1349
 		$this->Error('Unable to create a temporary file');
1350
-	if(!imagepng($im,$tmp))
1350
+	if (!imagepng($im, $tmp))
1351 1351
 		$this->Error('Error while saving to temporary file');
1352 1352
 	imagedestroy($im);
1353
-	$info=$this->_parsepng($tmp);
1353
+	$info = $this->_parsepng($tmp);
1354 1354
 	unlink($tmp);
1355 1355
 	return $info;
1356 1356
 }
@@ -1359,8 +1359,8 @@  discard block
 block discarded – undo
1359 1359
 {
1360 1360
 	//Begin a new object
1361 1361
 	$this->n++;
1362
-	$this->offsets[$this->n]=strlen($this->buffer);
1363
-	$this->_out($this->n.' 0 obj');
1362
+	$this->offsets[$this->n] = strlen($this->buffer);
1363
+	$this->_out($this->n . ' 0 obj');
1364 1364
 }
1365 1365
 
1366 1366
 function _putstream($s)
@@ -1373,162 +1373,162 @@  discard block
 block discarded – undo
1373 1373
 function _out($s)
1374 1374
 {
1375 1375
 	//Add a line to the document
1376
-	if($this->state==2)
1377
-		$this->pages[$this->page].=$s."\n";
1376
+	if ($this->state == 2)
1377
+		$this->pages[$this->page] .= $s . "\n";
1378 1378
 	else
1379
-		$this->buffer.=$s."\n";
1379
+		$this->buffer .= $s . "\n";
1380 1380
 }
1381 1381
 
1382 1382
 function _putpages()
1383 1383
 {
1384
-	$nb=$this->page;
1385
-	if(!empty($this->AliasNbPages))
1384
+	$nb = $this->page;
1385
+	if (!empty($this->AliasNbPages))
1386 1386
 	{
1387 1387
 		//Replace number of pages
1388
-		for($n=1;$n<=$nb;$n++)
1389
-			$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1388
+		for ($n = 1; $n <= $nb; $n++)
1389
+			$this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]);
1390 1390
 	}
1391
-	if($this->DefOrientation=='P')
1391
+	if ($this->DefOrientation == 'P')
1392 1392
 	{
1393
-		$wPt=$this->DefPageFormat[0]*$this->k;
1394
-		$hPt=$this->DefPageFormat[1]*$this->k;
1393
+		$wPt = $this->DefPageFormat[0] * $this->k;
1394
+		$hPt = $this->DefPageFormat[1] * $this->k;
1395 1395
 	}
1396 1396
 	else
1397 1397
 	{
1398
-		$wPt=$this->DefPageFormat[1]*$this->k;
1399
-		$hPt=$this->DefPageFormat[0]*$this->k;
1398
+		$wPt = $this->DefPageFormat[1] * $this->k;
1399
+		$hPt = $this->DefPageFormat[0] * $this->k;
1400 1400
 	}
1401
-	$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
1402
-	for($n=1;$n<=$nb;$n++)
1401
+	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1402
+	for ($n = 1; $n <= $nb; $n++)
1403 1403
 	{
1404 1404
 		//Page
1405 1405
 		$this->_newobj();
1406 1406
 		$this->_out('<</Type /Page');
1407 1407
 		$this->_out('/Parent 1 0 R');
1408
-		if(isset($this->PageSizes[$n]))
1409
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1408
+		if (isset($this->PageSizes[$n]))
1409
+			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1]));
1410 1410
 		$this->_out('/Resources 2 0 R');
1411
-		if(isset($this->PageLinks[$n]))
1411
+		if (isset($this->PageLinks[$n]))
1412 1412
 		{
1413 1413
 			//Links
1414
-			$annots='/Annots [';
1415
-			foreach($this->PageLinks[$n] as $pl)
1414
+			$annots = '/Annots [';
1415
+			foreach ($this->PageLinks[$n] as $pl)
1416 1416
 			{
1417
-				$rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1418
-				$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1419
-				if(is_string($pl[4]))
1420
-					$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1417
+				$rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]);
1418
+				$annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] ';
1419
+				if (is_string($pl[4]))
1420
+					$annots .= '/A <</S /URI /URI ' . $this->_textstring($pl[4]) . '>>>>';
1421 1421
 				else
1422 1422
 				{
1423
-					$l=$this->links[$pl[4]];
1424
-					$h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1425
-					$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k);
1423
+					$l = $this->links[$pl[4]];
1424
+					$h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
1425
+					$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k);
1426 1426
 				}
1427 1427
 			}
1428
-			$this->_out($annots.']');
1428
+			$this->_out($annots . ']');
1429 1429
 		}
1430
-		$this->_out('/Contents '.($this->n+1).' 0 R>>');
1430
+		$this->_out('/Contents ' . ($this->n + 1) . ' 0 R>>');
1431 1431
 		$this->_out('endobj');
1432 1432
 		//Page content
1433
-		$p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1433
+		$p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
1434 1434
 		$this->_newobj();
1435
-		$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
1435
+		$this->_out('<<' . $filter . '/Length ' . strlen($p) . '>>');
1436 1436
 		$this->_putstream($p);
1437 1437
 		$this->_out('endobj');
1438 1438
 	}
1439 1439
 	//Pages root
1440
-	$this->offsets[1]=strlen($this->buffer);
1440
+	$this->offsets[1] = strlen($this->buffer);
1441 1441
 	$this->_out('1 0 obj');
1442 1442
 	$this->_out('<</Type /Pages');
1443
-	$kids='/Kids [';
1444
-	for($i=0;$i<$nb;$i++)
1445
-		$kids.=(3+2*$i).' 0 R ';
1446
-	$this->_out($kids.']');
1447
-	$this->_out('/Count '.$nb);
1448
-	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
1443
+	$kids = '/Kids [';
1444
+	for ($i = 0; $i < $nb; $i++)
1445
+		$kids .= (3 + 2 * $i) . ' 0 R ';
1446
+	$this->_out($kids . ']');
1447
+	$this->_out('/Count ' . $nb);
1448
+	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt));
1449 1449
 	$this->_out('>>');
1450 1450
 	$this->_out('endobj');
1451 1451
 }
1452 1452
 
1453 1453
 function _putfonts()
1454 1454
 {
1455
-	$nf=$this->n;
1456
-	foreach($this->diffs as $diff)
1455
+	$nf = $this->n;
1456
+	foreach ($this->diffs as $diff)
1457 1457
 	{
1458 1458
 		//Encodings
1459 1459
 		$this->_newobj();
1460
-		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
1460
+		$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . ']>>');
1461 1461
 		$this->_out('endobj');
1462 1462
 	}
1463
-	foreach($this->FontFiles as $file=>$info)
1463
+	foreach ($this->FontFiles as $file=>$info)
1464 1464
 	{
1465 1465
 		//Font file embedding
1466 1466
 		$this->_newobj();
1467
-		$this->FontFiles[$file]['n']=$this->n;
1468
-		$font='';
1469
-		$f=fopen($this->_getfontpath().$file,'rb',1);
1470
-		if(!$f)
1467
+		$this->FontFiles[$file]['n'] = $this->n;
1468
+		$font = '';
1469
+		$f = fopen($this->_getfontpath() . $file, 'rb', 1);
1470
+		if (!$f)
1471 1471
 			$this->Error('Font file not found');
1472
-		while(!feof($f))
1473
-			$font.=fread($f,8192);
1472
+		while (!feof($f))
1473
+			$font .= fread($f, 8192);
1474 1474
 		fclose($f);
1475
-		$compressed=(substr($file,-2)=='.z');
1476
-		if(!$compressed && isset($info['length2']))
1475
+		$compressed = (substr($file, -2) == '.z');
1476
+		if (!$compressed && isset($info['length2']))
1477 1477
 		{
1478
-			$header=(ord($font[0])==128);
1479
-			if($header)
1478
+			$header = (ord($font[0]) == 128);
1479
+			if ($header)
1480 1480
 			{
1481 1481
 				//Strip first binary header
1482
-				$font=substr($font,6);
1482
+				$font = substr($font, 6);
1483 1483
 			}
1484
-			if($header && ord($font[$info['length1']])==128)
1484
+			if ($header && ord($font[$info['length1']]) == 128)
1485 1485
 			{
1486 1486
 				//Strip second binary header
1487
-				$font=substr($font,0,$info['length1']).substr($font,$info['length1']+6);
1487
+				$font = substr($font, 0, $info['length1']) . substr($font, $info['length1'] + 6);
1488 1488
 			}
1489 1489
 		}
1490
-		$this->_out('<</Length '.strlen($font));
1491
-		if($compressed)
1490
+		$this->_out('<</Length ' . strlen($font));
1491
+		if ($compressed)
1492 1492
 			$this->_out('/Filter /FlateDecode');
1493
-		$this->_out('/Length1 '.$info['length1']);
1494
-		if(isset($info['length2']))
1495
-			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1493
+		$this->_out('/Length1 ' . $info['length1']);
1494
+		if (isset($info['length2']))
1495
+			$this->_out('/Length2 ' . $info['length2'] . ' /Length3 0');
1496 1496
 		$this->_out('>>');
1497 1497
 		$this->_putstream($font);
1498 1498
 		$this->_out('endobj');
1499 1499
 	}
1500
-	foreach($this->fonts as $k=>$font)
1500
+	foreach ($this->fonts as $k=>$font)
1501 1501
 	{
1502 1502
 		//Font objects
1503
-		$this->fonts[$k]['n']=$this->n+1;
1504
-		$type=$font['type'];
1505
-		$name=$font['name'];
1506
-		if($type=='core')
1503
+		$this->fonts[$k]['n'] = $this->n + 1;
1504
+		$type = $font['type'];
1505
+		$name = $font['name'];
1506
+		if ($type == 'core')
1507 1507
 		{
1508 1508
 			//Standard font
1509 1509
 			$this->_newobj();
1510 1510
 			$this->_out('<</Type /Font');
1511
-			$this->_out('/BaseFont /'.$name);
1511
+			$this->_out('/BaseFont /' . $name);
1512 1512
 			$this->_out('/Subtype /Type1');
1513
-			if($name!='Symbol' && $name!='ZapfDingbats')
1513
+			if ($name != 'Symbol' && $name != 'ZapfDingbats')
1514 1514
 				$this->_out('/Encoding /WinAnsiEncoding');
1515 1515
 			$this->_out('>>');
1516 1516
 			$this->_out('endobj');
1517 1517
 		}
1518
-		elseif($type=='Type1' || $type=='TrueType')
1518
+		elseif ($type == 'Type1' || $type == 'TrueType')
1519 1519
 		{
1520 1520
 			//Additional Type1 or TrueType font
1521 1521
 			$this->_newobj();
1522 1522
 			$this->_out('<</Type /Font');
1523
-			$this->_out('/BaseFont /'.$name);
1524
-			$this->_out('/Subtype /'.$type);
1523
+			$this->_out('/BaseFont /' . $name);
1524
+			$this->_out('/Subtype /' . $type);
1525 1525
 			$this->_out('/FirstChar 32 /LastChar 255');
1526
-			$this->_out('/Widths '.($this->n+1).' 0 R');
1527
-			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1528
-			if($font['enc'])
1526
+			$this->_out('/Widths ' . ($this->n + 1) . ' 0 R');
1527
+			$this->_out('/FontDescriptor ' . ($this->n + 2) . ' 0 R');
1528
+			if ($font['enc'])
1529 1529
 			{
1530
-				if(isset($font['diff']))
1531
-					$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1530
+				if (isset($font['diff']))
1531
+					$this->_out('/Encoding ' . ($nf + $font['diff']) . ' 0 R');
1532 1532
 				else
1533 1533
 					$this->_out('/Encoding /WinAnsiEncoding');
1534 1534
 			}
@@ -1536,29 +1536,29 @@  discard block
 block discarded – undo
1536 1536
 			$this->_out('endobj');
1537 1537
 			//Widths
1538 1538
 			$this->_newobj();
1539
-			$cw=&$font['cw'];
1540
-			$s='[';
1541
-			for($i=32;$i<=255;$i++)
1542
-				$s.=$cw[chr($i)].' ';
1543
-			$this->_out($s.']');
1539
+			$cw = &$font['cw'];
1540
+			$s = '[';
1541
+			for ($i = 32; $i <= 255; $i++)
1542
+				$s .= $cw[chr($i)] . ' ';
1543
+			$this->_out($s . ']');
1544 1544
 			$this->_out('endobj');
1545 1545
 			//Descriptor
1546 1546
 			$this->_newobj();
1547
-			$s='<</Type /FontDescriptor /FontName /'.$name;
1548
-			foreach($font['desc'] as $k=>$v)
1549
-				$s.=' /'.$k.' '.$v;
1550
-			$file=$font['file'];
1551
-			if($file)
1552
-				$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1553
-			$this->_out($s.'>>');
1547
+			$s = '<</Type /FontDescriptor /FontName /' . $name;
1548
+			foreach ($font['desc'] as $k=>$v)
1549
+				$s .= ' /' . $k . ' ' . $v;
1550
+			$file = $font['file'];
1551
+			if ($file)
1552
+				$s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->FontFiles[$file]['n'] . ' 0 R';
1553
+			$this->_out($s . '>>');
1554 1554
 			$this->_out('endobj');
1555 1555
 		}
1556 1556
 		else
1557 1557
 		{
1558 1558
 			//Allow for additional types
1559
-			$mtd='_put'.strtolower($type);
1560
-			if(!method_exists($this,$mtd))
1561
-				$this->Error('Unsupported font type: '.$type);
1559
+			$mtd = '_put' . strtolower($type);
1560
+			if (!method_exists($this, $mtd))
1561
+				$this->Error('Unsupported font type: ' . $type);
1562 1562
 			$this->$mtd($font);
1563 1563
 		}
1564 1564
 	}
@@ -1566,46 +1566,46 @@  discard block
 block discarded – undo
1566 1566
 
1567 1567
 function _putimages()
1568 1568
 {
1569
-	$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
1569
+	$filter = ($this->compress) ? '/Filter /FlateDecode ' : '';
1570 1570
 	reset($this->images);
1571
-	while(list($file,$info)=each($this->images))
1571
+	while (list($file, $info) = each($this->images))
1572 1572
 	{
1573 1573
 		$this->_newobj();
1574
-		$this->images[$file]['n']=$this->n;
1574
+		$this->images[$file]['n'] = $this->n;
1575 1575
 		$this->_out('<</Type /XObject');
1576 1576
 		$this->_out('/Subtype /Image');
1577
-		$this->_out('/Width '.$info['w']);
1578
-		$this->_out('/Height '.$info['h']);
1579
-		if($info['cs']=='Indexed')
1580
-			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1577
+		$this->_out('/Width ' . $info['w']);
1578
+		$this->_out('/Height ' . $info['h']);
1579
+		if ($info['cs'] == 'Indexed')
1580
+			$this->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]');
1581 1581
 		else
1582 1582
 		{
1583
-			$this->_out('/ColorSpace /'.$info['cs']);
1584
-			if($info['cs']=='DeviceCMYK')
1583
+			$this->_out('/ColorSpace /' . $info['cs']);
1584
+			if ($info['cs'] == 'DeviceCMYK')
1585 1585
 				$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1586 1586
 		}
1587
-		$this->_out('/BitsPerComponent '.$info['bpc']);
1588
-		if(isset($info['f']))
1589
-			$this->_out('/Filter /'.$info['f']);
1590
-		if(isset($info['parms']))
1587
+		$this->_out('/BitsPerComponent ' . $info['bpc']);
1588
+		if (isset($info['f']))
1589
+			$this->_out('/Filter /' . $info['f']);
1590
+		if (isset($info['parms']))
1591 1591
 			$this->_out($info['parms']);
1592
-		if(isset($info['trns']) && is_array($info['trns']))
1592
+		if (isset($info['trns']) && is_array($info['trns']))
1593 1593
 		{
1594
-			$trns='';
1595
-			for($i=0;$i<count($info['trns']);$i++)
1596
-				$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1597
-			$this->_out('/Mask ['.$trns.']');
1594
+			$trns = '';
1595
+			for ($i = 0; $i < count($info['trns']); $i++)
1596
+				$trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' ';
1597
+			$this->_out('/Mask [' . $trns . ']');
1598 1598
 		}
1599
-		$this->_out('/Length '.strlen($info['data']).'>>');
1599
+		$this->_out('/Length ' . strlen($info['data']) . '>>');
1600 1600
 		$this->_putstream($info['data']);
1601 1601
 		unset($this->images[$file]['data']);
1602 1602
 		$this->_out('endobj');
1603 1603
 		//Palette
1604
-		if($info['cs']=='Indexed')
1604
+		if ($info['cs'] == 'Indexed')
1605 1605
 		{
1606 1606
 			$this->_newobj();
1607
-			$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1608
-			$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
1607
+			$pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal'];
1608
+			$this->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>');
1609 1609
 			$this->_putstream($pal);
1610 1610
 			$this->_out('endobj');
1611 1611
 		}
@@ -1614,16 +1614,16 @@  discard block
 block discarded – undo
1614 1614
 
1615 1615
 function _putxobjectdict()
1616 1616
 {
1617
-	foreach($this->images as $image)
1618
-		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1617
+	foreach ($this->images as $image)
1618
+		$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
1619 1619
 }
1620 1620
 
1621 1621
 function _putresourcedict()
1622 1622
 {
1623 1623
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1624 1624
 	$this->_out('/Font <<');
1625
-	foreach($this->fonts as $font)
1626
-		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1625
+	foreach ($this->fonts as $font)
1626
+		$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
1627 1627
 	$this->_out('>>');
1628 1628
 	$this->_out('/XObject <<');
1629 1629
 	$this->_putxobjectdict();
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 	$this->_putfonts();
1636 1636
 	$this->_putimages();
1637 1637
 	//Resource dictionary
1638
-	$this->offsets[2]=strlen($this->buffer);
1638
+	$this->offsets[2] = strlen($this->buffer);
1639 1639
 	$this->_out('2 0 obj');
1640 1640
 	$this->_out('<<');
1641 1641
 	$this->_putresourcedict();
@@ -1645,50 +1645,50 @@  discard block
 block discarded – undo
1645 1645
 
1646 1646
 function _putinfo()
1647 1647
 {
1648
-	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1649
-	if(!empty($this->title))
1650
-		$this->_out('/Title '.$this->_textstring($this->title));
1651
-	if(!empty($this->subject))
1652
-		$this->_out('/Subject '.$this->_textstring($this->subject));
1653
-	if(!empty($this->author))
1654
-		$this->_out('/Author '.$this->_textstring($this->author));
1655
-	if(!empty($this->keywords))
1656
-		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1657
-	if(!empty($this->creator))
1658
-		$this->_out('/Creator '.$this->_textstring($this->creator));
1659
-	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1648
+	$this->_out('/Producer ' . $this->_textstring('FPDF ' . FPDF_VERSION));
1649
+	if (!empty($this->title))
1650
+		$this->_out('/Title ' . $this->_textstring($this->title));
1651
+	if (!empty($this->subject))
1652
+		$this->_out('/Subject ' . $this->_textstring($this->subject));
1653
+	if (!empty($this->author))
1654
+		$this->_out('/Author ' . $this->_textstring($this->author));
1655
+	if (!empty($this->keywords))
1656
+		$this->_out('/Keywords ' . $this->_textstring($this->keywords));
1657
+	if (!empty($this->creator))
1658
+		$this->_out('/Creator ' . $this->_textstring($this->creator));
1659
+	$this->_out('/CreationDate ' . $this->_textstring('D:' . @date('YmdHis')));
1660 1660
 }
1661 1661
 
1662 1662
 function _putcatalog()
1663 1663
 {
1664 1664
 	$this->_out('/Type /Catalog');
1665 1665
 	$this->_out('/Pages 1 0 R');
1666
-	if($this->ZoomMode=='fullpage')
1666
+	if ($this->ZoomMode == 'fullpage')
1667 1667
 		$this->_out('/OpenAction [3 0 R /Fit]');
1668
-	elseif($this->ZoomMode=='fullwidth')
1668
+	elseif ($this->ZoomMode == 'fullwidth')
1669 1669
 		$this->_out('/OpenAction [3 0 R /FitH null]');
1670
-	elseif($this->ZoomMode=='real')
1670
+	elseif ($this->ZoomMode == 'real')
1671 1671
 		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1672
-	elseif(!is_string($this->ZoomMode))
1673
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1674
-	if($this->LayoutMode=='single')
1672
+	elseif (!is_string($this->ZoomMode))
1673
+		$this->_out('/OpenAction [3 0 R /XYZ null null ' . ($this->ZoomMode / 100) . ']');
1674
+	if ($this->LayoutMode == 'single')
1675 1675
 		$this->_out('/PageLayout /SinglePage');
1676
-	elseif($this->LayoutMode=='continuous')
1676
+	elseif ($this->LayoutMode == 'continuous')
1677 1677
 		$this->_out('/PageLayout /OneColumn');
1678
-	elseif($this->LayoutMode=='two')
1678
+	elseif ($this->LayoutMode == 'two')
1679 1679
 		$this->_out('/PageLayout /TwoColumnLeft');
1680 1680
 }
1681 1681
 
1682 1682
 function _putheader()
1683 1683
 {
1684
-	$this->_out('%PDF-'.$this->PDFVersion);
1684
+	$this->_out('%PDF-' . $this->PDFVersion);
1685 1685
 }
1686 1686
 
1687 1687
 function _puttrailer()
1688 1688
 {
1689
-	$this->_out('/Size '.($this->n+1));
1690
-	$this->_out('/Root '.$this->n.' 0 R');
1691
-	$this->_out('/Info '.($this->n-1).' 0 R');
1689
+	$this->_out('/Size ' . ($this->n + 1));
1690
+	$this->_out('/Root ' . $this->n . ' 0 R');
1691
+	$this->_out('/Info ' . ($this->n - 1) . ' 0 R');
1692 1692
 }
1693 1693
 
1694 1694
 function _enddoc()
@@ -1709,12 +1709,12 @@  discard block
 block discarded – undo
1709 1709
 	$this->_out('>>');
1710 1710
 	$this->_out('endobj');
1711 1711
 	//Cross-ref
1712
-	$o=strlen($this->buffer);
1712
+	$o = strlen($this->buffer);
1713 1713
 	$this->_out('xref');
1714
-	$this->_out('0 '.($this->n+1));
1714
+	$this->_out('0 ' . ($this->n + 1));
1715 1715
 	$this->_out('0000000000 65535 f ');
1716
-	for($i=1;$i<=$this->n;$i++)
1717
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1716
+	for ($i = 1; $i <= $this->n; $i++)
1717
+		$this->_out(sprintf('%010d 00000 n ', $this->offsets[$i]));
1718 1718
 	//Trailer
1719 1719
 	$this->_out('trailer');
1720 1720
 	$this->_out('<<');
@@ -1723,13 +1723,13 @@  discard block
 block discarded – undo
1723 1723
 	$this->_out('startxref');
1724 1724
 	$this->_out($o);
1725 1725
 	$this->_out('%%EOF');
1726
-	$this->state=3;
1726
+	$this->state = 3;
1727 1727
 }
1728 1728
 //End of class
1729 1729
 }
1730 1730
 
1731 1731
 //Handle special IE contype request
1732
-if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype')
1732
+if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype')
1733 1733
 {
1734 1734
 	header('Content-Type: application/pdf');
1735 1735
 	exit;
Please login to merge, or discard this patch.
Braces   +562 added lines, -432 removed lines patch added patch discarded remove patch
@@ -112,21 +112,23 @@  discard block
 block discarded – undo
112 112
 		'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
113 113
 		'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
114 114
 	//Scale factor
115
-	if($unit=='pt')
116
-		$this->k=1;
117
-	elseif($unit=='mm')
118
-		$this->k=72/25.4;
119
-	elseif($unit=='cm')
120
-		$this->k=72/2.54;
121
-	elseif($unit=='in')
122
-		$this->k=72;
123
-	else
124
-		$this->Error('Incorrect unit: '.$unit);
115
+	if($unit=='pt') {
116
+			$this->k=1;
117
+	} elseif($unit=='mm') {
118
+			$this->k=72/25.4;
119
+	} elseif($unit=='cm') {
120
+			$this->k=72/2.54;
121
+	} elseif($unit=='in') {
122
+			$this->k=72;
123
+	} else {
124
+			$this->Error('Incorrect unit: '.$unit);
125
+	}
125 126
 	//Page format
126 127
 	$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
127 128
 		'letter'=>array(612,792), 'legal'=>array(612,1008));
128
-	if(is_string($format))
129
-		$format=$this->_getpageformat($format);
129
+	if(is_string($format)) {
130
+			$format=$this->_getpageformat($format);
131
+	}
130 132
 	$this->DefPageFormat=$format;
131 133
 	$this->CurPageFormat=$format;
132 134
 	//Page orientation
@@ -136,15 +138,14 @@  discard block
 block discarded – undo
136 138
 		$this->DefOrientation='P';
137 139
 		$this->w=$this->DefPageFormat[0];
138 140
 		$this->h=$this->DefPageFormat[1];
139
-	}
140
-	elseif($orientation=='l' || $orientation=='landscape')
141
+	} elseif($orientation=='l' || $orientation=='landscape')
141 142
 	{
142 143
 		$this->DefOrientation='L';
143 144
 		$this->w=$this->DefPageFormat[1];
144 145
 		$this->h=$this->DefPageFormat[0];
146
+	} else {
147
+			$this->Error('Incorrect orientation: '.$orientation);
145 148
 	}
146
-	else
147
-		$this->Error('Incorrect orientation: '.$orientation);
148 149
 	$this->CurOrientation=$this->DefOrientation;
149 150
 	$this->wPt=$this->w*$this->k;
150 151
 	$this->hPt=$this->h*$this->k;
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
 	//Set left, top and right margins
171 172
 	$this->lMargin=$left;
172 173
 	$this->tMargin=$top;
173
-	if($right===null)
174
-		$right=$left;
174
+	if($right===null) {
175
+			$right=$left;
176
+	}
175 177
 	$this->rMargin=$right;
176 178
 }
177 179
 
@@ -179,9 +181,10 @@  discard block
 block discarded – undo
179 181
 {
180 182
 	//Set left margin
181 183
 	$this->lMargin=$margin;
182
-	if($this->page>0 && $this->x<$margin)
183
-		$this->x=$margin;
184
-}
184
+	if($this->page>0 && $this->x<$margin) {
185
+			$this->x=$margin;
186
+	}
187
+	}
185 188
 
186 189
 function SetTopMargin($margin)
187 190
 {
@@ -206,62 +209,70 @@  discard block
 block discarded – undo
206 209
 function SetDisplayMode($zoom, $layout='continuous')
207 210
 {
208 211
 	//Set display mode in viewer
209
-	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
210
-		$this->ZoomMode=$zoom;
211
-	else
212
-		$this->Error('Incorrect zoom display mode: '.$zoom);
213
-	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
214
-		$this->LayoutMode=$layout;
215
-	else
216
-		$this->Error('Incorrect layout display mode: '.$layout);
217
-}
212
+	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
213
+			$this->ZoomMode=$zoom;
214
+	} else {
215
+			$this->Error('Incorrect zoom display mode: '.$zoom);
216
+	}
217
+	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
218
+			$this->LayoutMode=$layout;
219
+	} else {
220
+			$this->Error('Incorrect layout display mode: '.$layout);
221
+	}
222
+	}
218 223
 
219 224
 function SetCompression($compress)
220 225
 {
221 226
 	//Set page compression
222
-	if(function_exists('gzcompress'))
223
-		$this->compress=$compress;
224
-	else
225
-		$this->compress=false;
226
-}
227
+	if(function_exists('gzcompress')) {
228
+			$this->compress=$compress;
229
+	} else {
230
+			$this->compress=false;
231
+	}
232
+	}
227 233
 
228 234
 function SetTitle($title, $isUTF8=false)
229 235
 {
230 236
 	//Title of document
231
-	if($isUTF8)
232
-		$title=$this->_UTF8toUTF16($title);
237
+	if($isUTF8) {
238
+			$title=$this->_UTF8toUTF16($title);
239
+	}
233 240
 	$this->title=$title;
234 241
 }
235 242
 
236 243
 function SetSubject($subject, $isUTF8=false)
237 244
 {
238 245
 	//Subject of document
239
-	if($isUTF8)
240
-		$subject=$this->_UTF8toUTF16($subject);
246
+	if($isUTF8) {
247
+			$subject=$this->_UTF8toUTF16($subject);
248
+	}
241 249
 	$this->subject=$subject;
242 250
 }
243 251
 
244 252
 function SetAuthor($author, $isUTF8=false)
245 253
 {
246 254
 	//Author of document
247
-	if($isUTF8)
248
-		$author=$this->_UTF8toUTF16($author);
255
+	if($isUTF8) {
256
+			$author=$this->_UTF8toUTF16($author);
257
+	}
249 258
 	$this->author=$author;
250 259
 }
251 260
 
252 261
 function SetKeywords($keywords, $isUTF8=false)
253 262
 {
254 263
 	//Keywords of document
255
-	if($isUTF8)
256
-		$keywords=$this->_UTF8toUTF16($keywords);
264
+	if($isUTF8) {
265
+			$keywords=$this->_UTF8toUTF16($keywords);
266
+	}
257 267
 	$this->keywords=$keywords;
258 268
 }
259 269
 
260 270
 function SetCreator($creator, $isUTF8=false)
261 271
 {
262 272
 	//Creator of document
263
-	if($isUTF8)
264
-		$creator=$this->_UTF8toUTF16($creator);
273
+	if($isUTF8) {
274
+			$creator=$this->_UTF8toUTF16($creator);
275
+	}
265 276
 	$this->creator=$creator;
266 277
 }
267 278
 
@@ -286,10 +297,12 @@  discard block
 block discarded – undo
286 297
 function Close()
287 298
 {
288 299
 	//Terminate document
289
-	if($this->state==3)
290
-		return;
291
-	if($this->page==0)
292
-		$this->AddPage();
300
+	if($this->state==3) {
301
+			return;
302
+	}
303
+	if($this->page==0) {
304
+			$this->AddPage();
305
+	}
293 306
 	//Page footer
294 307
 	$this->InFooter=true;
295 308
 	$this->Footer();
@@ -303,8 +316,9 @@  discard block
 block discarded – undo
303 316
 function AddPage($orientation='', $format='')
304 317
 {
305 318
 	//Start a new page
306
-	if($this->state==0)
307
-		$this->Open();
319
+	if($this->state==0) {
320
+			$this->Open();
321
+	}
308 322
 	$family=$this->FontFamily;
309 323
 	$style=$this->FontStyle.($this->underline ? 'U' : '');
310 324
 	$size=$this->FontSizePt;
@@ -330,15 +344,18 @@  discard block
 block discarded – undo
330 344
 	$this->LineWidth=$lw;
331 345
 	$this->_out(sprintf('%.2F w',$lw*$this->k));
332 346
 	//Set font
333
-	if($family)
334
-		$this->SetFont($family,$style,$size);
347
+	if($family) {
348
+			$this->SetFont($family,$style,$size);
349
+	}
335 350
 	//Set colors
336 351
 	$this->DrawColor=$dc;
337
-	if($dc!='0 G')
338
-		$this->_out($dc);
352
+	if($dc!='0 G') {
353
+			$this->_out($dc);
354
+	}
339 355
 	$this->FillColor=$fc;
340
-	if($fc!='0 g')
341
-		$this->_out($fc);
356
+	if($fc!='0 g') {
357
+			$this->_out($fc);
358
+	}
342 359
 	$this->TextColor=$tc;
343 360
 	$this->ColorFlag=$cf;
344 361
 	//Page header
@@ -352,8 +369,9 @@  discard block
 block discarded – undo
352 369
 		$this->_out(sprintf('%.2F w',$lw*$this->k));
353 370
 	}
354 371
 	//Restore font
355
-	if($family)
356
-		$this->SetFont($family,$style,$size);
372
+	if($family) {
373
+			$this->SetFont($family,$style,$size);
374
+	}
357 375
 	//Restore colors
358 376
 	if($this->DrawColor!=$dc)
359 377
 	{
@@ -388,33 +406,38 @@  discard block
 block discarded – undo
388 406
 function SetDrawColor($r, $g=null, $b=null)
389 407
 {
390 408
 	//Set color for all stroking operations
391
-	if(($r==0 && $g==0 && $b==0) || $g===null)
392
-		$this->DrawColor=sprintf('%.3F G',$r/255);
393
-	else
394
-		$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
395
-	if($this->page>0)
396
-		$this->_out($this->DrawColor);
397
-}
409
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
410
+			$this->DrawColor=sprintf('%.3F G',$r/255);
411
+	} else {
412
+			$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
413
+	}
414
+	if($this->page>0) {
415
+			$this->_out($this->DrawColor);
416
+	}
417
+	}
398 418
 
399 419
 function SetFillColor($r, $g=null, $b=null)
400 420
 {
401 421
 	//Set color for all filling operations
402
-	if(($r==0 && $g==0 && $b==0) || $g===null)
403
-		$this->FillColor=sprintf('%.3F g',$r/255);
404
-	else
405
-		$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
422
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
423
+			$this->FillColor=sprintf('%.3F g',$r/255);
424
+	} else {
425
+			$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
426
+	}
406 427
 	$this->ColorFlag=($this->FillColor!=$this->TextColor);
407
-	if($this->page>0)
408
-		$this->_out($this->FillColor);
409
-}
428
+	if($this->page>0) {
429
+			$this->_out($this->FillColor);
430
+	}
431
+	}
410 432
 
411 433
 function SetTextColor($r, $g=null, $b=null)
412 434
 {
413 435
 	//Set color for text
414
-	if(($r==0 && $g==0 && $b==0) || $g===null)
415
-		$this->TextColor=sprintf('%.3F g',$r/255);
416
-	else
417
-		$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
436
+	if(($r==0 && $g==0 && $b==0) || $g===null) {
437
+			$this->TextColor=sprintf('%.3F g',$r/255);
438
+	} else {
439
+			$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
440
+	}
418 441
 	$this->ColorFlag=($this->FillColor!=$this->TextColor);
419 442
 }
420 443
 
@@ -425,8 +448,9 @@  discard block
 block discarded – undo
425 448
 	$cw=&$this->CurrentFont['cw'];
426 449
 	$w=0;
427 450
 	$l=strlen($s);
428
-	for($i=0;$i<$l;$i++)
429
-		$w+=$cw[$s[$i]];
451
+	for($i=0;$i<$l;$i++) {
452
+			$w+=$cw[$s[$i]];
453
+	}
430 454
 	return $w*$this->FontSize/1000;
431 455
 }
432 456
 
@@ -434,9 +458,10 @@  discard block
 block discarded – undo
434 458
 {
435 459
 	//Set line width
436 460
 	$this->LineWidth=$width;
437
-	if($this->page>0)
438
-		$this->_out(sprintf('%.2F w',$width*$this->k));
439
-}
461
+	if($this->page>0) {
462
+			$this->_out(sprintf('%.2F w',$width*$this->k));
463
+	}
464
+	}
440 465
 
441 466
 function Line($x1, $y1, $x2, $y2)
442 467
 {
@@ -447,12 +472,13 @@  discard block
 block discarded – undo
447 472
 function Rect($x, $y, $w, $h, $style='')
448 473
 {
449 474
 	//Draw a rectangle
450
-	if($style=='F')
451
-		$op='f';
452
-	elseif($style=='FD' || $style=='DF')
453
-		$op='B';
454
-	else
455
-		$op='S';
475
+	if($style=='F') {
476
+			$op='f';
477
+	} elseif($style=='FD' || $style=='DF') {
478
+			$op='B';
479
+	} else {
480
+			$op='S';
481
+	}
456 482
 	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
457 483
 }
458 484
 
@@ -460,19 +486,24 @@  discard block
 block discarded – undo
460 486
 {
461 487
 	//Add a TrueType or Type1 font
462 488
 	$family=strtolower($family);
463
-	if($file=='')
464
-		$file=str_replace(' ','',$family).strtolower($style).'.php';
465
-	if($family=='arial')
466
-		$family='helvetica';
489
+	if($file=='') {
490
+			$file=str_replace(' ','',$family).strtolower($style).'.php';
491
+	}
492
+	if($family=='arial') {
493
+			$family='helvetica';
494
+	}
467 495
 	$style=strtoupper($style);
468
-	if($style=='IB')
469
-		$style='BI';
496
+	if($style=='IB') {
497
+			$style='BI';
498
+	}
470 499
 	$fontkey=$family.$style;
471
-	if(isset($this->fonts[$fontkey]))
472
-		return;
500
+	if(isset($this->fonts[$fontkey])) {
501
+			return;
502
+	}
473 503
 	include($this->_getfontpath().$file);
474
-	if(!isset($name))
475
-		$this->Error('Could not include font definition file');
504
+	if(!isset($name)) {
505
+			$this->Error('Could not include font definition file');
506
+	}
476 507
 	$i=count($this->fonts)+1;
477 508
 	$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
478 509
 	if($diff)
@@ -497,10 +528,11 @@  discard block
 block discarded – undo
497 528
 	}
498 529
 	if($file)
499 530
 	{
500
-		if($type=='TrueType')
501
-			$this->FontFiles[$file]=array('length1'=>$originalsize);
502
-		else
503
-			$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
531
+		if($type=='TrueType') {
532
+					$this->FontFiles[$file]=array('length1'=>$originalsize);
533
+		} else {
534
+					$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
535
+		}
504 536
 	}
505 537
 }
506 538
 
@@ -510,27 +542,32 @@  discard block
 block discarded – undo
510 542
 	global $fpdf_charwidths;
511 543
 
512 544
 	$family=strtolower($family);
513
-	if($family=='')
514
-		$family=$this->FontFamily;
515
-	if($family=='arial')
516
-		$family='helvetica';
517
-	elseif($family=='symbol' || $family=='zapfdingbats')
518
-		$style='';
545
+	if($family=='') {
546
+			$family=$this->FontFamily;
547
+	}
548
+	if($family=='arial') {
549
+			$family='helvetica';
550
+	} elseif($family=='symbol' || $family=='zapfdingbats') {
551
+			$style='';
552
+	}
519 553
 	$style=strtoupper($style);
520 554
 	if(strpos($style,'U')!==false)
521 555
 	{
522 556
 		$this->underline=true;
523 557
 		$style=str_replace('U','',$style);
558
+	} else {
559
+			$this->underline=false;
560
+	}
561
+	if($style=='IB') {
562
+			$style='BI';
563
+	}
564
+	if($size==0) {
565
+			$size=$this->FontSizePt;
524 566
 	}
525
-	else
526
-		$this->underline=false;
527
-	if($style=='IB')
528
-		$style='BI';
529
-	if($size==0)
530
-		$size=$this->FontSizePt;
531 567
 	//Test if font is already selected
532
-	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
533
-		return;
568
+	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) {
569
+			return;
570
+	}
534 571
 	//Test if used for the first time
535 572
 	$fontkey=$family.$style;
536 573
 	if(!isset($this->fonts[$fontkey]))
@@ -542,19 +579,21 @@  discard block
 block discarded – undo
542 579
 			{
543 580
 				//Load metric file
544 581
 				$file=$family;
545
-				if($family=='times' || $family=='helvetica')
546
-					$file.=strtolower($style);
582
+				if($family=='times' || $family=='helvetica') {
583
+									$file.=strtolower($style);
584
+				}
547 585
 				include($this->_getfontpath().$file.'.php');
548
-				if(!isset($fpdf_charwidths[$fontkey]))
549
-					$this->Error('Could not include font metric file');
586
+				if(!isset($fpdf_charwidths[$fontkey])) {
587
+									$this->Error('Could not include font metric file');
588
+				}
550 589
 			}
551 590
 			$i=count($this->fonts)+1;
552 591
 			$name=$this->CoreFonts[$fontkey];
553 592
 			$cw=$fpdf_charwidths[$fontkey];
554 593
 			$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
594
+		} else {
595
+					$this->Error('Undefined font: '.$family.' '.$style);
555 596
 		}
556
-		else
557
-			$this->Error('Undefined font: '.$family.' '.$style);
558 597
 	}
559 598
 	//Select it
560 599
 	$this->FontFamily=$family;
@@ -562,20 +601,23 @@  discard block
 block discarded – undo
562 601
 	$this->FontSizePt=$size;
563 602
 	$this->FontSize=$size/$this->k;
564 603
 	$this->CurrentFont=&$this->fonts[$fontkey];
565
-	if($this->page>0)
566
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
567
-}
604
+	if($this->page>0) {
605
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
606
+	}
607
+	}
568 608
 
569 609
 function SetFontSize($size)
570 610
 {
571 611
 	//Set font size in points
572
-	if($this->FontSizePt==$size)
573
-		return;
612
+	if($this->FontSizePt==$size) {
613
+			return;
614
+	}
574 615
 	$this->FontSizePt=$size;
575 616
 	$this->FontSize=$size/$this->k;
576
-	if($this->page>0)
577
-		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
578
-}
617
+	if($this->page>0) {
618
+			$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
619
+	}
620
+	}
579 621
 
580 622
 function AddLink()
581 623
 {
@@ -588,10 +630,12 @@  discard block
 block discarded – undo
588 630
 function SetLink($link, $y=0, $page=-1)
589 631
 {
590 632
 	//Set destination of internal link
591
-	if($y==-1)
592
-		$y=$this->y;
593
-	if($page==-1)
594
-		$page=$this->page;
633
+	if($y==-1) {
634
+			$y=$this->y;
635
+	}
636
+	if($page==-1) {
637
+			$page=$this->page;
638
+	}
595 639
 	$this->links[$link]=array($page, $y);
596 640
 }
597 641
 
@@ -605,10 +649,12 @@  discard block
 block discarded – undo
605 649
 {
606 650
 	//Output a string
607 651
 	$s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
608
-	if($this->underline && $txt!='')
609
-		$s.=' '.$this->_dounderline($x,$y,$txt);
610
-	if($this->ColorFlag)
611
-		$s='q '.$this->TextColor.' '.$s.' Q';
652
+	if($this->underline && $txt!='') {
653
+			$s.=' '.$this->_dounderline($x,$y,$txt);
654
+	}
655
+	if($this->ColorFlag) {
656
+			$s='q '.$this->TextColor.' '.$s.' Q';
657
+	}
612 658
 	$this->_out($s);
613 659
 }
614 660
 
@@ -640,74 +686,89 @@  discard block
 block discarded – undo
640 686
 			$this->_out(sprintf('%.3F Tw',$ws*$k));
641 687
 		}
642 688
 	}
643
-	if($w==0)
644
-		$w=$this->w-$this->rMargin-$this->x;
689
+	if($w==0) {
690
+			$w=$this->w-$this->rMargin-$this->x;
691
+	}
645 692
 	$s='';
646 693
 	if($fill || $border==1)
647 694
 	{
648
-		if($fill)
649
-			$op=($border==1) ? 'B' : 'f';
650
-		else
651
-			$op='S';
695
+		if($fill) {
696
+					$op=($border==1) ? 'B' : 'f';
697
+		} else {
698
+					$op='S';
699
+		}
652 700
 		$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
653 701
 	}
654 702
 	if(is_string($border))
655 703
 	{
656 704
 		$x=$this->x;
657 705
 		$y=$this->y;
658
-		if(strpos($border,'L')!==false)
659
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
660
-		if(strpos($border,'T')!==false)
661
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
662
-		if(strpos($border,'R')!==false)
663
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
664
-		if(strpos($border,'B')!==false)
665
-			$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
706
+		if(strpos($border,'L')!==false) {
707
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
708
+		}
709
+		if(strpos($border,'T')!==false) {
710
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
711
+		}
712
+		if(strpos($border,'R')!==false) {
713
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
714
+		}
715
+		if(strpos($border,'B')!==false) {
716
+					$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
717
+		}
666 718
 	}
667 719
 	if($txt!=='')
668 720
 	{
669
-		if($align=='R')
670
-			$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
671
-		elseif($align=='C')
672
-			$dx=($w-$this->GetStringWidth($txt))/2;
673
-		else
674
-			$dx=$this->cMargin;
675
-		if($this->ColorFlag)
676
-			$s.='q '.$this->TextColor.' ';
721
+		if($align=='R') {
722
+					$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
723
+		} elseif($align=='C') {
724
+					$dx=($w-$this->GetStringWidth($txt))/2;
725
+		} else {
726
+					$dx=$this->cMargin;
727
+		}
728
+		if($this->ColorFlag) {
729
+					$s.='q '.$this->TextColor.' ';
730
+		}
677 731
 		$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
678 732
 		$s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
679
-		if($this->underline)
680
-			$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
681
-		if($this->ColorFlag)
682
-			$s.=' Q';
683
-		if($link)
684
-			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
685
-	}
686
-	if($s)
687
-		$this->_out($s);
733
+		if($this->underline) {
734
+					$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
735
+		}
736
+		if($this->ColorFlag) {
737
+					$s.=' Q';
738
+		}
739
+		if($link) {
740
+					$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
741
+		}
742
+	}
743
+	if($s) {
744
+			$this->_out($s);
745
+	}
688 746
 	$this->lasth=$h;
689 747
 	if($ln>0)
690 748
 	{
691 749
 		//Go to next line
692 750
 		$this->y+=$h;
693
-		if($ln==1)
694
-			$this->x=$this->lMargin;
751
+		if($ln==1) {
752
+					$this->x=$this->lMargin;
753
+		}
754
+	} else {
755
+			$this->x+=$w;
756
+	}
695 757
 	}
696
-	else
697
-		$this->x+=$w;
698
-}
699 758
 
700 759
 function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
701 760
 {
702 761
 	//Output text with automatic or explicit line breaks
703 762
 	$cw=&$this->CurrentFont['cw'];
704
-	if($w==0)
705
-		$w=$this->w-$this->rMargin-$this->x;
763
+	if($w==0) {
764
+			$w=$this->w-$this->rMargin-$this->x;
765
+	}
706 766
 	$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
707 767
 	$s=str_replace("\r",'',$txt);
708 768
 	$nb=strlen($s);
709
-	if($nb>0 && $s[$nb-1]=="\n")
710
-		$nb--;
769
+	if($nb>0 && $s[$nb-1]=="\n") {
770
+			$nb--;
771
+	}
711 772
 	$b=0;
712 773
 	if($border)
713 774
 	{
@@ -716,14 +777,15 @@  discard block
 block discarded – undo
716 777
 			$border='LTRB';
717 778
 			$b='LRT';
718 779
 			$b2='LR';
719
-		}
720
-		else
780
+		} else
721 781
 		{
722 782
 			$b2='';
723
-			if(strpos($border,'L')!==false)
724
-				$b2.='L';
725
-			if(strpos($border,'R')!==false)
726
-				$b2.='R';
783
+			if(strpos($border,'L')!==false) {
784
+							$b2.='L';
785
+			}
786
+			if(strpos($border,'R')!==false) {
787
+							$b2.='R';
788
+			}
727 789
 			$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
728 790
 		}
729 791
 	}
@@ -752,8 +814,9 @@  discard block
 block discarded – undo
752 814
 			$l=0;
753 815
 			$ns=0;
754 816
 			$nl++;
755
-			if($border && $nl==2)
756
-				$b=$b2;
817
+			if($border && $nl==2) {
818
+							$b=$b2;
819
+			}
757 820
 			continue;
758 821
 		}
759 822
 		if($c==' ')
@@ -768,16 +831,16 @@  discard block
 block discarded – undo
768 831
 			//Automatic line break
769 832
 			if($sep==-1)
770 833
 			{
771
-				if($i==$j)
772
-					$i++;
834
+				if($i==$j) {
835
+									$i++;
836
+				}
773 837
 				if($this->ws>0)
774 838
 				{
775 839
 					$this->ws=0;
776 840
 					$this->_out('0 Tw');
777 841
 				}
778 842
 				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
779
-			}
780
-			else
843
+			} else
781 844
 			{
782 845
 				if($align=='J')
783 846
 				{
@@ -792,11 +855,12 @@  discard block
 block discarded – undo
792 855
 			$l=0;
793 856
 			$ns=0;
794 857
 			$nl++;
795
-			if($border && $nl==2)
796
-				$b=$b2;
858
+			if($border && $nl==2) {
859
+							$b=$b2;
860
+			}
861
+		} else {
862
+					$i++;
797 863
 		}
798
-		else
799
-			$i++;
800 864
 	}
801 865
 	//Last chunk
802 866
 	if($this->ws>0)
@@ -804,8 +868,9 @@  discard block
 block discarded – undo
804 868
 		$this->ws=0;
805 869
 		$this->_out('0 Tw');
806 870
 	}
807
-	if($border && strpos($border,'B')!==false)
808
-		$b.='B';
871
+	if($border && strpos($border,'B')!==false) {
872
+			$b.='B';
873
+	}
809 874
 	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
810 875
 	$this->x=$this->lMargin;
811 876
 }
@@ -844,8 +909,9 @@  discard block
 block discarded – undo
844 909
 			$nl++;
845 910
 			continue;
846 911
 		}
847
-		if($c==' ')
848
-			$sep=$i;
912
+		if($c==' ') {
913
+					$sep=$i;
914
+		}
849 915
 		$l+=$cw[$c];
850 916
 		if($l>$wmax)
851 917
 		{
@@ -863,11 +929,11 @@  discard block
 block discarded – undo
863 929
 					$nl++;
864 930
 					continue;
865 931
 				}
866
-				if($i==$j)
867
-					$i++;
932
+				if($i==$j) {
933
+									$i++;
934
+				}
868 935
 				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
869
-			}
870
-			else
936
+			} else
871 937
 			{
872 938
 				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
873 939
 				$i=$sep+1;
@@ -882,24 +948,26 @@  discard block
 block discarded – undo
882 948
 				$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
883 949
 			}
884 950
 			$nl++;
951
+		} else {
952
+					$i++;
885 953
 		}
886
-		else
887
-			$i++;
888 954
 	}
889 955
 	//Last chunk
890
-	if($i!=$j)
891
-		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
892
-}
956
+	if($i!=$j) {
957
+			$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
958
+	}
959
+	}
893 960
 
894 961
 function Ln($h=null)
895 962
 {
896 963
 	//Line feed; default value is last cell height
897 964
 	$this->x=$this->lMargin;
898
-	if($h===null)
899
-		$this->y+=$this->lasth;
900
-	else
901
-		$this->y+=$h;
902
-}
965
+	if($h===null) {
966
+			$this->y+=$this->lasth;
967
+	} else {
968
+			$this->y+=$h;
969
+	}
970
+	}
903 971
 
904 972
 function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
905 973
 {
@@ -910,33 +978,36 @@  discard block
 block discarded – undo
910 978
 		if($type=='')
911 979
 		{
912 980
 			$pos=strrpos($file,'.');
913
-			if(!$pos)
914
-				$this->Error('Image file has no extension and no type was specified: '.$file);
981
+			if(!$pos) {
982
+							$this->Error('Image file has no extension and no type was specified: '.$file);
983
+			}
915 984
 			$type=substr($file,$pos+1);
916 985
 		}
917 986
 		$type=strtolower($type);
918
-		if($type=='jpeg')
919
-			$type='jpg';
987
+		if($type=='jpeg') {
988
+					$type='jpg';
989
+		}
920 990
 		$mtd='_parse'.$type;
921
-		if(!method_exists($this,$mtd))
922
-			$this->Error('Unsupported image type: '.$type);
991
+		if(!method_exists($this,$mtd)) {
992
+					$this->Error('Unsupported image type: '.$type);
993
+		}
923 994
 		$info=$this->$mtd($file);
924 995
 		$info['i']=count($this->images)+1;
925 996
 		$this->images[$file]=$info;
997
+	} else {
998
+			$info=$this->images[$file];
926 999
 	}
927
-	else
928
-		$info=$this->images[$file];
929 1000
 	//Automatic width and height calculation if needed
930 1001
 	if($w==0 && $h==0)
931 1002
 	{
932 1003
 		//Put image at 72 dpi
933 1004
 		$w=$info['w']/$this->k;
934 1005
 		$h=$info['h']/$this->k;
1006
+	} elseif($w==0) {
1007
+			$w=$h*$info['w']/$info['h'];
1008
+	} elseif($h==0) {
1009
+			$h=$w*$info['h']/$info['w'];
935 1010
 	}
936
-	elseif($w==0)
937
-		$w=$h*$info['w']/$info['h'];
938
-	elseif($h==0)
939
-		$h=$w*$info['h']/$info['w'];
940 1011
 	//Flowing mode
941 1012
 	if($y===null)
942 1013
 	{
@@ -950,12 +1021,14 @@  discard block
 block discarded – undo
950 1021
 		$y=$this->y;
951 1022
 		$this->y+=$h;
952 1023
 	}
953
-	if($x===null)
954
-		$x=$this->x;
1024
+	if($x===null) {
1025
+			$x=$this->x;
1026
+	}
955 1027
 	$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
956
-	if($link)
957
-		$this->Link($x,$y,$w,$h,$link);
958
-}
1028
+	if($link) {
1029
+			$this->Link($x,$y,$w,$h,$link);
1030
+	}
1031
+	}
959 1032
 
960 1033
 function GetX()
961 1034
 {
@@ -966,11 +1039,12 @@  discard block
 block discarded – undo
966 1039
 function SetX($x)
967 1040
 {
968 1041
 	//Set x position
969
-	if($x>=0)
970
-		$this->x=$x;
971
-	else
972
-		$this->x=$this->w+$x;
973
-}
1042
+	if($x>=0) {
1043
+			$this->x=$x;
1044
+	} else {
1045
+			$this->x=$this->w+$x;
1046
+	}
1047
+	}
974 1048
 
975 1049
 function GetY()
976 1050
 {
@@ -982,11 +1056,12 @@  discard block
 block discarded – undo
982 1056
 {
983 1057
 	//Set y position and reset x
984 1058
 	$this->x=$this->lMargin;
985
-	if($y>=0)
986
-		$this->y=$y;
987
-	else
988
-		$this->y=$this->h+$y;
989
-}
1059
+	if($y>=0) {
1060
+			$this->y=$y;
1061
+	} else {
1062
+			$this->y=$this->h+$y;
1063
+	}
1064
+	}
990 1065
 
991 1066
 function SetXY($x, $y)
992 1067
 {
@@ -998,8 +1073,9 @@  discard block
 block discarded – undo
998 1073
 function Output($name='', $dest='')
999 1074
 {
1000 1075
 	//Output PDF to some destination
1001
-	if($this->state<3)
1002
-		$this->Close();
1076
+	if($this->state<3) {
1077
+			$this->Close();
1078
+	}
1003 1079
 	$dest=strtoupper($dest);
1004 1080
 	if($dest=='')
1005 1081
 	{
@@ -1007,22 +1083,24 @@  discard block
 block discarded – undo
1007 1083
 		{
1008 1084
 			$name='doc.pdf';
1009 1085
 			$dest='I';
1086
+		} else {
1087
+					$dest='F';
1010 1088
 		}
1011
-		else
1012
-			$dest='F';
1013 1089
 	}
1014 1090
 	switch($dest)
1015 1091
 	{
1016 1092
 		case 'I':
1017 1093
 			//Send to standard output
1018
-			if(ob_get_length())
1019
-				$this->Error('Some data has already been output, can\'t send PDF file');
1094
+			if(ob_get_length()) {
1095
+							$this->Error('Some data has already been output, can\'t send PDF file');
1096
+			}
1020 1097
 			if(php_sapi_name()!='cli')
1021 1098
 			{
1022 1099
 				//We send to a browser
1023 1100
 				header('Content-Type: application/pdf');
1024
-				if(headers_sent())
1025
-					$this->Error('Some data has already been output, can\'t send PDF file');
1101
+				if(headers_sent()) {
1102
+									$this->Error('Some data has already been output, can\'t send PDF file');
1103
+				}
1026 1104
 				header('Content-Length: '.strlen($this->buffer));
1027 1105
 				header('Content-Disposition: inline; filename="'.$name.'"');
1028 1106
 				header('Cache-Control: private, max-age=0, must-revalidate');
@@ -1033,11 +1111,13 @@  discard block
 block discarded – undo
1033 1111
 			break;
1034 1112
 		case 'D':
1035 1113
 			//Download file
1036
-			if(ob_get_length())
1037
-				$this->Error('Some data has already been output, can\'t send PDF file');
1114
+			if(ob_get_length()) {
1115
+							$this->Error('Some data has already been output, can\'t send PDF file');
1116
+			}
1038 1117
 			header('Content-Type: application/x-download');
1039
-			if(headers_sent())
1040
-				$this->Error('Some data has already been output, can\'t send PDF file');
1118
+			if(headers_sent()) {
1119
+							$this->Error('Some data has already been output, can\'t send PDF file');
1120
+			}
1041 1121
 			header('Content-Length: '.strlen($this->buffer));
1042 1122
 			header('Content-Disposition: attachment; filename="'.$name.'"');
1043 1123
 			header('Cache-Control: private, max-age=0, must-revalidate');
@@ -1048,8 +1128,9 @@  discard block
 block discarded – undo
1048 1128
 		case 'F':
1049 1129
 			//Save to local file
1050 1130
 			$f=fopen($name,'wb');
1051
-			if(!$f)
1052
-				$this->Error('Unable to create output file: '.$name);
1131
+			if(!$f) {
1132
+							$this->Error('Unable to create output file: '.$name);
1133
+			}
1053 1134
 			fwrite($f,$this->buffer,strlen($this->buffer));
1054 1135
 			fclose($f);
1055 1136
 			break;
@@ -1070,29 +1151,34 @@  discard block
 block discarded – undo
1070 1151
 function _dochecks()
1071 1152
 {
1072 1153
 	//Check availability of %F
1073
-	if(sprintf('%.1F',1.0)!='1.0')
1074
-		$this->Error('This version of PHP is not supported');
1154
+	if(sprintf('%.1F',1.0)!='1.0') {
1155
+			$this->Error('This version of PHP is not supported');
1156
+	}
1075 1157
 	//Check mbstring overloading
1076
-	if(ini_get('mbstring.func_overload') & 2)
1077
-		$this->Error('mbstring overloading must be disabled');
1158
+	if(ini_get('mbstring.func_overload') & 2) {
1159
+			$this->Error('mbstring overloading must be disabled');
1160
+	}
1078 1161
 	//Disable runtime magic quotes
1079
-	if(get_magic_quotes_runtime())
1080
-		@set_magic_quotes_runtime(0);
1081
-}
1162
+	if(get_magic_quotes_runtime()) {
1163
+			@set_magic_quotes_runtime(0);
1164
+	}
1165
+	}
1082 1166
 
1083 1167
 function _getpageformat($format)
1084 1168
 {
1085 1169
 	$format=strtolower($format);
1086
-	if(!isset($this->PageFormats[$format]))
1087
-		$this->Error('Unknown page format: '.$format);
1170
+	if(!isset($this->PageFormats[$format])) {
1171
+			$this->Error('Unknown page format: '.$format);
1172
+	}
1088 1173
 	$a=$this->PageFormats[$format];
1089 1174
 	return array($a[0]/$this->k, $a[1]/$this->k);
1090 1175
 }
1091 1176
 
1092 1177
 function _getfontpath()
1093 1178
 {
1094
-	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font'))
1095
-		define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1179
+	if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) {
1180
+			define('FPDF_FONTPATH',dirname(__FILE__).'/font/');
1181
+	}
1096 1182
 	return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
1097 1183
 }
1098 1184
 
@@ -1105,16 +1191,18 @@  discard block
 block discarded – undo
1105 1191
 	$this->y=$this->tMargin;
1106 1192
 	$this->FontFamily='';
1107 1193
 	//Check page size
1108
-	if($orientation=='')
1109
-		$orientation=$this->DefOrientation;
1110
-	else
1111
-		$orientation=strtoupper($orientation[0]);
1112
-	if($format=='')
1113
-		$format=$this->DefPageFormat;
1114
-	else
1194
+	if($orientation=='') {
1195
+			$orientation=$this->DefOrientation;
1196
+	} else {
1197
+			$orientation=strtoupper($orientation[0]);
1198
+	}
1199
+	if($format=='') {
1200
+			$format=$this->DefPageFormat;
1201
+	} else
1115 1202
 	{
1116
-		if(is_string($format))
1117
-			$format=$this->_getpageformat($format);
1203
+		if(is_string($format)) {
1204
+					$format=$this->_getpageformat($format);
1205
+		}
1118 1206
 	}
1119 1207
 	if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1])
1120 1208
 	{
@@ -1123,8 +1211,7 @@  discard block
 block discarded – undo
1123 1211
 		{
1124 1212
 			$this->w=$format[0];
1125 1213
 			$this->h=$format[1];
1126
-		}
1127
-		else
1214
+		} else
1128 1215
 		{
1129 1216
 			$this->w=$format[1];
1130 1217
 			$this->h=$format[0];
@@ -1135,9 +1222,10 @@  discard block
 block discarded – undo
1135 1222
 		$this->CurOrientation=$orientation;
1136 1223
 		$this->CurPageFormat=$format;
1137 1224
 	}
1138
-	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1])
1139
-		$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1140
-}
1225
+	if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) {
1226
+			$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
1227
+	}
1228
+	}
1141 1229
 
1142 1230
 function _endpage()
1143 1231
 {
@@ -1176,15 +1264,13 @@  discard block
 block discarded – undo
1176 1264
 			$c3=ord($s[$i++]);
1177 1265
 			$res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1178 1266
 			$res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1179
-		}
1180
-		elseif($c1>=192)
1267
+		} elseif($c1>=192)
1181 1268
 		{
1182 1269
 			//2-byte character
1183 1270
 			$c2=ord($s[$i++]);
1184 1271
 			$res.=chr(($c1 & 0x1C)>>2);
1185 1272
 			$res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1186
-		}
1187
-		else
1273
+		} else
1188 1274
 		{
1189 1275
 			//Single-byte character
1190 1276
 			$res.="\0".chr($c1);
@@ -1206,22 +1292,26 @@  discard block
 block discarded – undo
1206 1292
 {
1207 1293
 	//Extract info from a JPEG file
1208 1294
 	$a=GetImageSize($file);
1209
-	if(!$a)
1210
-		$this->Error('Missing or incorrect image file: '.$file);
1211
-	if($a[2]!=2)
1212
-		$this->Error('Not a JPEG file: '.$file);
1213
-	if(!isset($a['channels']) || $a['channels']==3)
1214
-		$colspace='DeviceRGB';
1215
-	elseif($a['channels']==4)
1216
-		$colspace='DeviceCMYK';
1217
-	else
1218
-		$colspace='DeviceGray';
1295
+	if(!$a) {
1296
+			$this->Error('Missing or incorrect image file: '.$file);
1297
+	}
1298
+	if($a[2]!=2) {
1299
+			$this->Error('Not a JPEG file: '.$file);
1300
+	}
1301
+	if(!isset($a['channels']) || $a['channels']==3) {
1302
+			$colspace='DeviceRGB';
1303
+	} elseif($a['channels']==4) {
1304
+			$colspace='DeviceCMYK';
1305
+	} else {
1306
+			$colspace='DeviceGray';
1307
+	}
1219 1308
 	$bpc=isset($a['bits']) ? $a['bits'] : 8;
1220 1309
 	//Read whole file
1221 1310
 	$f=fopen($file,'rb');
1222 1311
 	$data='';
1223
-	while(!feof($f))
1224
-		$data.=fread($f,8192);
1312
+	while(!feof($f)) {
1313
+			$data.=fread($f,8192);
1314
+	}
1225 1315
 	fclose($f);
1226 1316
 	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
1227 1317
 }
@@ -1230,35 +1320,43 @@  discard block
 block discarded – undo
1230 1320
 {
1231 1321
 	//Extract info from a PNG file
1232 1322
 	$f=fopen($file,'rb');
1233
-	if(!$f)
1234
-		$this->Error('Can\'t open image file: '.$file);
1323
+	if(!$f) {
1324
+			$this->Error('Can\'t open image file: '.$file);
1325
+	}
1235 1326
 	//Check signature
1236
-	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1237
-		$this->Error('Not a PNG file: '.$file);
1327
+	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
1328
+			$this->Error('Not a PNG file: '.$file);
1329
+	}
1238 1330
 	//Read header chunk
1239 1331
 	$this->_readstream($f,4);
1240
-	if($this->_readstream($f,4)!='IHDR')
1241
-		$this->Error('Incorrect PNG file: '.$file);
1332
+	if($this->_readstream($f,4)!='IHDR') {
1333
+			$this->Error('Incorrect PNG file: '.$file);
1334
+	}
1242 1335
 	$w=$this->_readint($f);
1243 1336
 	$h=$this->_readint($f);
1244 1337
 	$bpc=ord($this->_readstream($f,1));
1245
-	if($bpc>8)
1246
-		$this->Error('16-bit depth not supported: '.$file);
1338
+	if($bpc>8) {
1339
+			$this->Error('16-bit depth not supported: '.$file);
1340
+	}
1247 1341
 	$ct=ord($this->_readstream($f,1));
1248
-	if($ct==0)
1249
-		$colspace='DeviceGray';
1250
-	elseif($ct==2)
1251
-		$colspace='DeviceRGB';
1252
-	elseif($ct==3)
1253
-		$colspace='Indexed';
1254
-	else
1255
-		$this->Error('Alpha channel not supported: '.$file);
1256
-	if(ord($this->_readstream($f,1))!=0)
1257
-		$this->Error('Unknown compression method: '.$file);
1258
-	if(ord($this->_readstream($f,1))!=0)
1259
-		$this->Error('Unknown filter method: '.$file);
1260
-	if(ord($this->_readstream($f,1))!=0)
1261
-		$this->Error('Interlacing not supported: '.$file);
1342
+	if($ct==0) {
1343
+			$colspace='DeviceGray';
1344
+	} elseif($ct==2) {
1345
+			$colspace='DeviceRGB';
1346
+	} elseif($ct==3) {
1347
+			$colspace='Indexed';
1348
+	} else {
1349
+			$this->Error('Alpha channel not supported: '.$file);
1350
+	}
1351
+	if(ord($this->_readstream($f,1))!=0) {
1352
+			$this->Error('Unknown compression method: '.$file);
1353
+	}
1354
+	if(ord($this->_readstream($f,1))!=0) {
1355
+			$this->Error('Unknown filter method: '.$file);
1356
+	}
1357
+	if(ord($this->_readstream($f,1))!=0) {
1358
+			$this->Error('Interlacing not supported: '.$file);
1359
+	}
1262 1360
 	$this->_readstream($f,4);
1263 1361
 	$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
1264 1362
 	//Scan chunks looking for palette, transparency and image data
@@ -1274,37 +1372,37 @@  discard block
 block discarded – undo
1274 1372
 			//Read palette
1275 1373
 			$pal=$this->_readstream($f,$n);
1276 1374
 			$this->_readstream($f,4);
1277
-		}
1278
-		elseif($type=='tRNS')
1375
+		} elseif($type=='tRNS')
1279 1376
 		{
1280 1377
 			//Read transparency info
1281 1378
 			$t=$this->_readstream($f,$n);
1282
-			if($ct==0)
1283
-				$trns=array(ord(substr($t,1,1)));
1284
-			elseif($ct==2)
1285
-				$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1286
-			else
1379
+			if($ct==0) {
1380
+							$trns=array(ord(substr($t,1,1)));
1381
+			} elseif($ct==2) {
1382
+							$trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
1383
+			} else
1287 1384
 			{
1288 1385
 				$pos=strpos($t,chr(0));
1289
-				if($pos!==false)
1290
-					$trns=array($pos);
1386
+				if($pos!==false) {
1387
+									$trns=array($pos);
1388
+				}
1291 1389
 			}
1292 1390
 			$this->_readstream($f,4);
1293
-		}
1294
-		elseif($type=='IDAT')
1391
+		} elseif($type=='IDAT')
1295 1392
 		{
1296 1393
 			//Read image data block
1297 1394
 			$data.=$this->_readstream($f,$n);
1298 1395
 			$this->_readstream($f,4);
1396
+		} elseif($type=='IEND') {
1397
+					break;
1398
+		} else {
1399
+					$this->_readstream($f,$n+4);
1299 1400
 		}
1300
-		elseif($type=='IEND')
1301
-			break;
1302
-		else
1303
-			$this->_readstream($f,$n+4);
1304 1401
 	}
1305 1402
 	while($n);
1306
-	if($colspace=='Indexed' && empty($pal))
1307
-		$this->Error('Missing palette in '.$file);
1403
+	if($colspace=='Indexed' && empty($pal)) {
1404
+			$this->Error('Missing palette in '.$file);
1405
+	}
1308 1406
 	fclose($f);
1309 1407
 	return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data);
1310 1408
 }
@@ -1316,13 +1414,15 @@  discard block
 block discarded – undo
1316 1414
 	while($n>0 && !feof($f))
1317 1415
 	{
1318 1416
 		$s=fread($f,$n);
1319
-		if($s===false)
1320
-			$this->Error('Error while reading stream');
1417
+		if($s===false) {
1418
+					$this->Error('Error while reading stream');
1419
+		}
1321 1420
 		$n-=strlen($s);
1322 1421
 		$res.=$s;
1323 1422
 	}
1324
-	if($n>0)
1325
-		$this->Error('Unexpected end of stream');
1423
+	if($n>0) {
1424
+			$this->Error('Unexpected end of stream');
1425
+	}
1326 1426
 	return $res;
1327 1427
 }
1328 1428
 
@@ -1336,19 +1436,24 @@  discard block
 block discarded – undo
1336 1436
 function _parsegif($file)
1337 1437
 {
1338 1438
 	//Extract info from a GIF file (via PNG conversion)
1339
-	if(!function_exists('imagepng'))
1340
-		$this->Error('GD extension is required for GIF support');
1341
-	if(!function_exists('imagecreatefromgif'))
1342
-		$this->Error('GD has no GIF read support');
1439
+	if(!function_exists('imagepng')) {
1440
+			$this->Error('GD extension is required for GIF support');
1441
+	}
1442
+	if(!function_exists('imagecreatefromgif')) {
1443
+			$this->Error('GD has no GIF read support');
1444
+	}
1343 1445
 	$im=imagecreatefromgif($file);
1344
-	if(!$im)
1345
-		$this->Error('Missing or incorrect image file: '.$file);
1446
+	if(!$im) {
1447
+			$this->Error('Missing or incorrect image file: '.$file);
1448
+	}
1346 1449
 	imageinterlace($im,0);
1347 1450
 	$tmp=tempnam('.','gif');
1348
-	if(!$tmp)
1349
-		$this->Error('Unable to create a temporary file');
1350
-	if(!imagepng($im,$tmp))
1351
-		$this->Error('Error while saving to temporary file');
1451
+	if(!$tmp) {
1452
+			$this->Error('Unable to create a temporary file');
1453
+	}
1454
+	if(!imagepng($im,$tmp)) {
1455
+			$this->Error('Error while saving to temporary file');
1456
+	}
1352 1457
 	imagedestroy($im);
1353 1458
 	$info=$this->_parsepng($tmp);
1354 1459
 	unlink($tmp);
@@ -1373,11 +1478,12 @@  discard block
 block discarded – undo
1373 1478
 function _out($s)
1374 1479
 {
1375 1480
 	//Add a line to the document
1376
-	if($this->state==2)
1377
-		$this->pages[$this->page].=$s."\n";
1378
-	else
1379
-		$this->buffer.=$s."\n";
1380
-}
1481
+	if($this->state==2) {
1482
+			$this->pages[$this->page].=$s."\n";
1483
+	} else {
1484
+			$this->buffer.=$s."\n";
1485
+	}
1486
+	}
1381 1487
 
1382 1488
 function _putpages()
1383 1489
 {
@@ -1385,15 +1491,15 @@  discard block
 block discarded – undo
1385 1491
 	if(!empty($this->AliasNbPages))
1386 1492
 	{
1387 1493
 		//Replace number of pages
1388
-		for($n=1;$n<=$nb;$n++)
1389
-			$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1494
+		for($n=1;$n<=$nb;$n++) {
1495
+					$this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]);
1496
+		}
1390 1497
 	}
1391 1498
 	if($this->DefOrientation=='P')
1392 1499
 	{
1393 1500
 		$wPt=$this->DefPageFormat[0]*$this->k;
1394 1501
 		$hPt=$this->DefPageFormat[1]*$this->k;
1395
-	}
1396
-	else
1502
+	} else
1397 1503
 	{
1398 1504
 		$wPt=$this->DefPageFormat[1]*$this->k;
1399 1505
 		$hPt=$this->DefPageFormat[0]*$this->k;
@@ -1405,8 +1511,9 @@  discard block
 block discarded – undo
1405 1511
 		$this->_newobj();
1406 1512
 		$this->_out('<</Type /Page');
1407 1513
 		$this->_out('/Parent 1 0 R');
1408
-		if(isset($this->PageSizes[$n]))
1409
-			$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1514
+		if(isset($this->PageSizes[$n])) {
1515
+					$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1]));
1516
+		}
1410 1517
 		$this->_out('/Resources 2 0 R');
1411 1518
 		if(isset($this->PageLinks[$n]))
1412 1519
 		{
@@ -1416,9 +1523,9 @@  discard block
 block discarded – undo
1416 1523
 			{
1417 1524
 				$rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1418 1525
 				$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1419
-				if(is_string($pl[4]))
1420
-					$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1421
-				else
1526
+				if(is_string($pl[4])) {
1527
+									$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1528
+				} else
1422 1529
 				{
1423 1530
 					$l=$this->links[$pl[4]];
1424 1531
 					$h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt;
@@ -1441,8 +1548,9 @@  discard block
 block discarded – undo
1441 1548
 	$this->_out('1 0 obj');
1442 1549
 	$this->_out('<</Type /Pages');
1443 1550
 	$kids='/Kids [';
1444
-	for($i=0;$i<$nb;$i++)
1445
-		$kids.=(3+2*$i).' 0 R ';
1551
+	for($i=0;$i<$nb;$i++) {
1552
+			$kids.=(3+2*$i).' 0 R ';
1553
+	}
1446 1554
 	$this->_out($kids.']');
1447 1555
 	$this->_out('/Count '.$nb);
1448 1556
 	$this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt));
@@ -1467,10 +1575,12 @@  discard block
 block discarded – undo
1467 1575
 		$this->FontFiles[$file]['n']=$this->n;
1468 1576
 		$font='';
1469 1577
 		$f=fopen($this->_getfontpath().$file,'rb',1);
1470
-		if(!$f)
1471
-			$this->Error('Font file not found');
1472
-		while(!feof($f))
1473
-			$font.=fread($f,8192);
1578
+		if(!$f) {
1579
+					$this->Error('Font file not found');
1580
+		}
1581
+		while(!feof($f)) {
1582
+					$font.=fread($f,8192);
1583
+		}
1474 1584
 		fclose($f);
1475 1585
 		$compressed=(substr($file,-2)=='.z');
1476 1586
 		if(!$compressed && isset($info['length2']))
@@ -1488,11 +1598,13 @@  discard block
 block discarded – undo
1488 1598
 			}
1489 1599
 		}
1490 1600
 		$this->_out('<</Length '.strlen($font));
1491
-		if($compressed)
1492
-			$this->_out('/Filter /FlateDecode');
1601
+		if($compressed) {
1602
+					$this->_out('/Filter /FlateDecode');
1603
+		}
1493 1604
 		$this->_out('/Length1 '.$info['length1']);
1494
-		if(isset($info['length2']))
1495
-			$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1605
+		if(isset($info['length2'])) {
1606
+					$this->_out('/Length2 '.$info['length2'].' /Length3 0');
1607
+		}
1496 1608
 		$this->_out('>>');
1497 1609
 		$this->_putstream($font);
1498 1610
 		$this->_out('endobj');
@@ -1510,12 +1622,12 @@  discard block
 block discarded – undo
1510 1622
 			$this->_out('<</Type /Font');
1511 1623
 			$this->_out('/BaseFont /'.$name);
1512 1624
 			$this->_out('/Subtype /Type1');
1513
-			if($name!='Symbol' && $name!='ZapfDingbats')
1514
-				$this->_out('/Encoding /WinAnsiEncoding');
1625
+			if($name!='Symbol' && $name!='ZapfDingbats') {
1626
+							$this->_out('/Encoding /WinAnsiEncoding');
1627
+			}
1515 1628
 			$this->_out('>>');
1516 1629
 			$this->_out('endobj');
1517
-		}
1518
-		elseif($type=='Type1' || $type=='TrueType')
1630
+		} elseif($type=='Type1' || $type=='TrueType')
1519 1631
 		{
1520 1632
 			//Additional Type1 or TrueType font
1521 1633
 			$this->_newobj();
@@ -1527,10 +1639,11 @@  discard block
 block discarded – undo
1527 1639
 			$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
1528 1640
 			if($font['enc'])
1529 1641
 			{
1530
-				if(isset($font['diff']))
1531
-					$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1532
-				else
1533
-					$this->_out('/Encoding /WinAnsiEncoding');
1642
+				if(isset($font['diff'])) {
1643
+									$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
1644
+				} else {
1645
+									$this->_out('/Encoding /WinAnsiEncoding');
1646
+				}
1534 1647
 			}
1535 1648
 			$this->_out('>>');
1536 1649
 			$this->_out('endobj');
@@ -1538,27 +1651,30 @@  discard block
 block discarded – undo
1538 1651
 			$this->_newobj();
1539 1652
 			$cw=&$font['cw'];
1540 1653
 			$s='[';
1541
-			for($i=32;$i<=255;$i++)
1542
-				$s.=$cw[chr($i)].' ';
1654
+			for($i=32;$i<=255;$i++) {
1655
+							$s.=$cw[chr($i)].' ';
1656
+			}
1543 1657
 			$this->_out($s.']');
1544 1658
 			$this->_out('endobj');
1545 1659
 			//Descriptor
1546 1660
 			$this->_newobj();
1547 1661
 			$s='<</Type /FontDescriptor /FontName /'.$name;
1548
-			foreach($font['desc'] as $k=>$v)
1549
-				$s.=' /'.$k.' '.$v;
1662
+			foreach($font['desc'] as $k=>$v) {
1663
+							$s.=' /'.$k.' '.$v;
1664
+			}
1550 1665
 			$file=$font['file'];
1551
-			if($file)
1552
-				$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1666
+			if($file) {
1667
+							$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
1668
+			}
1553 1669
 			$this->_out($s.'>>');
1554 1670
 			$this->_out('endobj');
1555
-		}
1556
-		else
1671
+		} else
1557 1672
 		{
1558 1673
 			//Allow for additional types
1559 1674
 			$mtd='_put'.strtolower($type);
1560
-			if(!method_exists($this,$mtd))
1561
-				$this->Error('Unsupported font type: '.$type);
1675
+			if(!method_exists($this,$mtd)) {
1676
+							$this->Error('Unsupported font type: '.$type);
1677
+			}
1562 1678
 			$this->$mtd($font);
1563 1679
 		}
1564 1680
 	}
@@ -1576,24 +1692,28 @@  discard block
 block discarded – undo
1576 1692
 		$this->_out('/Subtype /Image');
1577 1693
 		$this->_out('/Width '.$info['w']);
1578 1694
 		$this->_out('/Height '.$info['h']);
1579
-		if($info['cs']=='Indexed')
1580
-			$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1581
-		else
1695
+		if($info['cs']=='Indexed') {
1696
+					$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
1697
+		} else
1582 1698
 		{
1583 1699
 			$this->_out('/ColorSpace /'.$info['cs']);
1584
-			if($info['cs']=='DeviceCMYK')
1585
-				$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1700
+			if($info['cs']=='DeviceCMYK') {
1701
+							$this->_out('/Decode [1 0 1 0 1 0 1 0]');
1702
+			}
1586 1703
 		}
1587 1704
 		$this->_out('/BitsPerComponent '.$info['bpc']);
1588
-		if(isset($info['f']))
1589
-			$this->_out('/Filter /'.$info['f']);
1590
-		if(isset($info['parms']))
1591
-			$this->_out($info['parms']);
1705
+		if(isset($info['f'])) {
1706
+					$this->_out('/Filter /'.$info['f']);
1707
+		}
1708
+		if(isset($info['parms'])) {
1709
+					$this->_out($info['parms']);
1710
+		}
1592 1711
 		if(isset($info['trns']) && is_array($info['trns']))
1593 1712
 		{
1594 1713
 			$trns='';
1595
-			for($i=0;$i<count($info['trns']);$i++)
1596
-				$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1714
+			for($i=0;$i<count($info['trns']);$i++) {
1715
+							$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
1716
+			}
1597 1717
 			$this->_out('/Mask ['.$trns.']');
1598 1718
 		}
1599 1719
 		$this->_out('/Length '.strlen($info['data']).'>>');
@@ -1614,16 +1734,18 @@  discard block
 block discarded – undo
1614 1734
 
1615 1735
 function _putxobjectdict()
1616 1736
 {
1617
-	foreach($this->images as $image)
1618
-		$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1619
-}
1737
+	foreach($this->images as $image) {
1738
+			$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
1739
+	}
1740
+	}
1620 1741
 
1621 1742
 function _putresourcedict()
1622 1743
 {
1623 1744
 	$this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
1624 1745
 	$this->_out('/Font <<');
1625
-	foreach($this->fonts as $font)
1626
-		$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1746
+	foreach($this->fonts as $font) {
1747
+			$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
1748
+	}
1627 1749
 	$this->_out('>>');
1628 1750
 	$this->_out('/XObject <<');
1629 1751
 	$this->_putxobjectdict();
@@ -1646,16 +1768,21 @@  discard block
 block discarded – undo
1646 1768
 function _putinfo()
1647 1769
 {
1648 1770
 	$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
1649
-	if(!empty($this->title))
1650
-		$this->_out('/Title '.$this->_textstring($this->title));
1651
-	if(!empty($this->subject))
1652
-		$this->_out('/Subject '.$this->_textstring($this->subject));
1653
-	if(!empty($this->author))
1654
-		$this->_out('/Author '.$this->_textstring($this->author));
1655
-	if(!empty($this->keywords))
1656
-		$this->_out('/Keywords '.$this->_textstring($this->keywords));
1657
-	if(!empty($this->creator))
1658
-		$this->_out('/Creator '.$this->_textstring($this->creator));
1771
+	if(!empty($this->title)) {
1772
+			$this->_out('/Title '.$this->_textstring($this->title));
1773
+	}
1774
+	if(!empty($this->subject)) {
1775
+			$this->_out('/Subject '.$this->_textstring($this->subject));
1776
+	}
1777
+	if(!empty($this->author)) {
1778
+			$this->_out('/Author '.$this->_textstring($this->author));
1779
+	}
1780
+	if(!empty($this->keywords)) {
1781
+			$this->_out('/Keywords '.$this->_textstring($this->keywords));
1782
+	}
1783
+	if(!empty($this->creator)) {
1784
+			$this->_out('/Creator '.$this->_textstring($this->creator));
1785
+	}
1659 1786
 	$this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis')));
1660 1787
 }
1661 1788
 
@@ -1663,21 +1790,23 @@  discard block
 block discarded – undo
1663 1790
 {
1664 1791
 	$this->_out('/Type /Catalog');
1665 1792
 	$this->_out('/Pages 1 0 R');
1666
-	if($this->ZoomMode=='fullpage')
1667
-		$this->_out('/OpenAction [3 0 R /Fit]');
1668
-	elseif($this->ZoomMode=='fullwidth')
1669
-		$this->_out('/OpenAction [3 0 R /FitH null]');
1670
-	elseif($this->ZoomMode=='real')
1671
-		$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1672
-	elseif(!is_string($this->ZoomMode))
1673
-		$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1674
-	if($this->LayoutMode=='single')
1675
-		$this->_out('/PageLayout /SinglePage');
1676
-	elseif($this->LayoutMode=='continuous')
1677
-		$this->_out('/PageLayout /OneColumn');
1678
-	elseif($this->LayoutMode=='two')
1679
-		$this->_out('/PageLayout /TwoColumnLeft');
1680
-}
1793
+	if($this->ZoomMode=='fullpage') {
1794
+			$this->_out('/OpenAction [3 0 R /Fit]');
1795
+	} elseif($this->ZoomMode=='fullwidth') {
1796
+			$this->_out('/OpenAction [3 0 R /FitH null]');
1797
+	} elseif($this->ZoomMode=='real') {
1798
+			$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
1799
+	} elseif(!is_string($this->ZoomMode)) {
1800
+			$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
1801
+	}
1802
+	if($this->LayoutMode=='single') {
1803
+			$this->_out('/PageLayout /SinglePage');
1804
+	} elseif($this->LayoutMode=='continuous') {
1805
+			$this->_out('/PageLayout /OneColumn');
1806
+	} elseif($this->LayoutMode=='two') {
1807
+			$this->_out('/PageLayout /TwoColumnLeft');
1808
+	}
1809
+	}
1681 1810
 
1682 1811
 function _putheader()
1683 1812
 {
@@ -1713,8 +1842,9 @@  discard block
 block discarded – undo
1713 1842
 	$this->_out('xref');
1714 1843
 	$this->_out('0 '.($this->n+1));
1715 1844
 	$this->_out('0000000000 65535 f ');
1716
-	for($i=1;$i<=$this->n;$i++)
1717
-		$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1845
+	for($i=1;$i<=$this->n;$i++) {
1846
+			$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
1847
+	}
1718 1848
 	//Trailer
1719 1849
 	$this->_out('trailer');
1720 1850
 	$this->_out('<<');
Please login to merge, or discard this patch.
includes/librairies/pdf/fpdf_extends.class.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -57,6 +57,10 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 
59 59
 	// Cr�ation r�cursive de dossiers
60
+
61
+	/**
62
+	 * @param string $path
63
+	 */
60 64
 	function make_recursiv_dir($path, $rights = 0777) {
61 65
 		if (!@is_dir($path)) {
62 66
 			$folder_path = array($path);
@@ -313,6 +317,11 @@  discard block
 block discarded – undo
313 317
 	}
314 318
 
315 319
 	// Affiche un ligne de la facture
320
+
321
+	/**
322
+	 * @param integer[] $dim_array
323
+	 * @param string $currency
324
+	 */
316 325
 	function row($row, $dim_array, $currency) {
317 326
 
318 327
 		// S�curit�
@@ -336,6 +345,9 @@  discard block
 block discarded – undo
336 345
 		$this->Ln();
337 346
 	}
338 347
 
348
+	/**
349
+	 * @param string $currency
350
+	 */
339 351
 	function total($order_id, $currency, $invoice_id = null) {
340 352
 
341 353
 		/* Donn�es commande */
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 DEFINE('EUR', chr(128)); // Sigle �
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	function WordWrap(&$text, $maxwidth) {
23 23
 		$text = trim($text);
24
-		if ($text==='')
24
+		if ($text === '')
25 25
 			return 0;
26 26
 		$space = $this->GetStringWidth(' ');
27 27
 		$lines = explode("\n", $text);
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 				if ($width + $wordwidth <= $maxwidth)
40 40
 				{
41 41
 					$width += $wordwidth + $space;
42
-					$text .= $word.' ';
42
+					$text .= $word . ' ';
43 43
 				}
44 44
 				else
45 45
 				{
46 46
 					$width = $wordwidth + $space;
47
-					$text = rtrim($text)."\n".$word.' ';
47
+					$text = rtrim($text) . "\n" . $word . ' ';
48 48
 					$count++;
49 49
 				}
50 50
 			}
51
-			$text = rtrim($text)."\n";
51
+			$text = rtrim($text) . "\n";
52 52
 			$count++;
53 53
 		}
54 54
 		$text = rtrim($text);
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
 			return;
66 66
 		}
67 67
 
68
-		while(!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
68
+		while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') {
69 69
 			array_push($folder_path, dirname(end($folder_path)));
70 70
 		}
71 71
 
72
-		while($parent_folder_path = array_pop($folder_path)) {
73
-			if(!@mkdir($parent_folder_path, $rights)) {
72
+		while ($parent_folder_path = array_pop($folder_path)) {
73
+			if (!@mkdir($parent_folder_path, $rights)) {
74 74
 				user_error("Can't create folder \"$parent_folder_path\".\n");
75 75
 			}
76 76
 		}
77 77
 	}
78 78
 
79
-	function invoice_export( $order_id, $invoice_id = null ) {
79
+	function invoice_export($order_id, $invoice_id = null) {
80 80
 
81 81
 		$current_user_id = get_current_user_id();
82 82
 		$order = get_post_meta($order_id, '_order_postmeta', true);
83 83
 
84
-		if($order['customer_id']==$current_user_id OR is_admin()) {
84
+		if ($order['customer_id'] == $current_user_id OR is_admin()) {
85 85
 
86 86
 			if (in_array($order['order_status'], array('completed', 'shipped', 'partially_paid'))) {
87 87
 				$invoice_dir = WP_CONTENT_DIR . "/uploads/wpshop_invoices/";
88 88
 				$filename = $this->get_invoice_filename($order_id);
89
-				$invoice_url = $invoice_dir.$filename;
89
+				$invoice_url = $invoice_dir . $filename;
90 90
 
91 91
 				// If the invoice has not been already generated
92 92
 // 				if ( !file_exists($invoice_url) ) {
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 
95 95
 					// Currency management
96 96
 					$currency = $order['order_currency'];
97
-					if($currency == 'EUR')$currency = EUR;
98
-					else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
97
+					if ($currency == 'EUR')$currency = EUR;
98
+					else $currency = html_entity_decode(wpshop_tools::wpshop_get_sigle($currency));
99 99
 
100 100
 					// On d�finit un alias pour le nombre de pages total
101 101
 					$this->AliasNbPages();
102 102
 					// On ajoute une page au document
103 103
 					$this->AddPage();
104 104
 					// On lui applique une police
105
-					$this->SetFont('Arial','',10);
105
+					$this->SetFont('Arial', '', 10);
106 106
 					// Coordonn�es magasin
107 107
 					$this->store_head($order_id);
108 108
 					// Coordonn�es client
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 					$path = $invoice_url;
126 126
 					$this->Output($path, "F");
127 127
 					// On force le t�l�chargement de la facture
128
-					$Fichier_a_telecharger = $refdate.".pdf";
128
+					$Fichier_a_telecharger = $refdate . ".pdf";
129 129
 					$this->forceDownload($Fichier_a_telecharger, $path, filesize($path));
130 130
 // 				}
131 131
 // 				else $this->forceDownload($filename, $invoice_url, filesize($invoice_url));
132 132
 			}
133
-			else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
133
+			else echo __('The payment regarding the invoice you requested isn\'t completed', 'wpshop');
134 134
 		}
135
-		else echo __('You don\'t have the rights to access this invoice.','wpshop');
135
+		else echo __('You don\'t have the rights to access this invoice.', 'wpshop');
136 136
 	}
137 137
 
138 138
 	/** Force le t�l�chargement d'un fichier */
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		$emails = get_option('wpshop_emails', array());
158 158
 
159 159
 		//Positionnement
160
-		$this->SetY(55);$this->SetX(12);
160
+		$this->SetY(55); $this->SetX(12);
161 161
 		// Cadre client destinataire
162 162
 		$this->rect(10, 52, 80, 40);
163 163
 
164 164
 		$xsize = 80;
165 165
 
166
-		if(!empty($company) && !empty($emails)) {
166
+		if (!empty($company) && !empty($emails)) {
167 167
 			// Infos
168 168
 			$store_name = utf8_decode(utf8_encode($company['company_name']));
169 169
 			$store_email = !empty($emails['contact_email']) ? $emails['contact_email'] : null;
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 			$store_country = utf8_decode(utf8_encode($company['company_country']));
177 177
 
178 178
 			// Gras pour le titre
179
-			$this->SetFont('','B',10);
180
-			$this->Cell($xsize,5,$store_name,0,1,'L'); $this->SetX(12);
179
+			$this->SetFont('', 'B', 10);
180
+			$this->Cell($xsize, 5, $store_name, 0, 1, 'L'); $this->SetX(12);
181 181
 			// Police normale pour le reste
182
-			$this->SetFont('','',9);
183
-			$this->Cell($xsize,4,$store_street_adress,0,1,'L'); $this->SetX(12);
184
-			if (!empty($store_suburb)){$this->Cell(80,4,$store_suburb,0,1,'L');} $this->SetX(12);
185
-			$this->Cell($xsize,4,$store_postcode . ' ' . $store_city,0,1,'L'); $this->SetX(12);
182
+			$this->SetFont('', '', 9);
183
+			$this->Cell($xsize, 4, $store_street_adress, 0, 1, 'L'); $this->SetX(12);
184
+			if (!empty($store_suburb)) {$this->Cell(80, 4, $store_suburb, 0, 1, 'L'); } $this->SetX(12);
185
+			$this->Cell($xsize, 4, $store_postcode . ' ' . $store_city, 0, 1, 'L'); $this->SetX(12);
186 186
 			//if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12);
187
-			$this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12);
188
-			$this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12);
187
+			$this->Cell($xsize, 4, $store_country, 0, 1, 'L'); $this->SetX(12);
188
+			$this->Cell($xsize, 4, $store_email, 0, 1, 'L'); $this->SetX(12);
189 189
 		}
190 190
 		else {
191
-			$this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L');
191
+			$this->Cell($xsize, 5, _('Nc', 'wpshop'), 0, 1, 'L');
192 192
 		}
193 193
 	}
194 194
 
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		$customer_data = $customer_data['billing']['address'];
199 199
 
200 200
 		// FPDF ne d�codant pas l'UTF-8, on le fait via PHP
201
-		$customer_firstname = ( !empty($customer_data['address_first_name']) ) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null;
202
-		$customer_lastname = ( !empty($customer_data['address_last_name']) ) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null;
203
-		$customer_company = ( !empty($customer_data['company']) ) ? utf8_decode(utf8_encode($customer_data['company'])) : null;
204
-		$customer_street_adress = ( !empty($customer_data['address']) ) ? utf8_decode(utf8_encode($customer_data['address'])) : null;
205
-		$customer_city = ( !empty($customer_data['city']) ) ? utf8_decode(utf8_encode($customer_data['city'])) : null;
206
-		$customer_postcode = ( !empty($customer_data['postcode']) ) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null;
207
-		$customer_state = ( !empty($customer_data['state']) ) ? utf8_decode(utf8_encode($customer_data['state'])) : null;
208
-		$customer_country = ( !empty($customer_data['country']) ) ? utf8_decode(utf8_encode($customer_data['country'])) : null;
201
+		$customer_firstname = (!empty($customer_data['address_first_name'])) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null;
202
+		$customer_lastname = (!empty($customer_data['address_last_name'])) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null;
203
+		$customer_company = (!empty($customer_data['company'])) ? utf8_decode(utf8_encode($customer_data['company'])) : null;
204
+		$customer_street_adress = (!empty($customer_data['address'])) ? utf8_decode(utf8_encode($customer_data['address'])) : null;
205
+		$customer_city = (!empty($customer_data['city'])) ? utf8_decode(utf8_encode($customer_data['city'])) : null;
206
+		$customer_postcode = (!empty($customer_data['postcode'])) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null;
207
+		$customer_state = (!empty($customer_data['state'])) ? utf8_decode(utf8_encode($customer_data['state'])) : null;
208
+		$customer_country = (!empty($customer_data['country'])) ? utf8_decode(utf8_encode($customer_data['country'])) : null;
209 209
 
210
-		$customer_tva_intra = ( !empty($customer_data['company_tva_intra']) ) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null;
210
+		$customer_tva_intra = (!empty($customer_data['company_tva_intra'])) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null;
211 211
 
212 212
 		$xsize = 80;
213 213
 
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 		// Et on �cris
220 220
 		// On r�gle la police d'�criture
221 221
 		// gras pour le titre
222
-		$this->SetFont('','B',10);
223
-		$this->Cell($xsize,5,$customer_lastname.' '.$customer_firstname.(!empty($customer_company)?', '.$customer_company:null),0,1,'L'); $this->SetX(102);
222
+		$this->SetFont('', 'B', 10);
223
+		$this->Cell($xsize, 5, $customer_lastname . ' ' . $customer_firstname . (!empty($customer_company) ? ', ' . $customer_company : null), 0, 1, 'L'); $this->SetX(102);
224 224
 		// Police normale pour le reste
225
-		$this->SetFont('','',9);
226
-		$this->Cell($xsize,4,$customer_street_adress,0,1,'L'); $this->SetX(102);
227
-		if (!empty($customer_suburb)){$this->Cell($xsize,4,$customer_suburb,0,1,'L');} $this->SetX(102);
228
-		$this->Cell($xsize,4,$customer_postcode . ' ' . $customer_city,0,1,'L'); $this->SetX(102);
229
-		if ($customer_state != ''){$this->Cell($xsize,4,$customer_state,0,1,'L');} $this->SetX(102);
230
-		$this->Cell($xsize,4,$customer_country . ' ',0,1,'L'); $this->SetX(102);
231
-		if ($customer_tva_intra != ''){$this->Cell($xsize,4,__('TVA Intracommunautaire','wpshop').' : '.$customer_tva_intra,0,1,'L');}
225
+		$this->SetFont('', '', 9);
226
+		$this->Cell($xsize, 4, $customer_street_adress, 0, 1, 'L'); $this->SetX(102);
227
+		if (!empty($customer_suburb)) {$this->Cell($xsize, 4, $customer_suburb, 0, 1, 'L'); } $this->SetX(102);
228
+		$this->Cell($xsize, 4, $customer_postcode . ' ' . $customer_city, 0, 1, 'L'); $this->SetX(102);
229
+		if ($customer_state != '') {$this->Cell($xsize, 4, $customer_state, 0, 1, 'L'); } $this->SetX(102);
230
+		$this->Cell($xsize, 4, $customer_country . ' ', 0, 1, 'L'); $this->SetX(102);
231
+		if ($customer_tva_intra != '') {$this->Cell($xsize, 4, __('TVA Intracommunautaire', 'wpshop') . ' : ' . $customer_tva_intra, 0, 1, 'L'); }
232 232
 	}
233 233
 
234 234
 	// R�f�rence et date de facturation
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 		// On r�cup�re la r�f�rence
239 239
 		//$invoice_ref = 'FA'.date('ym').'-0001';
240 240
 		// On r�cup�re la date de facturation
241
-		$invoice_add_date = substr($order['order_date'],0,10);
241
+		$invoice_add_date = substr($order['order_date'], 0, 10);
242 242
 		// On r�cup�re la date d'�ch�ance
243 243
 		//$invoice_max_date = '';
244 244
 
245 245
 		// Positionnement
246
-		$this->SetY(25); $this->SetX(135); $this->SetFont('','B',14);
247
-		$this->Cell(50, 5, utf8_decode(__( 'Ref. : ', 'wpshop' )) . $invoice_ref,0,1,'L');
246
+		$this->SetY(25); $this->SetX(135); $this->SetFont('', 'B', 14);
247
+		$this->Cell(50, 5, utf8_decode(__('Ref. : ', 'wpshop')) . $invoice_ref, 0, 1, 'L');
248 248
 		// Positionnement
249
-		$this->SetX(135); $this->SetFont('','',9);
250
-		$this->Cell(50, 4, utf8_decode(__( 'Billing date : ', 'wpshop' )) . $invoice_add_date,0,1,'L');
249
+		$this->SetX(135); $this->SetFont('', '', 9);
250
+		$this->Cell(50, 4, utf8_decode(__('Billing date : ', 'wpshop')) . $invoice_add_date, 0, 1, 'L');
251 251
 
252
-		$this->SetX(135); $this->SetFont('','',9);
253
-		$this->Cell(50, 4, utf8_decode(__( 'Payment method : ', 'wpshop' )) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L');
252
+		$this->SetX(135); $this->SetFont('', '', 9);
253
+		$this->Cell(50, 4, utf8_decode(__('Payment method : ', 'wpshop')) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L');
254 254
 
255
-		$this->SetX(135); $this->SetFont('','',9);
256
-		$this->Cell(50, 4, utf8_decode(__( 'Transaction id : ', 'wpshop' )) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L');
255
+		$this->SetX(135); $this->SetFont('', '', 9);
256
+		$this->Cell(50, 4, utf8_decode(__('Transaction id : ', 'wpshop')) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L');
257 257
 
258 258
 		//$this->SetX(135);
259 259
 		//$this->Cell(50, 4, utf8_decode(__( 'Date d\'�ch�ance : ', 'wpshop' )) . $invoice_max_date,0,1,'L');
260 260
 
261
-		return $invoice_ref.'_'.$invoice_add_date;
261
+		return $invoice_ref . '_' . $invoice_add_date;
262 262
 	}
263 263
 
264 264
 	function get_invoice_filename($order_id) {
265 265
 		$order = get_post_meta($order_id, '_order_postmeta', true);
266
-		$invoice_add_date = substr($order['order_date'],0,10);
266
+		$invoice_add_date = substr($order['order_date'], 0, 10);
267 267
 		$order_invoice_ref = $order['order_invoice_ref'];
268
-		return $order_invoice_ref.'_'.$invoice_add_date.'.pdf';
268
+		return $order_invoice_ref . '_' . $invoice_add_date . '.pdf';
269 269
 	}
270 270
 
271 271
 	/**
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
 	 * @param integer $invoice_id Optionnal An invoice ID, this parameter could be used to call an invoice for a partial payment
276 276
 	 */
277 277
 	function rows($order_id, $currency, $invoice_id = null) {
278
-		$title_ref = utf8_decode(__( 'Reference', 'wpshop' ));
279
-		$title_name = utf8_decode(__( 'Designation', 'wpshop' ));
280
-		$title_qty = utf8_decode(__( 'Qty', 'wpshop' ));
281
-		$title_baseprice = utf8_decode(__( 'PU HT', 'wpshop' ));
282
-		$title_discount = utf8_decode(__( 'Discount', 'wpshop' ));
283
-		$title_tax = utf8_decode(__( 'TVA (Tax)', 'wpshop' ));
284
-		$title_price = utf8_decode(__( 'Total ET', 'wpshop' ));
278
+		$title_ref = utf8_decode(__('Reference', 'wpshop'));
279
+		$title_name = utf8_decode(__('Designation', 'wpshop'));
280
+		$title_qty = utf8_decode(__('Qty', 'wpshop'));
281
+		$title_baseprice = utf8_decode(__('PU HT', 'wpshop'));
282
+		$title_discount = utf8_decode(__('Discount', 'wpshop'));
283
+		$title_tax = utf8_decode(__('TVA (Tax)', 'wpshop'));
284
+		$title_price = utf8_decode(__('Total ET', 'wpshop'));
285 285
 
286 286
 		/**	Set title for invoice line table	*/
287 287
 		$header = array($title_ref, $title_name, $title_qty, $title_baseprice, $title_discount, $title_tax, $title_price);
@@ -289,23 +289,23 @@  discard block
 block discarded – undo
289 289
 		/**	Set column size	*/
290 290
 		$w = array(26, 75, 10, 15, 15, 30, 20);
291 291
 
292
-		$this->setXY(10,100);
293
-		for($i=0;$i<count($header);$i++) {
294
-			$this->Cell($w[$i],5,$header[$i],1,0,'C');
292
+		$this->setXY(10, 100);
293
+		for ($i = 0; $i < count($header); $i++) {
294
+			$this->Cell($w[$i], 5, $header[$i], 1, 0, 'C');
295 295
 		}
296 296
 		$this->Ln();
297 297
 
298 298
 		/**	Get the order content	*/
299 299
 		$order_data = get_post_meta($order_id, '_order_postmeta', true);
300
-		if ( in_array($order_data['order_status'], array('completed', 'shipped') ) ) {
300
+		if (in_array($order_data['order_status'], array('completed', 'shipped'))) {
301 301
 			/**	Foreach item in order: add a row to invoice	*/
302 302
 			foreach ($order_data['order_items'] as $o) {
303 303
 				$this->row($o, $w, $currency);
304 304
 			}
305 305
 		}
306
-		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
307
-			foreach ( $order_data['order_payment']['received'] as $payment_info ) {
308
-				if ( !is_array($payment_info) ) {
306
+		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received'])) {
307
+			foreach ($order_data['order_payment']['received'] as $payment_info) {
308
+				if (!is_array($payment_info)) {
309 309
 
310 310
 				}
311 311
 			}
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 		$total_ht = !empty($row['item_total_ht']) ? $row['item_total_ht'] : 'Nc';
327 327
 
328 328
 		// On affiche les valeurs
329
-		$this->Cell($dim_array[0],8,$product_reference,'LRB',0,'C');
330
-		$this->Cell($dim_array[1],8,$product_name,'LRB',0,'L');
331
-		$this->Cell($dim_array[2],8,$qty_invoiced,'LRB',0,'C');
332
-		$this->Cell($dim_array[3],8,number_format($item_pu_ht,2,'.',' ').' '.$currency,'LRB',0,'C');
333
-		$this->Cell($dim_array[4],8,number_format($discount_amount,2,'.',' ').' '.$currency,'LRB',0,'C');
334
-		$this->Cell($dim_array[5],8,number_format($item_tva_total_amount,2,'.',' ').' '.$currency.' (' . round($tax_rate, 2) . '%)','LRB',0,'C');
335
-		$this->Cell($dim_array[6],8,number_format($total_ht,2,'.',' ').' '.$currency,'LRB',0,'C');
329
+		$this->Cell($dim_array[0], 8, $product_reference, 'LRB', 0, 'C');
330
+		$this->Cell($dim_array[1], 8, $product_name, 'LRB', 0, 'L');
331
+		$this->Cell($dim_array[2], 8, $qty_invoiced, 'LRB', 0, 'C');
332
+		$this->Cell($dim_array[3], 8, number_format($item_pu_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
333
+		$this->Cell($dim_array[4], 8, number_format($discount_amount, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
334
+		$this->Cell($dim_array[5], 8, number_format($item_tva_total_amount, 2, '.', ' ') . ' ' . $currency . ' (' . round($tax_rate, 2) . '%)', 'LRB', 0, 'C');
335
+		$this->Cell($dim_array[6], 8, number_format($total_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C');
336 336
 		$this->Ln();
337 337
 	}
338 338
 
@@ -344,30 +344,30 @@  discard block
 block discarded – undo
344 344
 		// D�calage
345 345
 		$this->Ln();
346 346
 
347
-		$this->Cell(105,10);
348
-		$this->Cell(50,8,__('Total ET','wpshop'),1);
349
-		$this->Cell(35,8,number_format($order['order_total_ht'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
347
+		$this->Cell(105, 10);
348
+		$this->Cell(50, 8, __('Total ET', 'wpshop'), 1);
349
+		$this->Cell(35, 8, number_format($order['order_total_ht'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
350 350
 
351
-		foreach($order['order_tva'] as $k => $v) {
352
-			$this->Cell(105,10);
353
-			$this->Cell(50,8,__('Tax','wpshop').' '.$k.'%',1); $this->Cell(35,8,number_format($v,2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
351
+		foreach ($order['order_tva'] as $k => $v) {
352
+			$this->Cell(105, 10);
353
+			$this->Cell(50, 8, __('Tax', 'wpshop') . ' ' . $k . '%', 1); $this->Cell(35, 8, number_format($v, 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
354 354
 		}
355 355
 
356
-		$this->Cell(105,10);
357
-		$this->Cell(50,8,__('Shipping','wpshop'),1); $this->Cell(35,8,number_format($order['order_shipping_cost'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
356
+		$this->Cell(105, 10);
357
+		$this->Cell(50, 8, __('Shipping', 'wpshop'), 1); $this->Cell(35, 8, number_format($order['order_shipping_cost'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
358 358
 
359
-		if(!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']){
360
-			$this->Cell(105,10);
361
-			$this->Cell(50,8,utf8_decode(__('Total ATI before discount','wpshop')),1);
362
-			$this->Cell(35,8,number_format($order['order_grand_total_before_discount'],2).' '.$currency,1,0,'C'); $this->Ln();
359
+		if (!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']) {
360
+			$this->Cell(105, 10);
361
+			$this->Cell(50, 8, utf8_decode(__('Total ATI before discount', 'wpshop')), 1);
362
+			$this->Cell(35, 8, number_format($order['order_grand_total_before_discount'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln();
363 363
 
364
-			$this->Cell(105,10);
365
-			$this->Cell(50,8,__('Discount','wpshop'),1);
366
-			$this->Cell(35,8,'-'.number_format($order['order_discount_amount_total_cart'],2).' '.$currency,1,0,'C'); $this->Ln();
364
+			$this->Cell(105, 10);
365
+			$this->Cell(50, 8, __('Discount', 'wpshop'), 1);
366
+			$this->Cell(35, 8, '-' . number_format($order['order_discount_amount_total_cart'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln();
367 367
 		}
368 368
 
369
-		$this->Cell(105,10);
370
-		$this->Cell(50,8,__('Total ATI','wpshop'),1); $this->SetFont('','B',10); $this->Cell(35,8,number_format($order['order_grand_total'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln();
369
+		$this->Cell(105, 10);
370
+		$this->Cell(50, 8, __('Total ATI', 'wpshop'), 1); $this->SetFont('', 'B', 10); $this->Cell(35, 8, number_format($order['order_grand_total'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln();
371 371
 	}
372 372
 
373 373
 	function rib($store_number)
@@ -414,25 +414,25 @@  discard block
 block discarded – undo
414 414
 		$tva_intra = $store['company_tva_intra'];
415 415
 		$currency = wpshop_tools::wpshop_get_currency(true);
416 416
 
417
-		$this->SetFont('','',10);
418
-		$this->SetXY(10,-50);
417
+		$this->SetFont('', '', 10);
418
+		$this->SetXY(10, -50);
419 419
 
420
-		if(isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) {
421
-			$this->MultiCell(190,4,utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')),0,'L',FALSE);
420
+		if (isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) {
421
+			$this->MultiCell(190, 4, utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')), 0, 'L', FALSE);
422 422
 			$this->Ln();
423 423
 		}
424
-		$this->MultiCell(190,4,utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')),0,'L',FALSE);
424
+		$this->MultiCell(190, 4, utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')), 0, 'L', FALSE);
425 425
 		$this->Ln();
426
-		$this->MultiCell(190,4,utf8_decode($store_name.', '.$society_type.__(' capital of ', 'wpshop').$society_capital.' '.$currency.'. SIRET : '.$siret.'. TVA Intracommunautaire : '.$tva_intra),0,'L',FALSE);
426
+		$this->MultiCell(190, 4, utf8_decode($store_name . ', ' . $society_type . __(' capital of ', 'wpshop') . $society_capital . ' ' . $currency . '. SIRET : ' . $siret . '. TVA Intracommunautaire : ' . $tva_intra), 0, 'L', FALSE);
427 427
 	}
428 428
 
429 429
 	//En-t�te
430 430
 	function Header( ) {
431
-		$this->SetFont('Arial','B',15);
431
+		$this->SetFont('Arial', 'B', 15);
432 432
 		//D�calage � droite
433 433
 		$this->Cell(70);
434 434
 		//Titre
435
-		$this->Cell(30,10,'FACTURE',0,0,'L');
435
+		$this->Cell(30, 10, 'FACTURE', 0, 0, 'L');
436 436
 	}
437 437
 
438 438
 	//Pied de page
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 		//Positionnement � 1,5 cm du bas
441 441
 		$this->SetY(-15);
442 442
 		//Police Arial italique 8
443
-		$this->SetFont('Arial','I',8);
443
+		$this->SetFont('Arial', 'I', 8);
444 444
 		//Num�ro de page
445
-		$this->Cell(0,10,$this->PageNo() . '/{nb}',0,0,'C');
445
+		$this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C');
446 446
 	}
447 447
 }
448 448
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -21,8 +23,9 @@  discard block
 block discarded – undo
21 23
 
22 24
 	function WordWrap(&$text, $maxwidth) {
23 25
 		$text = trim($text);
24
-		if ($text==='')
25
-			return 0;
26
+		if ($text==='') {
27
+					return 0;
28
+		}
26 29
 		$space = $this->GetStringWidth(' ');
27 30
 		$lines = explode("\n", $text);
28 31
 		$text = '';
@@ -40,8 +43,7 @@  discard block
 block discarded – undo
40 43
 				{
41 44
 					$width += $wordwidth + $space;
42 45
 					$text .= $word.' ';
43
-				}
44
-				else
46
+				} else
45 47
 				{
46 48
 					$width = $wordwidth + $space;
47 49
 					$text = rtrim($text)."\n".$word.' ';
@@ -60,8 +62,7 @@  discard block
 block discarded – undo
60 62
 	function make_recursiv_dir($path, $rights = 0777) {
61 63
 		if (!@is_dir($path)) {
62 64
 			$folder_path = array($path);
63
-		}
64
-		else {
65
+		} else {
65 66
 			return;
66 67
 		}
67 68
 
@@ -94,8 +95,11 @@  discard block
 block discarded – undo
94 95
 
95 96
 					// Currency management
96 97
 					$currency = $order['order_currency'];
97
-					if($currency == 'EUR')$currency = EUR;
98
-					else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
98
+					if($currency == 'EUR') {
99
+						$currency = EUR;
100
+					} else {
101
+						$currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) );
102
+					}
99 103
 
100 104
 					// On d�finit un alias pour le nombre de pages total
101 105
 					$this->AliasNbPages();
@@ -129,10 +133,12 @@  discard block
 block discarded – undo
129 133
 					$this->forceDownload($Fichier_a_telecharger, $path, filesize($path));
130 134
 // 				}
131 135
 // 				else $this->forceDownload($filename, $invoice_url, filesize($invoice_url));
136
+			} else {
137
+				echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
132 138
 			}
133
-			else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop');
139
+		} else {
140
+			echo __('You don\'t have the rights to access this invoice.','wpshop');
134 141
 		}
135
-		else echo __('You don\'t have the rights to access this invoice.','wpshop');
136 142
 	}
137 143
 
138 144
 	/** Force le t�l�chargement d'un fichier */
@@ -186,8 +192,7 @@  discard block
 block discarded – undo
186 192
 			//if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12);
187 193
 			$this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12);
188 194
 			$this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12);
189
-		}
190
-		else {
195
+		} else {
191 196
 			$this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L');
192 197
 		}
193 198
 	}
@@ -302,8 +307,7 @@  discard block
 block discarded – undo
302 307
 			foreach ($order_data['order_items'] as $o) {
303 308
 				$this->row($o, $w, $currency);
304 309
 			}
305
-		}
306
-		else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
310
+		} else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) {
307 311
 			foreach ( $order_data['order_payment']['received'] as $payment_info ) {
308 312
 				if ( !is_array($payment_info) ) {
309 313
 
Please login to merge, or discard this patch.
includes/librairies/purchase/checkout.class.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -260,6 +260,10 @@
 block discarded – undo
260 260
 		}
261 261
 	}
262 262
 
263
+	/**
264
+	 * @param string $token
265
+	 * @param string $login
266
+	 */
263 267
 	public static function direct_payment_link( $token, $order_id, $login ) {
264 268
 
265 269
 		global $wpdb;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@
 block discarded – undo
23 23
 	var $creating_account = true;
24 24
 
25 25
 	/** Constructor of the class
26
-	* @return void
27
-	*/
26
+	 * @return void
27
+	 */
28 28
 	function __construct () {
29 29
 	}
30 30
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -58,12 +60,13 @@  discard block
 block discarded – undo
58 60
 						// On enregistre la commande
59 61
 						update_post_meta($order_id, '_order_postmeta', $order);
60 62
 						update_post_meta($order_id, '_wpshop_order_customer_id', $user_id);
63
+					} else {
64
+						$wpshop->add_error(__('You don\'t own the order', 'wpshop'));
61 65
 					}
62
-					else $wpshop->add_error(__('You don\'t own the order', 'wpshop'));
66
+				} else {
67
+					$wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
63 68
 				}
64
-				else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
65
-			}
66
-			else{
69
+			} else{
67 70
 				$order_data = array(
68 71
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
69 72
 					'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
@@ -106,7 +109,9 @@  discard block
 block discarded – undo
106 109
 
107 110
 				}
108 111
 				}
109
-				if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
112
+				if(!empty($download_codes)) {
113
+					update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
114
+				}
110 115
 
111 116
 				// Informations de commande � stocker
112 117
 				$currency = wpshop_tools::wpshop_get_currency(true);
@@ -128,8 +133,7 @@  discard block
 block discarded – undo
128 133
 				// Si c'est un devis
129 134
 				if ( $paymentMethod == 'quotation' ) {
130 135
 					$order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference();
131
-				}
132
-				else {
136
+				} else {
133 137
 					$order['order_key'] = wpshop_orders::get_new_order_reference();
134 138
 				}
135 139
 
@@ -190,8 +194,7 @@  discard block
 block discarded – undo
190 194
 
191 195
 				if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) {
192 196
 					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') );
193
-				}
194
-				else {
197
+				} else {
195 198
 					$email_option = get_option( 'wpshop_emails' );
196 199
 					if ( empty($email_option['send_confirmation_order_message']) ) {
197 200
 						$payment_method_option = get_option( 'wps_payment_mode' );
@@ -245,8 +248,7 @@  discard block
 block discarded – undo
245 248
 
246 249
 			if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){
247 250
 				$message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE';
248
-			}
249
-			else {
251
+			} else {
250 252
 				$message_type = 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE';
251 253
 				$order_tmp_key = $order_infos['order_temporary_key'];
252 254
 			}
@@ -288,8 +290,7 @@  discard block
 block discarded – undo
288 290
 				$_SESSION['order_id'] = $order_id;
289 291
 				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
290 292
 				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ) );
291
-			}
292
-			else {
293
+			} else {
293 294
 				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) );
294 295
 			}
295 296
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	/** Constructor of the class
26 26
 	* @return void
27 27
 	*/
28
-	function __construct () {
28
+	function __construct() {
29 29
 	}
30 30
 
31 31
 
32
-	public static function process_checkout($paymentMethod='paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) {
32
+	public static function process_checkout($paymentMethod = 'paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) {
33 33
 
34 34
 		global $wpdb, $wpshop, $wpshop_cart;
35 35
 		$wps_message = new wps_message_ctr();
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		if (is_user_logged_in()) :
39 39
 			$user_id = get_current_user_id();
40 40
 
41
-		if ( $customer_id != 0 ) {
41
+		if ($customer_id != 0) {
42 42
 			$user_id = $customer_id;
43 43
 		}
44 44
 
45 45
 			// If the order is already created in the db
46
-			if(!empty($order_id) && is_numeric($order_id)) {
46
+			if (!empty($order_id) && is_numeric($order_id)) {
47 47
 				$order = get_post_meta($order_id, '_order_postmeta', true);
48 48
 
49
-				if(!empty($order)) {
50
-					if($order['customer_id'] == $user_id) {
49
+				if (!empty($order)) {
50
+					if ($order['customer_id'] == $user_id) {
51 51
 						$order['payment_method'] = $paymentMethod;
52
-						$_SESSION['order_id'] = wpshop_tools::varSanitizer( $order_id );
52
+						$_SESSION['order_id'] = wpshop_tools::varSanitizer($order_id);
53 53
 						// Store cart in session
54 54
 						//wpshop_cart::store_cart_in_session($order);
55 55
 						// Add a payment
56
-						$order['order_payment']['received'][] = array( 'method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id() );
56
+						$order['order_payment']['received'][] = array('method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id());
57 57
 
58 58
 						// On enregistre la commande
59 59
 						update_post_meta($order_id, '_order_postmeta', $order);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 				}
64 64
 				else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop'));
65 65
 			}
66
-			else{
66
+			else {
67 67
 				$order_data = array(
68 68
 					'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER,
69
-					'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
69
+					'post_title' => sprintf(__('Order - %s', 'wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)),
70 70
 					'post_status' => 'publish',
71
-					'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field( $_POST['wps-customer-comment'] ) : '',
71
+					'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field($_POST['wps-customer-comment']) : '',
72 72
 					'post_author' => $user_id,
73 73
 					'comment_status' => 'closed'
74 74
 				);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 				$order_tva = array();
79 79
 
80 80
 				//$cart = (array)$wpshop_cart->cart;
81
-				if ( !empty($_SESSION['cart']) && !empty( $_SESSION['cart']['shipping_method']) ) {
81
+				if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['shipping_method'])) {
82 82
 					$_SESSION['cart']['shipping_method'] = __('Standard shipping method', 'wpshop');
83 83
 				}
84 84
 				$cart = (array)$_SESSION['cart'];
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
 				$_SESSION['order_id'] = $order_id;
91 91
 
92 92
 				// Cr�ation des codes de t�l�chargement si il y a des produits t�l�chargeable dans le panier
93
-				if ( !empty( $cart['order_items']  ) ) {
94
-				foreach($cart['order_items'] as $c) {
93
+				if (!empty($cart['order_items'])) {
94
+				foreach ($cart['order_items'] as $c) {
95 95
 					$product = wpshop_products::get_product_data($c['item_id']);
96 96
 					/** Check if it's a variation and check the parent product **/
97
-					if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
98
-						$parent_def = wpshop_products::get_parent_variation( $c['item_id'] );
99
-						if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) {
97
+					if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
98
+						$parent_def = wpshop_products::get_parent_variation($c['item_id']);
99
+						if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) {
100 100
 							$product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_'];
101 101
 						}
102 102
 					}
103
-					if(!empty($product['is_downloadable_'])) {
103
+					if (!empty($product['is_downloadable_'])) {
104 104
 						$download_codes[$c['item_id']] = array('item_id' => $c['item_id'], 'download_code' => uniqid('', true));
105 105
 					}
106 106
 
107 107
 				}
108 108
 				}
109
-				if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes);
109
+				if (!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_' . $order_id, $download_codes);
110 110
 
111 111
 				// Informations de commande � stocker
112 112
 				$currency = wpshop_tools::wpshop_get_currency(true);
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 					'order_payment' 		=> array(
122 122
 					'customer_choice' 		=> array('method' => $paymentMethod),
123 123
 					'received'				=> array('0' => array('method' => $paymentMethod, 'waited_amount' => $cart['order_amount_to_pay_now'], 'status' =>  'waiting_payment', 'author' => $user_id)),
124
-					'shipping_method'       => ( ( !empty( $_SESSION['shipping_method']) ) ? wpshop_tools::varSanitizer( $_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop') )
124
+					'shipping_method'       => ((!empty($_SESSION['shipping_method'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop'))
125 125
 					),
126 126
 				), $cart);
127 127
 
128 128
 				// Si c'est un devis
129
-				if ( $paymentMethod == 'quotation' ) {
129
+				if ($paymentMethod == 'quotation') {
130 130
 					$order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference();
131 131
 				}
132 132
 				else {
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				}
135 135
 
136 136
 				//Round final amount
137
-				$order['order_grand_total'] = number_format( round($order['order_grand_total'], 2), 2, '.', '');
138
-				$order['order_total_ttc'] = number_format( round($order['order_total_ttc'], 2), 2, '.', '');
139
-				$order['order_amount_to_pay_now'] = number_format( round($order['order_amount_to_pay_now'], 2), 2, '.', '');
137
+				$order['order_grand_total'] = number_format(round($order['order_grand_total'], 2), 2, '.', '');
138
+				$order['order_total_ttc'] = number_format(round($order['order_total_ttc'], 2), 2, '.', '');
139
+				$order['order_amount_to_pay_now'] = number_format(round($order['order_amount_to_pay_now'], 2), 2, '.', '');
140 140
 
141 141
 				/** On enregistre la commande	*/
142 142
 				update_post_meta($order_id, '_order_postmeta', $order);
@@ -145,75 +145,75 @@  discard block
 block discarded – undo
145 145
 				update_post_meta($order_id, '_wpshop_order_status', $order['order_status']);
146 146
 
147 147
 
148
-				do_action( 'wps_order_extra_save', $order_id );
148
+				do_action('wps_order_extra_save', $order_id);
149 149
 
150 150
 				//Add an action to extra actions on order save
151 151
 				// @TODO : REQUEST
152
-				$args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST);
153
-				wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args );
152
+				$args = array('order_id' => $order_id, 'posted_data' => $_REQUEST);
153
+				wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args);
154 154
 
155 155
 				/**	Set custmer information for the order	*/
156
-				$shipping_address =  ( !empty($shipping_address_option) && !empty($shipping_address_option['activate']) ) ? ( ( !empty($_SESSION['shipping_address']) ) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id ) : '';
157
-				$billing_address =  ( !empty($_SESSION['billing_address']) ) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id;
156
+				$shipping_address = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? ((!empty($_SESSION['shipping_address'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id) : '';
157
+				$billing_address = (!empty($_SESSION['billing_address'])) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id;
158 158
 
159 159
 
160
-				if ( !empty( $billing_address) ) {
160
+				if (!empty($billing_address)) {
161 161
 					wpshop_orders::set_order_customer_addresses($user_id, $order_id, $shipping_address, $billing_address);
162 162
 				}
163 163
 
164
-				if ( !empty($_SESSION['shipping_address_to_save']) ) {
164
+				if (!empty($_SESSION['shipping_address_to_save'])) {
165 165
 					$order_infos_postmeta = get_post_meta($order_id, '_order_info', true);
166 166
 					$order_infos_postmeta['shipping']['address'] = $_SESSION['shipping_address_to_save'];
167 167
 					$order_infos_postmeta['shipping']['address_id'] = '';
168 168
 					update_post_meta($order_id, '_order_info', $order_infos_postmeta);
169
-					unset( $_SESSION['shipping_address_to_save'] );
169
+					unset($_SESSION['shipping_address_to_save']);
170 170
 				}
171 171
 
172 172
 
173 173
 				/** Save Coupon use **/
174
-				if ( !empty($_SESSION['cart']['coupon_id']) ) {
174
+				if (!empty($_SESSION['cart']['coupon_id'])) {
175 175
 					$wps_coupon_mdl = new wps_coupon_model();
176
-					$wps_coupon_mdl->save_coupon_use( $_SESSION['cart']['coupon_id'] );
176
+					$wps_coupon_mdl->save_coupon_use($_SESSION['cart']['coupon_id']);
177 177
 				}
178 178
 
179 179
 				/**	Notify the customer as the case	*/
180 180
 				$user_info = get_userdata($user_id);
181 181
 				$email = $user_info->user_email;
182
-				$first_name = $user_info->user_firstname ;
182
+				$first_name = $user_info->user_firstname;
183 183
 				$last_name = $user_info->user_lastname;
184 184
 
185 185
 				// Envoie du message de confirmation de commande au client
186
-				$order_meta = get_post_meta( $order_id, '_order_postmeta', true);
186
+				$order_meta = get_post_meta($order_id, '_order_postmeta', true);
187 187
 
188
-				$shipping_mode_option = get_option( 'wps_shipping_mode' );
189
-				$shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' );
188
+				$shipping_mode_option = get_option('wps_shipping_mode');
189
+				$shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : '');
190 190
 
191
-				if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) {
192
-					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') );
191
+				if (!empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key'])) {
192
+					$wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''));
193 193
 				}
194 194
 				else {
195
-					$email_option = get_option( 'wpshop_emails' );
196
-					if ( empty($email_option['send_confirmation_order_message']) ) {
197
-						$payment_method_option = get_option( 'wps_payment_mode' );
198
-						$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
195
+					$email_option = get_option('wpshop_emails');
196
+					if (empty($email_option['send_confirmation_order_message'])) {
197
+						$payment_method_option = get_option('wps_payment_mode');
198
+						$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method'];
199 199
 
200
-						$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0),  'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '',  'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ) );
200
+						$wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''));
201 201
 					}
202 202
 				}
203 203
 
204
-				if ( empty($_SESSION['wps-pos-addon']) ) {
204
+				if (empty($_SESSION['wps-pos-addon'])) {
205 205
 					$email_option = get_option('wpshop_emails');
206
-					if( empty($email_option) || ( !empty($email_option) && empty($email_option['send_confirmation_order_message']) ) ){
207
-						self::send_order_email_to_administrator( $order_id, $user_info );
206
+					if (empty($email_option) || (!empty($email_option) && empty($email_option['send_confirmation_order_message']))) {
207
+						self::send_order_email_to_administrator($order_id, $user_info);
208 208
 					}
209 209
 				}
210 210
 
211 211
 
212 212
 				/** IF Order amount is 0, Finish the Order **/
213
-				if ( $cart['order_amount_to_pay_now'] == 0 ) {
213
+				if ($cart['order_amount_to_pay_now'] == 0) {
214 214
 					$order_meta = get_post_meta($order_id, '_order_postmeta', true);
215 215
 					$payment_status = 'completed';
216
-					$params_array = array (
216
+					$params_array = array(
217 217
 						'method' =>'free',
218 218
 						'waited_amount' => $order_meta['order_amount_to_pay_now'],
219 219
 						'status' =>  'payment_received',
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 					);
225 225
 					wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status);
226 226
 				}
227
-				apply_filters( 'wpshop_finish_order_extra_actions', $order_id);
227
+				apply_filters('wpshop_finish_order_extra_actions', $order_id);
228 228
 			}
229 229
 		endif;
230 230
 		return $order_id;
231 231
 	}
232 232
 
233
-	public static function send_order_email_to_administrator ( $order_id, $customer_infos = ''  ) {
234
-		if ( !empty($order_id) ) {
233
+	public static function send_order_email_to_administrator($order_id, $customer_infos = '') {
234
+		if (!empty($order_id)) {
235 235
 			$wps_message = new wps_message_ctr();
236 236
 			$order_infos = get_post_meta($order_id, '_order_postmeta', true);
237 237
 			//Send email to administrator(s)
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 			$shop_admin_email = $shop_admin_email_option['contact_email'];
240 240
 			$order_tmp_key = '';
241 241
 
242
-			$shipping_mode_option = get_option( 'wps_shipping_mode' );
243
-			$shipping_method = ( !empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ( (!empty($order_infos['order_payment']['shipping_method']) ) ? $order_infos['order_payment']['shipping_method'] : '' );
242
+			$shipping_mode_option = get_option('wps_shipping_mode');
243
+			$shipping_method = (!empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ((!empty($order_infos['order_payment']['shipping_method'])) ? $order_infos['order_payment']['shipping_method'] : '');
244 244
 
245 245
 
246
-			if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){
246
+			if (!empty($order_infos) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key'])) {
247 247
 				$message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE';
248 248
 			}
249 249
 			else {
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
 				$order_tmp_key = $order_infos['order_temporary_key'];
252 252
 			}
253 253
 
254
-			$payment_method_option = get_option( 'wps_payment_mode' );
255
-			$order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])  ) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method'];
254
+			$payment_method_option = get_option('wps_payment_mode');
255
+			$order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method'];
256 256
 
257
-			$data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => ( !empty($customer_infos) && !empty($customer_infos->user_email) ) ? $customer_infos->user_email : '' , 'customer_last_name' => ( !empty($customer_infos) && !empty($customer_infos->user_lastname) ) ? $customer_infos->user_lastname : '', 'customer_first_name' => ( !empty($customer_infos) && !empty($customer_infos->user_firstname) ) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '','order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' );
257
+			$data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => (!empty($customer_infos) && !empty($customer_infos->user_email)) ? $customer_infos->user_email : '', 'customer_last_name' => (!empty($customer_infos) && !empty($customer_infos->user_lastname)) ? $customer_infos->user_lastname : '', 'customer_first_name' => (!empty($customer_infos) && !empty($customer_infos->user_firstname)) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '');
258 258
 
259
-			$wps_message->wpshop_prepared_email( $shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id));
259
+			$wps_message->wpshop_prepared_email($shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id));
260 260
 		}
261 261
 	}
262 262
 
263
-	public static function direct_payment_link( $token, $order_id, $login ) {
263
+	public static function direct_payment_link($token, $order_id, $login) {
264 264
 
265 265
 		global $wpdb;
266
-		if( !empty($token) && !empty($order_id) && !empty($login) ) {
266
+		if (!empty($token) && !empty($order_id) && !empty($login)) {
267 267
 			/** Verify informations **/
268
-			$query = $wpdb->prepare( 'SELECT * FROM ' .$wpdb->users. ' WHERE user_login = %s AND user_activation_key = %s', $login, $token);
269
-			$user_infos = $wpdb->get_row( $query );
270
-			if( !empty($user_infos) ) {
268
+			$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->users . ' WHERE user_login = %s AND user_activation_key = %s', $login, $token);
269
+			$user_infos = $wpdb->get_row($query);
270
+			if (!empty($user_infos)) {
271 271
 				/** Connect the user **/
272 272
 				$secure_cookie = is_ssl() ? true : false;
273 273
 				wp_set_auth_cookie($user_infos->ID, true, $secure_cookie);
@@ -276,21 +276,21 @@  discard block
 block discarded – undo
276 276
 				$order_meta = get_post_meta($order_id, '_order_postmeta', true);
277 277
 				$_SESSION['cart'] = array();
278 278
 				$_SESSION['cart']['order_items'] = array();
279
-				if ( !empty($order_meta) && !empty( $order_meta['order_items']) ) {
279
+				if (!empty($order_meta) && !empty($order_meta['order_items'])) {
280 280
 					$wpshop_cart_type = 'cart';
281
-					foreach( $order_meta['order_items'] as $item ) {;
281
+					foreach ($order_meta['order_items'] as $item) {;
282 282
 						$_SESSION['cart']['order_items'][$item['item_id']] = $item;
283 283
 					}
284 284
 					$wps_cart_ctr = new wps_cart();
285
-					$order = $wps_cart_ctr->calcul_cart_information( array() );
286
-					$wps_cart_ctr->store_cart_in_session( $order );
285
+					$order = $wps_cart_ctr->calcul_cart_information(array());
286
+					$wps_cart_ctr->store_cart_in_session($order);
287 287
 				}
288 288
 				$_SESSION['order_id'] = $order_id;
289
-				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
290
-				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ) );
289
+				$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login));
290
+				wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))));
291 291
 			}
292 292
 			else {
293
-				wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) );
293
+				wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id'))));
294 294
 			}
295 295
 
296 296
 		}
Please login to merge, or discard this patch.
includes/librairies/purchase/orders.class.php 4 patches
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 
266 266
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
267
-	* @return int
267
+	* @return string
268 268
 	*/
269 269
 	public static function get_new_order_reference(){
270 270
 		$number_figures = get_option('wpshop_order_number_figures', false);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
288
-	* @return int
288
+	* @return string
289 289
 	*/
290 290
 	public static function get_new_pre_order_reference($save = true){
291 291
 		$number_figures = get_option('wpshop_order_number_figures', false);
@@ -650,6 +650,10 @@  discard block
 block discarded – undo
650 650
 
651 651
 		return $output;
652 652
 	}
653
+
654
+	/**
655
+	 * @param boolean $state
656
+	 */
653 657
 	static function display_customer_pay_quotation( $state, $oid ) {
654 658
 		$btn = '<a role="button" class="wps-bton-' . ( ( $state ) ? 'third' : 'second' ) . '-mini-rounded quotation_is_payable_by_customer" href="#" >'.__('Customer can pay', 'wpshop').'</a>';
655 659
 		if( $state ) {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 	/** Generate the billing reference regarding the order $order_id
245 245
 	 * @return void
246
-	*/
246
+	 */
247 247
 	function order_generate_billing_number($order_id, $force_invoicing = false){
248 248
 		global $wpdb, $wpshop_modules_billing;
249 249
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 
265 265
 
266 266
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
267
-	* @return int
268
-	*/
267
+	 * @return int
268
+	 */
269 269
 	public static function get_new_order_reference(){
270 270
 		$number_figures = get_option('wpshop_order_number_figures', false);
271 271
 		/* If the number doesn't exist, we create a default one */
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
288
-	* @return int
289
-	*/
288
+	 * @return int
289
+	 */
290 290
 	public static function get_new_pre_order_reference($save = true){
291 291
 		$number_figures = get_option('wpshop_order_number_figures', false);
292 292
 		/* If the number doesn't exist, we create a default one */
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 	/** Set the custom colums
350 350
 	 * @return array
351
-	*/
351
+	 */
352 352
 	static function orders_edit_columns($columns){
353 353
 	  $columns = array(
354 354
 		'cb' => '<input type="checkbox" />',
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 	/** Give the content by column
369 369
 	 * @return array
370
-	*/
370
+	 */
371 371
 	public static function orders_custom_columns($column, $post_id) {
372 372
 		if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) {
373 373
 			global $civility, $order_status;
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Products management method file
4 6
  *
@@ -132,8 +134,7 @@  discard block
 block discarded – undo
132 134
 		$order_main_info .= '<div class="wps-product-section">';
133 135
 		if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){
134 136
 			$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>';
135
-		}
136
-		else{
137
+		} else{
137 138
 			if(!empty($order_postmeta['order_key'])){
138 139
 				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>';
139 140
 			}
@@ -148,8 +149,7 @@  discard block
 block discarded – undo
148 149
 				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID;
149 150
 				$order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin');
150 151
 				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . '';
151
-			}
152
-			else {
152
+			} else {
153 153
 				$order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin');
154 154
 			}
155 155
 		}
@@ -195,8 +195,7 @@  discard block
 block discarded – undo
195 195
 			if ( empty($credit_meta) ) {
196 196
 				if( $order_postmeta['order_status'] == 'refunded') {
197 197
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&amp;invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>';
198
-				}
199
-				else {
198
+				} else {
200 199
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
201 200
 				}
202 201
 			}
@@ -276,8 +275,7 @@  discard block
 block discarded – undo
276 275
 
277 276
 		$order_current_number = get_option('wpshop_order_current_number', false);
278 277
 		/* If the counter doesn't exist, we initiate it */
279
-		if(!$order_current_number) { $order_current_number = 1; }
280
-		else { $order_current_number++; }
278
+		if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; }
281 279
 		update_option('wpshop_order_current_number', $order_current_number);
282 280
 
283 281
 		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
@@ -297,8 +295,7 @@  discard block
 block discarded – undo
297 295
 
298 296
 		$order_current_number = get_option('wpshop_preorder_current_number', false);
299 297
 		/* If the counter doesn't exist, we initiate it */
300
-		if(!$order_current_number) { $order_current_number = 1; }
301
-		else { $order_current_number++; }
298
+		if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; }
302 299
 		if($save){
303 300
 			update_option('wpshop_preorder_current_number', $order_current_number);
304 301
 		}
@@ -332,8 +329,7 @@  discard block
 block discarded – undo
332 329
 					$shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
333 330
 				}
334 331
 			}
335
-		}
336
-		else {
332
+		} else {
337 333
 			$shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
338 334
 			$shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
339 335
 			$shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : '';
@@ -394,8 +390,7 @@  discard block
 block discarded – undo
394 390
 				case "order_billing":
395 391
 					if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) {
396 392
 						$billing = $addresses['billing']['address'];
397
-					}
398
-					else if ( !empty($addresses['billing']) ) {
393
+					} else if ( !empty($addresses['billing']) ) {
399 394
 						$billing = $addresses['billing'];
400 395
 					}
401 396
 					if ( !empty($billing) ) {
@@ -403,8 +398,7 @@  discard block
 block discarded – undo
403 398
 						echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />';
404 399
 						echo (!empty($billing['address']) ? $billing['address'] : null).'<br />';
405 400
 						echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null);
406
-					}
407
-					else {
401
+					} else {
408 402
 						echo __('No information available for user billing', 'wpshop');
409 403
 					}
410 404
 				break;
@@ -412,8 +406,7 @@  discard block
 block discarded – undo
412 406
 				case "order_shipping":
413 407
 					if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) {
414 408
 						$shipping = $addresses['shipping']['address'];
415
-					}
416
-					else if ( !empty($addresses['shipping']) ) {
409
+					} else if ( !empty($addresses['shipping']) ) {
417 410
 						$shipping = $addresses['shipping'];
418 411
 					}
419 412
 					if ( !empty($shipping) ) {
@@ -421,8 +414,7 @@  discard block
 block discarded – undo
421 414
 						echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />';
422 415
 						echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />';
423 416
 						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null);
424
-					}
425
-					else{
417
+					} else{
426 418
 						echo __('No information available for user shipping', 'wpshop');
427 419
 					}
428 420
 				break;
@@ -435,8 +427,7 @@  discard block
 block discarded – undo
435 427
 						// Marquer comme envoy�
436 428
 						if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) {
437 429
 							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> ';
438
-						}
439
-						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
430
+						} else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
440 431
 							//		$buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' ';
441 432
 						}
442 433
 						$buttons .= '</p>';
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -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
  * Products management method file
4 4
  *
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 /*	Check if file is include. No direct access possible with file url	*/
13
-if ( !defined( 'WPSHOP_VERSION' ) ) {
14
-	die( __('Access is not allowed by this way', 'wpshop') );
13
+if (!defined('WPSHOP_VERSION')) {
14
+	die(__('Access is not allowed by this way', 'wpshop'));
15 15
 }
16 16
 
17 17
 /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		/**	Add action button	*/
71 71
 		add_meta_box(
72 72
 			'wpshop_order_actions',
73
-			'<span class="dashicons dashicons-info"></span> '.__('Actions on order', 'wpshop'),
73
+			'<span class="dashicons dashicons-info"></span> ' . __('Actions on order', 'wpshop'),
74 74
 			array('wpshop_orders', 'order_actions'),
75 75
 				WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'high'
76 76
 		);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param object $order The current order being edited
112 112
 	 */
113
-	public static function order_actions( $order ) {
113
+	public static function order_actions($order) {
114 114
 		$output = '';
115 115
 
116 116
 		$order_status = unserialize(WPSHOP_ORDER_STATUS);
@@ -118,37 +118,37 @@  discard block
 block discarded – undo
118 118
 
119 119
 		$tpl_component = array();
120 120
 
121
-		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url( get_delete_post_link($order->ID) ) , 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') :  __('Move to Trash', 'wpshop'))), array(), 'admin');
122
-		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : '';
121
+		$delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url(get_delete_post_link($order->ID)), 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin');
122
+		$tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : '';
123 123
 
124 124
 		/**	Add an action list	*/
125 125
 		$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = '';
126 126
 
127 127
 		/**	Display main information about the order	*/
128 128
 		$order_main_info = '';
129
-		if(!empty($order_postmeta['order_date'])){
130
-			$order_main_info .=  '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>'.__('Order date','wpshop').' : </strong><br/>'.mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true).'</div>';
129
+		if (!empty($order_postmeta['order_date'])) {
130
+			$order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>' . __('Order date', 'wpshop') . ' : </strong><br/>' . mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true) . '</div>';
131 131
 		}
132 132
 		$order_main_info .= '<div class="wps-product-section">';
133
-		if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){
134
-			$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>';
133
+		if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) {
134
+			$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>';
135 135
 		}
136
-		else{
137
-			if(!empty($order_postmeta['order_key'])){
138
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>';
136
+		else {
137
+			if (!empty($order_postmeta['order_key'])) {
138
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>';
139 139
 			}
140
-			if(!empty($order_postmeta['order_temporary_key'])){
141
-				$order_main_info .=  '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>';
142
-				$post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0;
143
-				$order_main_info .= '<a href="' .WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $post_ID . '&mode=pdf">' .__('Download the quotation', 'wpshop'). '</a><br />';
140
+			if (!empty($order_postmeta['order_temporary_key'])) {
141
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>';
142
+				$post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0;
143
+				$order_main_info .= '<a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $post_ID . '&mode=pdf">' . __('Download the quotation', 'wpshop') . '</a><br />';
144 144
 			}
145
-			if(!empty($order_postmeta['order_invoice_ref'])){
145
+			if (!empty($order_postmeta['order_invoice_ref'])) {
146 146
 				$sub_tpl_component = array();
147 147
 				$sub_tpl_component['ADMIN_ORDER_RECEIVED_PAYMENT_INVOICE_REF'] = $order_postmeta['order_invoice_ref'];
148 148
 				$sub_tpl_component['ADMIN_ORDER_PAYMENT_RECEIVED_LINE_CLASSES'] = '';
149 149
 				$sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID;
150 150
 				$order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin');
151
-				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . '';
151
+				$order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . '';
152 152
 			}
153 153
 			else {
154 154
 				$order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin');
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 
160 160
 		/*Add the current order status in display**/
161
-			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= ( !empty($order_postmeta['order_status']) ) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) ) : '';
161
+			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= (!empty($order_postmeta['order_status'])) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop'))) : '';
162 162
 
163 163
 			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info;
164 164
 
@@ -168,37 +168,37 @@  discard block
 block discarded – undo
168 168
 		 * To check because notification is not really send
169 169
 		 *
170 170
 		 */
171
-		if ( !empty($order->post_author) ) {
171
+		if (!empty($order->post_author)) {
172 172
 			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '
173 173
 			<div class="wps-product-section wpshop_order_notify_customer_on_update_container" >
174
-				<input type="checkbox" name="notif_the_customer" id="wpshop_order_notif_the_customer_on_update" /> <label for="wpshop_order_notif_the_customer_on_update" >'.__('Send a notification to the customer', 'wpshop').'</label>
175
-				<!-- <br/><input type="checkbox" name="notif_the_customer_sendsms" id="wpshop_order_notif_the_customer_sendsms_on_update" /> <label for="wpshop_order_nnotif_the_customer_sendsms_on_update" >'.__('Send a SMS to the customer', 'wpshop').'</label> -->
174
+				<input type="checkbox" name="notif_the_customer" id="wpshop_order_notif_the_customer_on_update" /> <label for="wpshop_order_notif_the_customer_on_update" >'.__('Send a notification to the customer', 'wpshop') . '</label>
175
+				<!-- <br/><input type="checkbox" name="notif_the_customer_sendsms" id="wpshop_order_notif_the_customer_sendsms_on_update" /> <label for="wpshop_order_nnotif_the_customer_sendsms_on_update" >'.__('Send a SMS to the customer', 'wpshop') . '</label> -->
176 176
 			</div>';
177 177
 		}
178 178
 
179
-		if( ( ( !empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation' ) || !empty( $order_postmeta['order_temporary_key'] ) ) && $order_postmeta['order_status'] != 'canceled' && (float) $order_postmeta['order_amount_to_pay_now'] != (float) 0 ) {
180
-			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation( isset( $order_postmeta['pay_quotation'] ), $order->ID ) . '</div>';
179
+		if (((!empty($order_postmeta['cart_type']) && $order_postmeta['cart_type'] == 'quotation') || !empty($order_postmeta['order_temporary_key'])) && $order_postmeta['order_status'] != 'canceled' && (float)$order_postmeta['order_amount_to_pay_now'] != (float)0) {
180
+			$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section">' . self::display_customer_pay_quotation(isset($order_postmeta['pay_quotation']), $order->ID) . '</div>';
181 181
 		}
182 182
 
183 183
 		/*Add the button regarding the order status**/
184
-		if ( !empty($order_postmeta['order_status']) ) {
185
-			switch ( $order_postmeta['order_status'] ) {
184
+		if (!empty($order_postmeta['order_status'])) {
185
+			switch ($order_postmeta['order_status']) {
186 186
 				case 'awaiting_payment':
187
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><a role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" >'.__('Send a payment link to customer', 'wpshop').'</a></div>';
188
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_'.$order->ID.'" >'.__('Cancel this order', 'wpshop').'</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
187
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><a role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" >' . __('Send a payment link to customer', 'wpshop') . '</a></div>';
188
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_' . $order->ID . '" >' . __('Cancel this order', 'wpshop') . '</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>';
189 189
 				break;
190 190
 				/*case 'completed' || 'shipped':
191 191
 					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_resend_order_to_customer" ><button class="wps-bton-second-mini-rounded wps_resend_order_to_customer order_' .$order->ID. '">' . __('Resend this order to customer', 'wpshop') . '</button><input type="hidden" id="resendordertocustomer_order_hidden_indicator" name="resendordertocustomer_order_hidden_indicator" /></div>';
192 192
 				break;*/
193 193
 			}
194
-			$credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true );
194
+			$credit_meta = get_post_meta($order->ID, '_wps_order_credit', true);
195 195
 
196
-			if ( empty($credit_meta) ) {
197
-				if( $order_postmeta['order_status'] == 'refunded') {
198
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&amp;invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>';
196
+			if (empty($credit_meta)) {
197
+				if ($order_postmeta['order_status'] == 'refunded') {
198
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' . __('Credit Slip number', 'wpshop') . ' : <strong>' . ((!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref'])) ? '<a href="' . WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID . '&amp;invoice_ref=' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '&credit_slip=ok" target="_blank">' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '</a>' : '') . '</strong></div>';
199 199
 				}
200 200
 				else {
201
-					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
201
+					$tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' . $order->ID . '">' . __('Refund this order', 'wpshop') . '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>';
202 202
 				}
203 203
 			}
204 204
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	function order_container_in_admin() {
211 211
 		global $post;
212 212
 		$output  = '<div id="wps_order_content_container">';
213
-		$output .= self::order_content( $post );
213
+		$output .= self::order_content($post);
214 214
 		$output .= '</div>';
215 215
 		echo $output;
216 216
 	}
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param order $post The complete order content
223 223
 	 */
224
-	function order_content( $post ) {
224
+	function order_content($post) {
225 225
 		$order_content = '';
226 226
 
227 227
 		$order = get_post_meta($post->ID, '_order_postmeta', true);
228 228
 
229 229
 		$order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >';
230
-		if($order){/*	Read the order content if the order has product	*/
230
+		if ($order) {/*	Read the order content if the order has product	*/
231 231
 			$order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin');
232 232
 			if (empty($order['order_invoice_ref'])) {
233 233
 				$order_content .= '<div id="order_refresh_button_container" class="wpshop_clear_block" ><input type="button" class="button-primary alignright wpshopHide" id="wpshop_admin_order_recalculate" value="' . __('Refresh order informations', 'wpshop') . '" /></div>';
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
 	/** Generate the billing reference regarding the order $order_id
246 246
 	 * @return void
247 247
 	*/
248
-	function order_generate_billing_number($order_id, $force_invoicing = false){
248
+	function order_generate_billing_number($order_id, $force_invoicing = false) {
249 249
 		global $wpdb, $wpshop_modules_billing;
250 250
 
251 251
 		// Get the order from the db
252 252
 		$order = get_post_meta($order_id, '_order_postmeta', true);
253 253
 
254 254
 		// If the payment is completed
255
-		if(($order['order_status']=='completed') || $force_invoicing) {
255
+		if (($order['order_status'] == 'completed') || $force_invoicing) {
256 256
 
257 257
 			// If the reference hasn't been generated yet
258
-			if(empty($order['order_invoice_ref'])) {
259
-				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id );
258
+			if (empty($order['order_invoice_ref'])) {
259
+				$order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id);
260 260
 
261 261
 				update_post_meta($order_id, '_order_postmeta', $order);
262 262
 			}
@@ -267,45 +267,45 @@  discard block
 block discarded – undo
267 267
 	/** Renvoi une nouvelle r�f�rence unique pour une commande
268 268
 	* @return int
269 269
 	*/
270
-	public static function get_new_order_reference(){
270
+	public static function get_new_order_reference() {
271 271
 		$number_figures = get_option('wpshop_order_number_figures', false);
272 272
 		/* If the number doesn't exist, we create a default one */
273
-		if(!$number_figures){
273
+		if (!$number_figures) {
274 274
 			$number_figures = 5;
275 275
 			update_option('wpshop_order_number_figures', $number_figures);
276 276
 		}
277 277
 
278 278
 		$order_current_number = get_option('wpshop_order_current_number', false);
279 279
 		/* If the counter doesn't exist, we initiate it */
280
-		if(!$order_current_number) { $order_current_number = 1; }
280
+		if (!$order_current_number) { $order_current_number = 1; }
281 281
 		else { $order_current_number++; }
282 282
 		update_option('wpshop_order_current_number', $order_current_number);
283 283
 
284
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
285
-		return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref;
284
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
285
+		return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref;
286 286
 	}
287 287
 
288 288
 	/** Renvoi une nouvelle r�f�rence unique pour un devis
289 289
 	* @return int
290 290
 	*/
291
-	public static function get_new_pre_order_reference($save = true){
291
+	public static function get_new_pre_order_reference($save = true) {
292 292
 		$number_figures = get_option('wpshop_order_number_figures', false);
293 293
 		/* If the number doesn't exist, we create a default one */
294
-		if(!$number_figures){
294
+		if (!$number_figures) {
295 295
 			$number_figures = 5;
296 296
 			update_option('wpshop_order_number_figures', $number_figures);
297 297
 		}
298 298
 
299 299
 		$order_current_number = get_option('wpshop_preorder_current_number', false);
300 300
 		/* If the counter doesn't exist, we initiate it */
301
-		if(!$order_current_number) { $order_current_number = 1; }
301
+		if (!$order_current_number) { $order_current_number = 1; }
302 302
 		else { $order_current_number++; }
303
-		if($save){
303
+		if ($save) {
304 304
 			update_option('wpshop_preorder_current_number', $order_current_number);
305 305
 		}
306 306
 
307
-		$order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number);
308
-		return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref;
307
+		$order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number);
308
+		return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref;
309 309
 	}
310 310
 
311 311
 
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 *	@return void
322 322
 	 */
323
-	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){
323
+	public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') {
324 324
 		/**	Get order informations	*/
325 325
 		$billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
326
-		$billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
327
-		$billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : '';
328
-		if ( !empty($_SESSION['shipping_partner_id']) ) {
329
-			$partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
326
+		$billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
327
+		$billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : '';
328
+		if (!empty($_SESSION['shipping_partner_id'])) {
329
+			$partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true);
330 330
 			if (!empty($partner_address_id)) {
331
-				foreach( $partner_address_id as $address_id ) {
331
+				foreach ($partner_address_id as $address_id) {
332 332
 					$shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
333
-					$shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
333
+					$shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
334 334
 				}
335 335
 			}
336 336
 		}
337 337
 		else {
338 338
 			$shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true);
339
-			$shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true);
340
-			$shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : '';
339
+			$shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true);
340
+			$shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : '';
341 341
 		}
342 342
 
343 343
 		$order_info = array('billing' => $billing_info, 'shipping' => $shipping_info);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	/** Set the custom colums
351 351
 	 * @return array
352 352
 	*/
353
-	static function orders_edit_columns($columns){
353
+	static function orders_edit_columns($columns) {
354 354
 	  $columns = array(
355 355
 		'cb' => '<input type="checkbox" />',
356 356
 		'order_identifier' => __('Identifiers', 'wpshop'),
@@ -370,40 +370,40 @@  discard block
 block discarded – undo
370 370
 	 * @return array
371 371
 	*/
372 372
 	public static function orders_custom_columns($column, $post_id) {
373
-		if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) {
373
+		if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) {
374 374
 			global $civility, $order_status;
375 375
 
376 376
 			$metadata = get_post_custom();
377 377
 
378
-			$order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):'';
379
-			$addresses = get_post_meta($post_id,'_order_info', true);
378
+			$order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : '';
379
+			$addresses = get_post_meta($post_id, '_order_info', true);
380 380
 
381
-			switch($column){
381
+			switch ($column) {
382 382
 				case "order_identifier":
383
-					if( !empty( $order_postmeta['order_key'] ) ) {
383
+					if (!empty($order_postmeta['order_key'])) {
384 384
 						echo '<b>' . $order_postmeta['order_key'] . '</b><br>';
385 385
 					}
386
-					if( !empty( $order_postmeta['order_invoice_ref'] ) ) {
387
-						echo ( !empty($order_postmeta['order_temporary_key'] ) ? '<b>' . $order_postmeta['order_invoice_ref'] . '</b>' :  '<i>' . $order_postmeta['order_invoice_ref'] . '</i>' );
386
+					if (!empty($order_postmeta['order_invoice_ref'])) {
387
+						echo (!empty($order_postmeta['order_temporary_key']) ? '<b>' . $order_postmeta['order_invoice_ref'] . '</b>' : '<i>' . $order_postmeta['order_invoice_ref'] . '</i>');
388 388
 					}
389 389
 				break;
390 390
 
391 391
 				case "order_status":
392
-					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_'.$post_id.'">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
392
+					echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_' . $post_id . '">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop');
393 393
 				break;
394 394
 
395 395
 				case "order_billing":
396
-					if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) {
396
+					if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) {
397 397
 						$billing = $addresses['billing']['address'];
398 398
 					}
399
-					else if ( !empty($addresses['billing']) ) {
399
+					else if (!empty($addresses['billing'])) {
400 400
 						$billing = $addresses['billing'];
401 401
 					}
402
-					if ( !empty($billing) ) {
403
-						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null).' <strong>'.(!empty($billing['address_first_name']) ? $billing['address_first_name'] : null).' '.(!empty($billing['address_last_name']) ? $billing['address_last_name'] : null).'</strong>';
404
-						echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />';
405
-						echo (!empty($billing['address']) ? $billing['address'] : null).'<br />';
406
-						echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null);
402
+					if (!empty($billing)) {
403
+						echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null) . ' <strong>' . (!empty($billing['address_first_name']) ? $billing['address_first_name'] : null) . ' ' . (!empty($billing['address_last_name']) ? $billing['address_last_name'] : null) . '</strong>';
404
+						echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />';
405
+						echo (!empty($billing['address']) ? $billing['address'] : null) . '<br />';
406
+						echo (!empty($billing['postcode']) ? $billing['postcode'] : null) . ' ' . (!empty($billing['city']) ? $billing['city'] : null) . ', ' . (!empty($billing['country']) ? $billing['country'] : null);
407 407
 					}
408 408
 					else {
409 409
 						echo __('No information available for user billing', 'wpshop');
@@ -411,33 +411,33 @@  discard block
 block discarded – undo
411 411
 				break;
412 412
 
413 413
 				case "order_shipping":
414
-					if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) {
414
+					if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) {
415 415
 						$shipping = $addresses['shipping']['address'];
416 416
 					}
417
-					else if ( !empty($addresses['shipping']) ) {
417
+					else if (!empty($addresses['shipping'])) {
418 418
 						$shipping = $addresses['shipping'];
419 419
 					}
420
-					if ( !empty($shipping) ) {
421
-						echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>';
422
-						echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />';
423
-						echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />';
424
-						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null);
420
+					if (!empty($shipping)) {
421
+						echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>';
422
+						echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />';
423
+						echo (!empty($shipping['address']) ? $shipping['address'] : null) . '<br />';
424
+						echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null) . ' ' . (!empty($shipping['city']) ? $shipping['city'] : null) . ', ' . (!empty($shipping['country']) ? $shipping['country'] : null);
425 425
 					}
426
-					else{
426
+					else {
427 427
 						echo __('No information available for user shipping', 'wpshop');
428 428
 					}
429 429
 				break;
430 430
 
431 431
 				case "order_type":
432
-						echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.(!empty($order_postmeta['order_temporary_key']) ? __('Quotation','wpshop') :  __('Basic order','wpshop')).'</a>';
432
+						echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>';
433 433
 						$buttons = '<p class="row-actions">';
434 434
 						// Voir la commande
435
-						$buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>';
435
+						$buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>';
436 436
 						// Marquer comme envoy�
437 437
 						if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) {
438
-							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> ';
438
+							$buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader">' . __('Mark as shipped', 'wpshop') . '</a> ';
439 439
 						}
440
-						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) {
440
+						else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) {
441 441
 							//		$buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' ';
442 442
 						}
443 443
 						$buttons .= '</p>';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
 				case "order_total":
452 452
 					$currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency');
453
-					echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '.  wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
453
+					echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN';
454 454
 				break;
455 455
 
456 456
 				/*case "order_actions":
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	public static function list_table_filters() {
481
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
482
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
483
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
484
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
481
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
482
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
483
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
484
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
485 485
 
486 486
 		if (isset($post_type)) {
487 487
 			if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) {
@@ -493,23 +493,23 @@  discard block
 block discarded – undo
493 493
 				echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index');
494 494
 				$min = $entity_filter_btpf;
495 495
 				$max = $entity_filter_btps;
496
-				echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> ';
497
-				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null);
498
-				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null);
496
+				echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> ';
497
+				echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null);
498
+				echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null);
499 499
 			}
500 500
 		}
501 501
 	}
502 502
 
503 503
 	public static function list_table_filter_parse_query($query) {
504 504
 		global $pagenow, $wpdb;
505
-		$post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
506
-		$entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : '';
507
-		$entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : '';
508
-		$entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : '';
505
+		$post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '';
506
+		$entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : '';
507
+		$entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : '';
508
+		$entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : '';
509 509
 
510
-		if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) {
510
+		if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) {
511 511
 			$check = null;
512
-			switch ( $entity_filter ) {
512
+			switch ($entity_filter) {
513 513
 				case 'all':
514 514
 					$sql_query = $wpdb->prepare(
515 515
 						"SELECT ID
@@ -573,27 +573,27 @@  discard block
 block discarded – undo
573 573
 						break;
574 574
 			}
575 575
 
576
-			if ( !empty( $check ) ) {
577
-				if( !empty($no_btp) && $no_btp == 'yes' ) {
576
+			if (!empty($check)) {
577
+				if (!empty($no_btp) && $no_btp == 'yes') {
578 578
 					$min = 'minimum';
579 579
 					$max = 'maximum';
580 580
 				} else {
581
-					$min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum';
582
-					$max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum';
581
+					$min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum';
582
+					$max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum';
583 583
 				}
584 584
 				$results = $wpdb->get_results($sql_query);
585 585
 				$post_id_list = array();
586 586
 				$i = 0;
587
-				foreach($results as $item){
587
+				foreach ($results as $item) {
588 588
 					$meta_value = get_post_meta($item->ID, '_order_postmeta');
589
-					$price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : '';
590
-					if( $price >= $min || $min == 'minimum' ) {
591
-						if( $price <= $max || $max == 'maximum' ) {
589
+					$price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : '';
590
+					if ($price >= $min || $min == 'minimum') {
591
+						if ($price <= $max || $max == 'maximum') {
592 592
 							$post_id_list[] = $item->ID;
593 593
 						}
594 594
 					}
595 595
 				}
596
-				if( empty($post_id_list) ) {
596
+				if (empty($post_id_list)) {
597 597
 					$post_id_list[] = 'no_result';
598 598
 				}
599 599
 				$query->query_vars[$check] = $post_id_list;
@@ -604,66 +604,66 @@  discard block
 block discarded – undo
604 604
 
605 605
 
606 606
 
607
-	function latest_products_ordered ( $orders ) {
607
+	function latest_products_ordered($orders) {
608 608
 		global $wpdb;
609 609
 		$product_id = $output = '';
610 610
 		$products = array();
611 611
 		$display_option = get_option('wpshop_display_option');
612
-		if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) {
613
-			foreach( $orders as $order ) {
614
-				$order_content = get_post_meta( $order->ID, '_order_postmeta', true );
615
-				if ( !empty($order_content) && !empty( $order_content['order_items']) ) {
612
+		if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) {
613
+			foreach ($orders as $order) {
614
+				$order_content = get_post_meta($order->ID, '_order_postmeta', true);
615
+				if (!empty($order_content) && !empty($order_content['order_items'])) {
616 616
 
617
-					foreach( $order_content['order_items'] as $item ) {
618
-						if ( count( $products) >= $display_option['latest_products_ordered'] ) {
617
+					foreach ($order_content['order_items'] as $item) {
618
+						if (count($products) >= $display_option['latest_products_ordered']) {
619 619
 							continue;
620 620
 						}
621 621
 						$product_id = $item['item_id'];
622
-						if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) {
623
-							$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );
624
-							if ( !empty( $parent_def ) ) {
622
+						if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) {
623
+							$parent_def = wpshop_products::get_parent_variation($item['item_id']);
624
+							if (!empty($parent_def)) {
625 625
 								$parent_post = $parent_def['parent_post'];
626 626
 								$product_id = $parent_post->ID;
627 627
 							}
628 628
 						}
629 629
 
630
-						if ( !in_array($product_id, $products) ) {
630
+						if (!in_array($product_id, $products)) {
631 631
 							$products[] = $product_id;
632 632
 						}
633 633
 					}
634 634
 				}
635 635
 			}
636
-			if ( !empty($products) ) {
636
+			if (!empty($products)) {
637 637
 				$products_id = implode(",", $products);
638
-				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) );
638
+				$output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]')));
639 639
 			}
640 640
 		}
641 641
 		return $output;
642 642
 	}
643 643
 
644
-	function get_order_list_for_customer( $customer_id ) {
644
+	function get_order_list_for_customer($customer_id) {
645 645
 		global $wpdb;
646 646
 		$output = '';
647 647
 
648
-		if( !empty($customer_id) ) {
649
-			 $query = $wpdb->prepare( 'SELECT *
650
-							 		   FROM ' .$wpdb->posts. '
648
+		if (!empty($customer_id)) {
649
+			 $query = $wpdb->prepare('SELECT *
650
+							 		   FROM ' .$wpdb->posts . '
651 651
 							 		   WHERE post_author = %d
652
-							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS );
653
-			 $orders = $wpdb->get_results( $query );
652
+							 		   AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS);
653
+			 $orders = $wpdb->get_results($query);
654 654
 
655
-			 foreach( $orders as $order ) {
655
+			 foreach ($orders as $order) {
656 656
 
657 657
 			 }
658 658
 		}
659 659
 
660 660
 		return $output;
661 661
 	}
662
-	static function display_customer_pay_quotation( $state, $oid ) {
663
-		$btn = '<a role="button" class="wps-bton-' . ( ( $state ) ? 'third' : 'second' ) . '-mini-rounded quotation_is_payable_by_customer" href="#" >'.__('Customer can pay', 'wpshop').'</a>';
664
-		if( $state ) {
665
-			$url = wp_nonce_url( admin_url( 'admin-ajax.php?action=wps_checkout_quotation&order_id=' . $oid . '&is_link=link' ), 'wps_checkout_quotation', '_wpnonce' );
666
-			$btn .= '<br><a href="' . $url . '">' . __( 'Pay link', 'wpshop' ) . '</a>';
662
+	static function display_customer_pay_quotation($state, $oid) {
663
+		$btn = '<a role="button" class="wps-bton-' . (($state) ? 'third' : 'second') . '-mini-rounded quotation_is_payable_by_customer" href="#" >' . __('Customer can pay', 'wpshop') . '</a>';
664
+		if ($state) {
665
+			$url = wp_nonce_url(admin_url('admin-ajax.php?action=wps_checkout_quotation&order_id=' . $oid . '&is_link=link'), 'wps_checkout_quotation', '_wpnonce');
666
+			$btn .= '<br><a href="' . $url . '">' . __('Pay link', 'wpshop') . '</a>';
667 667
 		}
668 668
 		return $btn;
669 669
 	}
Please login to merge, or discard this patch.
includes/modules/billing/billing.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 
865 865
 		/**
866 866
 		 * Generate Sender part invoice template
867
-		 * @return Ambigous <string, string>
867
+		 * @return string <string, string>
868 868
 		 */
869 869
 		public static function generate_invoice_sender_part() {
870 870
 			$output ='';
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 		 * Generate Receiver part template
910 910
 		 * @param unknown_type $order_id
911 911
 		 * @param unknown_type $bon_colisage
912
-		 * @return Ambigous <string, string>
912
+		 * @return string <string, string>
913 913
 		 */
914 914
 		public static function generate_receiver_part( $order_id, $bon_colisage = false ) {
915 915
 			$output = '';
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 
967 967
 		/**
968 968
 		 * Genrate Footer invoice
969
-		 * @return Ambigous <string, string>
969
+		 * @return string <string, string>
970 970
 		 */
971 971
 		public static function generate_footer_invoice(){
972 972
 			$output ='';
@@ -1012,6 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 		 * @param float $tva_rate
1013 1013
 		 * @param id $product_id
1014 1014
 		 * @param string $invoice_ref
1015
+		 * @param integer $order_id
1015 1016
 		 */
1016 1017
 		public static function check_product_price( $price_ht, $price_ati, $tva_amount, $tva_rate, $product_id, $invoice_ref, $order_id ) {
1017 1018
 			$checking = true;
Please login to merge, or discard this patch.
Spacing   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -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
 	/**
15 15
 	 * Billing module utilities definition
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 		 */
26 26
 		function __construct() {
27 27
 			/**	Add custom template for current module	*/
28
-			add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) );
28
+			add_filter('wpshop_custom_template', array(&$this, 'custom_template_load'));
29 29
 
30 30
 			/**	In case wpshop is set on sale mode and not on view catalog only, Ad billign options	*/
31
-			if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) {
32
-				$wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : '';
33
-				$old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : '';
31
+			if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') {
32
+				$wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : '';
33
+				$old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : '';
34 34
 
35
-				if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' )
36
-					&& ( $old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation' ) ) {
35
+				if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation')
36
+					&& ($old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation')) {
37 37
 						/**	Add module option to wpshop general options	*/
38 38
 						add_filter('wpshop_options', array(&$this, 'add_options'), 9);
39 39
 						add_action('wsphop_options', array(&$this, 'declare_options'), 8);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			}
42 42
 
43 43
 			// Filter
44
-			add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'force_invoice_generation_on_order'), 50, 2 );
44
+			add_filter('wps_order_saving_admin_extra_action', array($this, 'force_invoice_generation_on_order'), 50, 2);
45 45
 		}
46 46
 
47 47
 		/**
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 		 *
52 52
 		 * @return array The template with new elements
53 53
 		 */
54
-		function custom_template_load( $templates ) {
54
+		function custom_template_load($templates) {
55 55
 			include('templates/common/main_elements.tpl.php');
56 56
 			$wpshop_template = $tpl_element;
57 57
 			/*	Get custom frontend template	*/
58
-			if ( is_file(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php') ) {
58
+			if (is_file(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php')) {
59 59
 				require_once(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php');
60 60
 				if (!empty($tpl_element))
61
-					$wpshop_template['common']['custom'] = ($tpl_element);unset($tpl_element);
61
+					$wpshop_template['common']['custom'] = ($tpl_element); unset($tpl_element);
62 62
 			}
63 63
 			$wpshop_display = new wpshop_display();
64
-			$templates = $wpshop_display->add_modules_template_to_internal( $wpshop_template, $templates );
64
+			$templates = $wpshop_display->add_modules_template_to_internal($wpshop_template, $templates);
65 65
 
66 66
 			unset($tpl_element);
67 67
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 		/**
72 72
 		 * Declare option groups for the module
73 73
 		 */
74
-		function add_options( $option_group ) {
74
+		function add_options($option_group) {
75 75
 			$option_group['wpshop_billing_info'] =
76
-				array(	'label' => __('Billing', 'wpshop'),
76
+				array('label' => __('Billing', 'wpshop'),
77 77
 						'subgroups' => array(
78 78
 							'wpshop_billing_info' => array('class' => ' wpshop_admin_box_options_billing'),
79 79
 						),
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 * Declare the different options in groups for the module
87 87
 		 */
88 88
 		function declare_options() {
89
-			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
+			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');
90 90
 
91 91
 			register_setting('wpshop_options', 'wpshop_billing_number_figures', array(&$this, 'wpshop_options_validate_billing_number_figures'));
92 92
 			add_settings_field('wpshop_billing_number_figures', __('Number of figures', 'wpshop'), array(&$this, 'wpshop_billing_number_figures_field'), 'wpshop_billing_info', 'wpshop_billing_info');
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
 			add_settings_field('wpshop_billing_address_choice', __('Billing address choice', 'wpshop'), array(&$this, 'wpshop_billing_address_choice_field'), 'wpshop_billing_info', 'wpshop_billing_info');
96 96
 			add_settings_field('wpshop_billing_address_include_into_register', '', array(&$this, 'wpshop_billing_address_include_into_register_field'), 'wpshop_billing_info', 'wpshop_billing_info');
97 97
 
98
-			$quotation_option = get_option( 'wpshop_addons' );
99
-			if ( !empty($quotation_option) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']['activate']) ) {
100
-				add_settings_section('wpshop_quotation_info', '<span class="dashicons dashicons-clipboard"></span>' .__('Quotation settings', 'wpshop'), array(&$this, 'quotation_options_main_explanation'), 'wpshop_billing_info');
98
+			$quotation_option = get_option('wpshop_addons');
99
+			if (!empty($quotation_option) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']['activate'])) {
100
+				add_settings_section('wpshop_quotation_info', '<span class="dashicons dashicons-clipboard"></span>' . __('Quotation settings', 'wpshop'), array(&$this, 'quotation_options_main_explanation'), 'wpshop_billing_info');
101 101
 
102 102
 				register_setting('wpshop_options', 'wpshop_quotation_validate_time', array(&$this, 'wpshop_options_validate_quotation_validate_time'));
103 103
 				add_settings_field('wpshop_quotation_validate_time', __('Quotation validate time', 'wpshop'), array(&$this, 'wpshop_quotation_validate_time_field'), 'wpshop_billing_info', 'wpshop_quotation_info');
104 104
 				$payment_option = get_option('wps_payment_mode');
105
-				if ( !empty($payment_option) && !empty($payment_option['mode']) && !empty($payment_option['mode']['banktransfer']) && !empty($payment_option['mode']['banktransfer']['active']) ) {
105
+				if (!empty($payment_option) && !empty($payment_option['mode']) && !empty($payment_option['mode']['banktransfer']) && !empty($payment_option['mode']['banktransfer']['active'])) {
106 106
 					register_setting('wpshop_options', 'wpshop_paymentMethod_options[banktransfer][add_in_quotation]', array(&$this, 'wpshop_options_validate_wpshop_bic_to_quotation'));
107 107
 					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');
108 108
 				}
109 109
 				register_setting('wpshop_options', 'wpshop_payment_partial', array(&$this, 'wpshop_quotation_payment_partial_validation'));
110
-				add_settings_field('wpshop_payment_partial', __( 'Quotation partial payment'), array(&$this, 'wpshop_quotation_payment_partial'), 'wpshop_billing_info', 'wpshop_quotation_info');
110
+				add_settings_field('wpshop_payment_partial', __('Quotation partial payment'), array(&$this, 'wpshop_quotation_payment_partial'), 'wpshop_billing_info', 'wpshop_quotation_info');
111 111
 			}
112 112
 
113 113
 		}
114 114
 
115
-		function wpshop_options_validate_wpshop_bic_to_quotation ($input) {
115
+		function wpshop_options_validate_wpshop_bic_to_quotation($input) {
116 116
 			return $input;
117 117
 		}
118 118
 
119
-		function wpshop_bic_to_quotation_field () {
119
+		function wpshop_bic_to_quotation_field() {
120 120
 			$add_quotation_option = get_option('wpshop_paymentMethod_options');
121
-			$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
+			$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"' : '') . ' />';
122 122
 			echo $output;
123 123
 		}
124 124
 
@@ -129,44 +129,44 @@  discard block
 block discarded – undo
129 129
 
130 130
 		}
131 131
 
132
-		function wpshop_options_validate_quotation_validate_time ($input) {
132
+		function wpshop_options_validate_quotation_validate_time($input) {
133 133
 			return $input;
134 134
 		}
135 135
 
136 136
 		function wpshop_billing_number_figures_field() {
137 137
 			$wpshop_billing_number_figures = get_option('wpshop_billing_number_figures');
138
-			$readonly = !empty($wpshop_billing_number_figures) ? 'readonly="readonly"': null;
139
-			if(empty($wpshop_billing_number_figures)) $wpshop_billing_number_figures=5;
138
+			$readonly = !empty($wpshop_billing_number_figures) ? 'readonly="readonly"' : null;
139
+			if (empty($wpshop_billing_number_figures)) $wpshop_billing_number_figures = 5;
140 140
 
141
-			echo '<input name="wpshop_billing_number_figures" type="text" value="'.$wpshop_billing_number_figures.'" '.$readonly.' />
142
-		<a href="#" title="'.__('Number of figures to make appear on invoices','wpshop').'" class="wpshop_infobulle_marker">?</a>';
141
+			echo '<input name="wpshop_billing_number_figures" type="text" value="' . $wpshop_billing_number_figures . '" ' . $readonly . ' />
142
+		<a href="#" title="'.__('Number of figures to make appear on invoices', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
143 143
 		}
144 144
 
145
-		function wpshop_options_validate_billing_number_figures( $input ) {
145
+		function wpshop_options_validate_billing_number_figures($input) {
146 146
 			return $input;
147 147
 		}
148 148
 
149
-		function wpshop_billing_address_validator( $input ){
149
+		function wpshop_billing_address_validator($input) {
150 150
 			global $wpdb;
151
-			$t = wps_address::get_addresss_form_fields_by_type ( $input['choice'] );
151
+			$t = wps_address::get_addresss_form_fields_by_type($input['choice']);
152 152
 
153 153
 			$the_code = '';
154
-			foreach( $t[$input['choice']] as $group_id => $group_def ) {
155
-				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']) ) {
154
+			foreach ($t[$input['choice']] as $group_id => $group_def) {
155
+				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'])) {
156 156
 					$the_code = $group_def['content'][$input['integrate_into_register_form_matching_field']['user_email']]['name'];
157 157
 					continue;
158 158
 				}
159 159
 			}
160 160
 			$the_code;
161 161
 
162
-			if ( !empty($input['integrate_into_register_form']) && $input['integrate_into_register_form'] == 'yes' ) {
163
-				if ( !empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && $the_code == 'address_user_email') {
162
+			if (!empty($input['integrate_into_register_form']) && $input['integrate_into_register_form'] == 'yes') {
163
+				if (!empty($input['integrate_into_register_form_matching_field']) && !empty($input['integrate_into_register_form_matching_field']['user_email']) && $the_code == 'address_user_email') {
164 164
 					$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('_need_verification' => 'no'), array('code' => $the_code));
165 165
 				}
166 166
 			}
167 167
 
168
-			$billing_option = get_option( 'wpshop_billing_address' );
169
-			if( !empty($billing_option) && !empty( $billing_option['display_model'] ) ) {
168
+			$billing_option = get_option('wpshop_billing_address');
169
+			if (!empty($billing_option) && !empty($billing_option['display_model'])) {
170 170
 				$input['display_model'] = $billing_option['display_model'];
171 171
 			}
172 172
 
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 
180 180
 			$wpshop_billing_address = get_option('wpshop_billing_address');
181 181
 
182
-			$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
+			$query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_name = "%s" AND post_type = "%s"', WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS, WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES);
183 183
 			$entity_id = $wpdb->get_var($query);
184 184
 
185
-			$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id);
185
+			$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id);
186 186
 			$content = $wpdb->get_results($query);
187 187
 
188 188
 			/*	Field for billing address type choice	*/
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
 			$input_def['possible_value'] = $content;
192 192
 			$input_def['type'] = 'select';
193 193
 			$input_def['value'] = $wpshop_billing_address['choice'];
194
-			$output .= '<div>' .wpshop_form::check_input_type($input_def). '</div>';
194
+			$output .= '<div>' . wpshop_form::check_input_type($input_def) . '</div>';
195 195
 
196 196
 			/*	Field for integrate billign form into register form	*/
197 197
 			$input_def = array();
198 198
 			$input_def['name'] = 'wpshop_billing_address[integrate_into_register_form]';
199 199
 			$input_def['id'] = 'wpshop_billing_address_integrate_into_register_form';
200
-			$input_def['possible_value'] = array( 'yes' => __('Integrate billing form into register form', 'wpshop') );
200
+			$input_def['possible_value'] = array('yes' => __('Integrate billing form into register form', 'wpshop'));
201 201
 			$input_def['valueToPut'] = 'index';
202 202
 			$input_def['options_label']['original'] = true;
203 203
 			$input_def['option'] = ' class="wpshop_billing_address_integrate_into_register_form" ';
204 204
 			$input_def['type'] = 'checkbox';
205
-			$input_def['value'] = array( !empty($wpshop_billing_address['integrate_into_register_form']) ? $wpshop_billing_address['integrate_into_register_form'] : '' );
205
+			$input_def['value'] = array(!empty($wpshop_billing_address['integrate_into_register_form']) ? $wpshop_billing_address['integrate_into_register_form'] : '');
206 206
 			$output .= '
207 207
 <div class="wpshop_include_billing_form_into_register_container" >
208
-	' .wpshop_form::check_input_type($input_def). '
208
+	' .wpshop_form::check_input_type($input_def) . '
209 209
 	<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') . '" />
210 210
 	<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'] : '') . '" />
211 211
 	<div class="wpshop_include_billing_form_into_register_where" ></div>
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
 
219 219
 		}
220 220
 
221
-		function wpshop_quotation_validate_time_field () {
221
+		function wpshop_quotation_validate_time_field() {
222 222
 			$quotation_option = get_option('wpshop_quotation_validate_time');
223
-			$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
+			$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) . '" />';
224 224
 			$output .= '<select name="wpshop_quotation_validate_time[time_type]" id="wpshop_quotation_validate_time[time_type]">';
225
-			$output .= '<option value="day" ' .( (  !empty($quotation_option) && !empty($quotation_option['time_type']) &&  $quotation_option['time_type'] == 'day') ? 'selected="selected"' : ''). '>' .__('Days', 'wpshop'). '</option>';
226
-			$output .= '<option value="month" ' .( (  !empty($quotation_option) && !empty($quotation_option['time_type']) &&  $quotation_option['time_type'] == 'month') ? 'selected="selected"' : ''). '>' .__('Months', 'wpshop'). '</option>';
227
-			$output .= '<option value="year" ' .( (  !empty($quotation_option) && !empty($quotation_option['time_type']) &&  $quotation_option['time_type'] == 'year') ? 'selected="selected"' : ''). '>' .__('Years', 'wpshop'). '</option>';
225
+			$output .= '<option value="day" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'day') ? 'selected="selected"' : '') . '>' . __('Days', 'wpshop') . '</option>';
226
+			$output .= '<option value="month" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'month') ? 'selected="selected"' : '') . '>' . __('Months', 'wpshop') . '</option>';
227
+			$output .= '<option value="year" ' . ((!empty($quotation_option) && !empty($quotation_option['time_type']) && $quotation_option['time_type'] == 'year') ? 'selected="selected"' : '') . '>' . __('Years', 'wpshop') . '</option>';
228 228
 			$output .= '</select>';
229 229
 
230 230
 			echo $output;
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
 		 *
238 238
 		 * @return string The new invoice number
239 239
 		 */
240
-		public static function generate_invoice_number( $order_id ) {
240
+		public static function generate_invoice_number($order_id) {
241 241
 			/**	Get configuration about the number of figure dor invoice number	*/
242 242
 
243 243
 			$number_figures = get_option('wpshop_billing_number_figures', false);
244 244
 
245 245
 			/** If the number doesn't exist, we create a default one */
246
-			if(!$number_figures) {
246
+			if (!$number_figures) {
247 247
 				update_option('wpshop_billing_number_figures', 5);
248 248
 			}
249 249
 
250 250
 			/** sleep my script, SLEEP I SAY ! **/
251
-			$rand_time = rand( 1000, 200000 );
252
-			usleep( $rand_time );
251
+			$rand_time = rand(1000, 200000);
252
+			usleep($rand_time);
253 253
 			/** GET UP !! **/
254 254
 
255 255
 			/**	Get last invoice number	*/
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 			/** Check if number exists **/
267 267
 			$billing_current_number_checking = get_option('wpshop_billing_current_number', false);
268
-			if ( $billing_current_number_checking == $billing_current_number ) {
268
+			if ($billing_current_number_checking == $billing_current_number) {
269 269
 				$billing_current_number++;
270 270
 			}
271 271
 
272 272
 			update_option('wpshop_billing_current_number', $billing_current_number);
273 273
 
274 274
 			/**	Create the new invoice number with all parameters viewed above	*/
275
-			$invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string)sprintf('%0'.$number_figures.'d', $billing_current_number));
275
+			$invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string)sprintf('%0' . $number_figures . 'd', $billing_current_number));
276 276
 
277 277
 			return $invoice_ref;
278 278
 		}
@@ -286,67 +286,67 @@  discard block
 block discarded – undo
286 286
 		 *
287 287
 		 * @return string The invoice output in case no error is found. The error in other case
288 288
 		 */
289
-		public static function generate_html_invoice( $order_id, $invoice_ref ) {
289
+		public static function generate_html_invoice($order_id, $invoice_ref) {
290 290
 			global $wpdb;
291 291
 
292
-			$date_output_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
292
+			$date_output_format = get_option('date_format') . ' ' . get_option('time_format');
293 293
 			$count_products = 0;
294 294
 
295
-			if ( !empty($order_id) ) {
295
+			if (!empty($order_id)) {
296 296
 				$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
297 297
 
298 298
 				$discounts_exists = false;
299 299
 
300
-				$is_quotation = ( empty($order_postmeta['order_key']) && !empty($order_postmeta['order_temporary_key']) ) ? true : false;
300
+				$is_quotation = (empty($order_postmeta['order_key']) && !empty($order_postmeta['order_temporary_key'])) ? true : false;
301 301
 				/** Check if it's a partial payment bill **/
302 302
 				$is_partial_payment = false;
303
-				if( isset( $order_postmeta['order_payment']['received'] ) && !empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid' ) {
304
-					foreach( $order_postmeta['order_payment']['received'] as $key => $payment ) {
305
-						if( isset( $payment['invoice_ref'] ) && $payment['invoice_ref'] == $invoice_ref ) {
303
+				if (isset($order_postmeta['order_payment']['received']) && !empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid') {
304
+					foreach ($order_postmeta['order_payment']['received'] as $key => $payment) {
305
+						if (isset($payment['invoice_ref']) && $payment['invoice_ref'] == $invoice_ref) {
306 306
 							$is_partial_payment = true;
307 307
 							break;
308 308
 						}
309 309
 					}
310
-				} elseif( !empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref'])  && $order_postmeta['order_invoice_ref'] != $invoice_ref ) {
310
+				} elseif (!empty($invoice_ref) && !empty($order_postmeta['order_invoice_ref']) && $order_postmeta['order_invoice_ref'] != $invoice_ref) {
311 311
 					$is_partial_payment = true;
312
-				} elseif( empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid' ) {
312
+				} elseif (empty($invoice_ref) && $order_postmeta['order_status'] == 'partially_paid') {
313 313
 					$is_partial_payment = true;
314 314
 				}
315 315
 
316 316
 				/** Check it is a shipping slip **/
317
-				$bon_colisage = !empty( $_GET['bon_colisage'] ) ? sanitize_key( $_GET['bon_colisage'] ) : false;
318
-				if ( $bon_colisage ) $bon_colisage = true;
317
+				$bon_colisage = !empty($_GET['bon_colisage']) ? sanitize_key($_GET['bon_colisage']) : false;
318
+				if ($bon_colisage) $bon_colisage = true;
319 319
 
320
-				if ( !empty($order_postmeta) ) {
320
+				if (!empty($order_postmeta)) {
321 321
 					$tpl_component = array();
322 322
 
323 323
 					/** Billing Header **/
324 324
 					//Logo
325 325
 					$logo_options = get_option('wpshop_logo');
326
-					$tpl_component['INVOICE_LOGO'] = ( !empty($logo_options) ) ? '<img src="' .$logo_options .'" alt="" />' : '';
326
+					$tpl_component['INVOICE_LOGO'] = (!empty($logo_options)) ? '<img src="' . $logo_options . '" alt="" />' : '';
327 327
 
328 328
 					// Title
329
-					$tpl_component['INVOICE_TITLE'] = ($is_partial_payment) ? __('Bill payment', 'wpshop') : ( ( $is_quotation ) ?  __('Quotation', 'wpshop') : __('Invoice', 'wpshop') );
329
+					$tpl_component['INVOICE_TITLE'] = ($is_partial_payment) ? __('Bill payment', 'wpshop') : (($is_quotation) ? __('Quotation', 'wpshop') : __('Invoice', 'wpshop'));
330 330
 
331 331
 // 					if ( empty($order_postmeta['order_invoice_ref']) ) {
332 332
 // 						$tpl_component['INVOICE_TITLE'] = __('Bill payment', 'wpshop');
333 333
 // 						$is_partial_payment = true;
334 334
 // 					}
335 335
 
336
-					if ( $bon_colisage ) {
337
-						$tpl_component['INVOICE_TITLE'] = __( 'Products List', 'wpshop' );
336
+					if ($bon_colisage) {
337
+						$tpl_component['INVOICE_TITLE'] = __('Products List', 'wpshop');
338 338
 					}
339 339
 
340
-					$tpl_component['INVOICE_ORDER_INVOICE_REF'] = ( !empty($invoice_ref) ) ? $invoice_ref : (!empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : null);
341
-					if ( $bon_colisage ) {
340
+					$tpl_component['INVOICE_ORDER_INVOICE_REF'] = (!empty($invoice_ref)) ? $invoice_ref : (!empty($order_postmeta['order_invoice_ref']) ? $order_postmeta['order_invoice_ref'] : null);
341
+					if ($bon_colisage) {
342 342
 						$tpl_component['INVOICE_ORDER_INVOICE_REF'] = '';
343 343
 					}
344
-					$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'] );
345
-					$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) );
344
+					$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']);
345
+					$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));
346 346
 
347 347
 					/** Validate period for Quotation **/
348
-					if ( $is_quotation ) {
349
-						$quotation_validate_period = self::quotation_validate_period( $order_postmeta['order_date'] );
348
+					if ($is_quotation) {
349
+						$quotation_validate_period = self::quotation_validate_period($order_postmeta['order_date']);
350 350
 					}
351 351
 					else {
352 352
 						$tpl_component['INVOICE_VALIDATE_TIME'] = '';
@@ -354,22 +354,22 @@  discard block
 block discarded – undo
354 354
 
355 355
 					$tpl_component['INVOICE_VALIDATE_TIME'] = empty($tpl_component['INVOICE_VALIDATE_TIME']) ? '' : $tpl_component['INVOICE_VALIDATE_TIME'];
356 356
 
357
-					$tpl_component['AMOUNT_INFORMATION'] = ( !$bon_colisage ) ? sprintf( __('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency( true ) ) : '';
357
+					$tpl_component['AMOUNT_INFORMATION'] = (!$bon_colisage) ? sprintf(__('Amount are shown in %s', 'wpshop'), wpshop_tools::wpshop_get_currency(true)) : '';
358 358
 
359 359
 
360 360
 
361 361
 					// Sender & receiver addresses
362 362
 					$tpl_component['INVOICE_SENDER'] = self::generate_invoice_sender_part( );
363
-					$tpl_component['INVOICE_RECEIVER'] = self::generate_receiver_part( $order_id, $bon_colisage );
363
+					$tpl_component['INVOICE_RECEIVER'] = self::generate_receiver_part($order_id, $bon_colisage);
364 364
 
365 365
 					$tpl_component['INVOICE_TRACKING'] = '';
366 366
 					$first = false;
367
-					if( !empty($order_postmeta['order_trackingNumber']) ) {
367
+					if (!empty($order_postmeta['order_trackingNumber'])) {
368 368
 						$tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingNumber'];
369 369
 						$first = true;
370 370
 					}
371
-					if( !empty($order_postmeta['order_trackingLink']) ) {
372
-						if( !$first ) {
371
+					if (!empty($order_postmeta['order_trackingLink'])) {
372
+						if (!$first) {
373 373
 							$tpl_component['INVOICE_TRACKING'] = __('Tracking : ', 'wpshop') . $order_postmeta['order_trackingLink'];
374 374
 						} else {
375 375
 							$tpl_component['INVOICE_TRACKING'] .= ' - ' . $order_postmeta['order_trackingLink'];
@@ -379,22 +379,22 @@  discard block
 block discarded – undo
379 379
 
380 380
 					/** Items Tab **/
381 381
 					$order_tva = array();
382
-					if ( $bon_colisage ) {
382
+					if ($bon_colisage) {
383 383
 						$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('bon_colisage_row_header', array(), array(), 'common');
384 384
 					}
385 385
 					else {
386 386
 						$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header', array(), array(), 'common');
387 387
 						//if ( !$is_quotation ) {
388 388
 							/** Check if products have discounts **/
389
-							if ( !empty($order_postmeta['order_items']) && !$is_partial_payment ) {
390
-								foreach( $order_postmeta['order_items'] as $item_id => $item ) {
391
-									if ( !empty($item['item_global_discount_value']) || !empty($item['item_unit_discount_value']) ) {
389
+							if (!empty($order_postmeta['order_items']) && !$is_partial_payment) {
390
+								foreach ($order_postmeta['order_items'] as $item_id => $item) {
391
+									if (!empty($item['item_global_discount_value']) || !empty($item['item_unit_discount_value'])) {
392 392
 										$discounts_exists = true;
393 393
 									}
394 394
 								}
395 395
 							}
396 396
 
397
-							if ( $discounts_exists ) {
397
+							if ($discounts_exists) {
398 398
 								$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header_with_discount', array(), array(), 'common');
399 399
 							}
400 400
 
@@ -404,113 +404,113 @@  discard block
 block discarded – undo
404 404
 					$total_discounted = 0;
405 405
 					$tpl_component['INVOICE_ROWS'] = '';
406 406
 
407
-					if( !$is_partial_payment ) {
408
-						if ( !empty($order_postmeta['order_items']) ) {
409
-							foreach( $order_postmeta['order_items'] as $item_id => $item ) {
407
+					if (!$is_partial_payment) {
408
+						if (!empty($order_postmeta['order_items'])) {
409
+							foreach ($order_postmeta['order_items'] as $item_id => $item) {
410 410
 								$sub_tpl_component = array();
411 411
 								$count_products += $item['item_qty'];
412
-								$barcode = get_post_meta( $item['item_id'], '_barcode', true );
413
-								if ( empty($barcode) ) {
414
-									$product_metadata = get_post_meta( $item['item_id'], '_wpshop_product_metadata', true );
415
-									$barcode = ( !empty($product_metadata) && !empty($product_metadata['barcode']) ) ? $product_metadata['barcode'] : '';
416
-
417
-									if( empty($barcode) ) {
418
-										$product_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT );
419
-										$att_def = wpshop_attributes::getElement( 'barcode', '"valid"', 'code' );
420
-										$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'] );
421
-										$barcode = $wpdb->get_var( $query );
412
+								$barcode = get_post_meta($item['item_id'], '_barcode', true);
413
+								if (empty($barcode)) {
414
+									$product_metadata = get_post_meta($item['item_id'], '_wpshop_product_metadata', true);
415
+									$barcode = (!empty($product_metadata) && !empty($product_metadata['barcode'])) ? $product_metadata['barcode'] : '';
416
+
417
+									if (empty($barcode)) {
418
+										$product_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
419
+										$att_def = wpshop_attributes::getElement('barcode', '"valid"', 'code');
420
+										$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']);
421
+										$barcode = $wpdb->get_var($query);
422 422
 									}
423 423
 								}
424
-								$sub_tpl_component['INVOICE_ROW_ITEM_BARCODE'] = ( !empty($barcode) ) ? $barcode : '-';
424
+								$sub_tpl_component['INVOICE_ROW_ITEM_BARCODE'] = (!empty($barcode)) ? $barcode : '-';
425 425
 
426
-								$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = ( !empty($barcode) ) ? $barcode : $item['item_ref'];
426
+								$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = (!empty($barcode)) ? $barcode : $item['item_ref'];
427 427
 
428 428
 								/** Item name **/
429 429
 								$is_variation = false;
430
-								if( get_post_type( $item['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) {
430
+								if (get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) {
431 431
 									$is_variation = true;
432
-									$parent_def = wpshop_products::get_parent_variation( $item['item_id'] );
433
-									if( !empty($parent_def) && !empty($parent_def['parent_post']) ) {
432
+									$parent_def = wpshop_products::get_parent_variation($item['item_id']);
433
+									if (!empty($parent_def) && !empty($parent_def['parent_post'])) {
434 434
 										$parent_post = $parent_def['parent_post'];
435 435
 										$item_parent_id = $parent_post->ID;
436
-										$item_title =  $parent_post->post_title;
436
+										$item_title = $parent_post->post_title;
437 437
 									}
438 438
 								} else {
439 439
 									$item_title = $item['item_name'];
440 440
 								}
441 441
 								$sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = $item_title;
442 442
 								/**	Get attribute order for current product	*/
443
-								$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails( get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true)  ) ;
443
+								$product_attribute_order_detail = wpshop_attributes_set::getAttributeSetDetails(get_post_meta($item['item_id'], WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY, true));
444 444
 								$output_order = array();
445
-								if ( count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail) ) {
446
-									foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
447
-										foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
448
-											if ( !empty($attribute_def->code) )
445
+								if (count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail)) {
446
+									foreach ($product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
447
+										foreach ($product_attr_group_detail['attribut'] as $position => $attribute_def) {
448
+											if (!empty($attribute_def->code))
449 449
 												$output_order[$attribute_def->code] = $position;
450 450
 										}
451 451
 									}
452 452
 								}
453
-								$variation_attribute_ordered = wpshop_products::get_selected_variation_display( $item['item_meta'], $output_order, 'invoice_print', 'common');
453
+								$variation_attribute_ordered = wpshop_products::get_selected_variation_display($item['item_meta'], $output_order, 'invoice_print', 'common');
454 454
 								ksort($variation_attribute_ordered['attribute_list']);
455 455
 								$detail_tpl_component['CART_PRODUCT_MORE_INFO'] = '';
456
-								foreach ( $variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output ) {
456
+								foreach ($variation_attribute_ordered['attribute_list'] as $attribute_variation_to_output) {
457 457
 									$detail_tpl_component['CART_PRODUCT_MORE_INFO'] .= $attribute_variation_to_output;
458 458
 								}
459 459
 								$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') : '';
460
-								unset( $detail_tpl_component );
460
+								unset($detail_tpl_component);
461 461
 
462 462
 								$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = $item['item_qty'];
463
-								$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, '.', '' ) );
464
-								$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, '.', '' ) );
465
-								$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] =  ( !empty($item['item_discount_value']) )  ?  number_format($item['item_discount_value'], 2, '.', '') : number_format(0, 2, '.', '' );
466
-								$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] =  number_format( ($item['item_pu_ht'] * $item['item_qty']), 2, '.', '' );
463
+								$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, '.', ''));
464
+								$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, '.', ''));
465
+								$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = (!empty($item['item_discount_value'])) ? number_format($item['item_discount_value'], 2, '.', '') : number_format(0, 2, '.', '');
466
+								$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format(($item['item_pu_ht'] * $item['item_qty']), 2, '.', '');
467 467
 								/** TVA **/
468
-								$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format($item['item_tva_total_amount'], 2, '.', '' );
468
+								$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format($item['item_tva_total_amount'], 2, '.', '');
469 469
 								$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = $item['item_tva_rate'];
470 470
 
471 471
 
472
-								$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format( $item['item_total_ttc'], 2, '.', '' );
472
+								$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($item['item_total_ttc'], 2, '.', '');
473 473
 
474 474
 
475 475
 								/** Checking Rate amount **/
476
-								if ( !$bon_colisage ) {
477
-								 $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 );
478
-								 if( !$checking ) {
476
+								if (!$bon_colisage) {
477
+								 $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);
478
+								 if (!$checking) {
479 479
 								 	return __('Invoice cannot be generate because an error was found. The website administrator has been warned.', 'wpshop');
480 480
 								 }
481 481
 								}
482 482
 
483
-								if ( $bon_colisage ) {
483
+								if ($bon_colisage) {
484 484
 									$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('bon_colisage_row', $sub_tpl_component, array(), 'common');
485 485
 								}
486 486
 								else {
487
-									if ( $discounts_exists ) {
487
+									if ($discounts_exists) {
488 488
 										$discounted_total_per_item = $item['item_total_ht'];
489 489
 										/** Unit Discount **/
490
-										if ( !empty($item['item_unit_discount_amount']) && !empty($item['item_unit_discount_value']) ) {
491
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( $item['item_unit_discount_amount'], 2, '.', '');
492
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( $item['item_unit_discount_value'], 2, '.', '');
490
+										if (!empty($item['item_unit_discount_amount']) && !empty($item['item_unit_discount_value'])) {
491
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format($item['item_unit_discount_amount'], 2, '.', '');
492
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format($item['item_unit_discount_value'], 2, '.', '');
493 493
 											$discounted_total_per_item = $discounted_total_per_item - $item['item_unit_discount_amount'];
494 494
 										}
495 495
 										else {
496
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
497
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
496
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
497
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', '');
498 498
 										}
499 499
 
500 500
 										/** Global Discount **/
501
-										if ( !empty($item['item_global_discount_amount']) && !empty($item['item_global_discount_value']) ) {
502
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( $item['item_global_discount_amount'], 2, '.', '');
503
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( $item['item_global_discount_value'], 2, '.', '');
501
+										if (!empty($item['item_global_discount_amount']) && !empty($item['item_global_discount_value'])) {
502
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format($item['item_global_discount_amount'], 2, '.', '');
503
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format($item['item_global_discount_value'], 2, '.', '');
504 504
 											$discounted_total_per_item = $discounted_total_per_item - $item['item_global_discount_amount'];
505 505
 										}
506 506
 										else {
507
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
508
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
507
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
508
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', '');
509 509
 										}
510 510
 
511 511
 										$total_discounted += $discounted_total_per_item;
512 512
 										/** Total HT Discounted **/
513
-										$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format( $discounted_total_per_item, 2, '.', '');
513
+										$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format($discounted_total_per_item, 2, '.', '');
514 514
 
515 515
 										$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common');
516 516
 									}
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
 										$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common');
519 519
 									}
520 520
 								}
521
-								unset( $sub_tpl_component );
521
+								unset($sub_tpl_component);
522 522
 
523 523
 								/** Check TVA **/
524
-								if ( empty($order_tva[ $item['item_tva_rate'] ]) ) {
525
-									$order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount'];
524
+								if (empty($order_tva[$item['item_tva_rate']])) {
525
+									$order_tva[$item['item_tva_rate']] = $item['item_tva_total_amount'];
526 526
 								}
527 527
 								else {
528
-									$order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount'];
528
+									$order_tva[$item['item_tva_rate']] += $item['item_tva_total_amount'];
529 529
 								}
530 530
 
531 531
 							}
@@ -536,33 +536,33 @@  discard block
 block discarded – undo
536 536
 
537 537
 						/** Display Partials payments **/
538 538
 						$total_partial_payment = 0; $last_payment = 0;
539
-						$order_invoice_ref = ( !empty($order_postmeta['order_invoice_ref']) ) ? $order_postmeta['order_invoice_ref'] : '';
540
-						if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage ) {
541
-							foreach( $order_postmeta['order_payment']['received'] as $received_payment ) {
542
-								if ( !empty($received_payment['invoice_ref']) && $received_payment['invoice_ref'] != $order_invoice_ref ) {
543
-									if ( intval( substr($received_payment['invoice_ref'], 2) ) == intval( substr($tpl_component['INVOICE_ORDER_INVOICE_REF'], 2) )) {
539
+						$order_invoice_ref = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : '';
540
+						if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) {
541
+							foreach ($order_postmeta['order_payment']['received'] as $received_payment) {
542
+								if (!empty($received_payment['invoice_ref']) && $received_payment['invoice_ref'] != $order_invoice_ref) {
543
+									if (intval(substr($received_payment['invoice_ref'], 2)) == intval(substr($tpl_component['INVOICE_ORDER_INVOICE_REF'], 2))) {
544 544
 										$sub_tpl_component = array();
545 545
 										$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref'];
546 546
 
547 547
 										/** Item name **/
548
-										$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']);
548
+										$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']);
549 549
 										$sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = '';
550 550
 										$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1;
551
-										$sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' );
552
-										$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] =  number_format(0, 2, '.', '' );
553
-										$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' );
551
+										$sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', '');
552
+										$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
553
+										$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = '-' . number_format($received_payment['received_amount'], 2, '.', '');
554 554
 
555 555
 										/** TVA **/
556
-										$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '' );
556
+										$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '');
557 557
 										$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0;
558
-										$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format( $received_payment['received_amount'], 2, '.', '' );
558
+										$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = '-' . number_format($received_payment['received_amount'], 2, '.', '');
559 559
 
560
-										if ( $discounts_exists ) {
561
-											$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = '-'.number_format( $received_payment['received_amount'], 2, '.', '');
562
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
563
-											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
564
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
565
-											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
560
+										if ($discounts_exists) {
561
+											$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = '-' . number_format($received_payment['received_amount'], 2, '.', '');
562
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
563
+											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format(0, 2, '.', '');
564
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
565
+											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format(0, 2, '.', '');
566 566
 
567 567
 											$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common');
568 568
 										}
@@ -571,11 +571,11 @@  discard block
 block discarded – undo
571 571
 										}
572 572
 									}
573 573
 
574
-									unset( $sub_tpl_component );
575
-									$total_partial_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0;
574
+									unset($sub_tpl_component);
575
+									$total_partial_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0;
576 576
 								}
577
-								else if( 'payment_received' == $received_payment[ 'status' ] ) {
578
-									$last_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0;
577
+								else if ('payment_received' == $received_payment['status']) {
578
+									$last_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0;
579 579
 								}
580 580
 
581 581
 							}
@@ -584,24 +584,24 @@  discard block
 block discarded – undo
584 584
 					else {
585 585
 						/** Display Partials payments **/
586 586
 						$total_partial_payment = 0; $last_payment = 0;
587
-						if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage ) {
588
-							foreach( $order_postmeta['order_payment']['received'] as $key => $received_payment ) {
589
-								if ( !empty($received_payment['invoice_ref']) && !empty($invoice_ref) && $received_payment['invoice_ref'] == $invoice_ref ) {
587
+						if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage) {
588
+							foreach ($order_postmeta['order_payment']['received'] as $key => $received_payment) {
589
+								if (!empty($received_payment['invoice_ref']) && !empty($invoice_ref) && $received_payment['invoice_ref'] == $invoice_ref) {
590 590
 									$sub_tpl_component = array();
591 591
 									$sub_tpl_component['INVOICE_ROW_ITEM_REF'] = $received_payment['invoice_ref'];
592 592
 									/** Item name **/
593
-									$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);
593
+									$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);
594 594
 									$sub_tpl_component['INVOICE_ROW_ITEM_DETAIL'] = '';
595 595
 									$sub_tpl_component['INVOICE_ROW_ITEM_QTY'] = 1;
596
-									$sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = number_format( $received_payment['received_amount'], 2, '.', '' );
597
-									$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '' );
598
-									$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format( $received_payment['received_amount'], 2, '.', '' );
596
+									$sub_tpl_component['INVOICE_ROW_ITEM_PU_HT'] = number_format($received_payment['received_amount'], 2, '.', '');
597
+									$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNT_AMOUNT'] = number_format(0, 2, '.', '');
598
+									$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_HT'] = number_format($received_payment['received_amount'], 2, '.', '');
599 599
 									/** TVA **/
600
-									$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '' );
600
+									$sub_tpl_component['INVOICE_ROW_ITEM_TVA_TOTAL_AMOUNT'] = number_format(0, 2, '.', '');
601 601
 									$sub_tpl_component['INVOICE_ROW_ITEM_TVA_RATE'] = 0;
602
-									$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format( $received_payment['received_amount'], 2, '.', '' );
602
+									$sub_tpl_component['INVOICE_ROW_ITEM_TOTAL_TTC'] = number_format($received_payment['received_amount'], 2, '.', '');
603 603
 									$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common');
604
-									unset( $sub_tpl_component );
604
+									unset($sub_tpl_component);
605 605
 									$total_partial_payment += $received_payment['received_amount'];
606 606
 								}
607 607
 							}
@@ -614,126 +614,126 @@  discard block
 block discarded – undo
614 614
 					/** Summary of order **/
615 615
 					$summary_tpl_component = array();
616 616
 					$tpl_component['INVOICE_SUMMARY_PART'] = $summary_tpl_component['INVOICE_SUMMARY_TAXES'] = '';
617
-					if ( !$bon_colisage ) {
618
-						if ( !empty( $order_tva ) ) {
619
-							foreach( $order_tva as $tax_rate => $tax_amount ) {
620
-								if ( $tax_amount > 0 ) {
621
-									$tax_rate = ( !empty($tax_rate) && $tax_rate == 'VAT_shipping_cost' ) ?  __('on Shipping cost', 'wpshop').' '.WPSHOP_VAT_ON_SHIPPING_COST : $tax_rate;
622
-									$sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf( __('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%' );
617
+					if (!$bon_colisage) {
618
+						if (!empty($order_tva)) {
619
+							foreach ($order_tva as $tax_rate => $tax_amount) {
620
+								if ($tax_amount > 0) {
621
+									$tax_rate = (!empty($tax_rate) && $tax_rate == 'VAT_shipping_cost') ? __('on Shipping cost', 'wpshop') . ' ' . WPSHOP_VAT_ON_SHIPPING_COST : $tax_rate;
622
+									$sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%');
623 623
 									$sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency();
624 624
 									$summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
625
-									unset( $sub_tpl_component );
625
+									unset($sub_tpl_component);
626 626
 								}
627
-								elseif( $is_partial_payment ) {
627
+								elseif ($is_partial_payment) {
628 628
 									$tax_rate = 0;
629
-									$tax_amount = number_format( 0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency();
630
-									$sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf( __('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%' );
629
+									$tax_amount = number_format(0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency();
630
+									$sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf(__('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%');
631 631
 									$sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency();
632 632
 									$summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
633
-									unset( $sub_tpl_component );
633
+									unset($sub_tpl_component);
634 634
 								}
635 635
 							}
636 636
 						}
637 637
 
638 638
 						/** If Discount Exist **/
639 639
 						// Checking Discounts on order
640
-						if( !empty($order_postmeta['order_discount_type']) && $order_postmeta['order_discount_value'] ) {
640
+						if (!empty($order_postmeta['order_discount_type']) && $order_postmeta['order_discount_value']) {
641 641
 							$discounts_exists = true;
642 642
 							// Calcul discount on Order
643
-							switch( $order_postmeta['order_discount_type'] ) {
643
+							switch ($order_postmeta['order_discount_type']) {
644 644
 								case 'amount':
645
-									$total_discounted += number_format( str_replace( ',', '.', $order_postmeta['order_discount_value'] ), 2, '.', '' );
645
+									$total_discounted += number_format(str_replace(',', '.', $order_postmeta['order_discount_value']), 2, '.', '');
646 646
 									break;
647 647
 								case 'percent':
648
-									$total_discounted += number_format( $order_postmeta['order_grand_total_before_discount'], 2, '.', '') * ( number_format( str_replace( ',', '.', $order_postmeta['order_discount_value']), 2, '.', '') / 100 );
648
+									$total_discounted += number_format($order_postmeta['order_grand_total_before_discount'], 2, '.', '') * (number_format(str_replace(',', '.', $order_postmeta['order_discount_value']), 2, '.', '') / 100);
649 649
 									break;
650 650
 							}
651 651
 						}
652
-						if ( !empty($total_discounted) && $discounts_exists ) {
652
+						if (!empty($total_discounted) && $discounts_exists) {
653 653
 							$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Discounted Total', 'wpshop');
654
-							$sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format( $total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency();
654
+							$sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format($total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency();
655 655
 							$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
656
-							unset( $sub_tpl_component );
656
+							unset($sub_tpl_component);
657 657
 						}
658 658
 						else {
659 659
 							$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = '';
660 660
 						}
661 661
 
662 662
 						$shipping_cost = 0;
663
-						if ( !$is_partial_payment ) {
664
-							if( !empty($order_postmeta['order_shipping_cost']) ) {
663
+						if (!$is_partial_payment) {
664
+							if (!empty($order_postmeta['order_shipping_cost'])) {
665 665
 								$shipping_cost = $order_postmeta['order_shipping_cost'];
666 666
 							}
667 667
 						}
668
-						$price_piloting = get_option( 'wpshop_shop_price_piloting', 'TTC' );
669
-						$shipping_taxes = 'HT' == $price_piloting ? ( WPSHOP_VAT_ON_SHIPPING_COST / 100 ) * $shipping_cost : $shipping_cost - ( $shipping_cost / ( 1 + WPSHOP_VAT_ON_SHIPPING_COST / 100 ) );
670
-						$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = number_format( $shipping_cost, 2, ',', '' );
671
-						$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST_TAXES'] = number_format( $shipping_taxes, 2, ',', '' );
668
+						$price_piloting = get_option('wpshop_shop_price_piloting', 'TTC');
669
+						$shipping_taxes = 'HT' == $price_piloting ? (WPSHOP_VAT_ON_SHIPPING_COST / 100) * $shipping_cost : $shipping_cost - ($shipping_cost / (1 + WPSHOP_VAT_ON_SHIPPING_COST / 100));
670
+						$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST'] = number_format($shipping_cost, 2, ',', '');
671
+						$summary_tpl_component['INVOICE_ORDER_SHIPPING_COST_TAXES'] = number_format($shipping_taxes, 2, ',', '');
672 672
 						//$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, ',', '' );
673 673
 
674
-						$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, ',', '' );
675
-						$summary_tpl_component['INVOICE_ORDER_TOTAL_HT'] = ( $is_partial_payment ) ?  number_format(0, 2, ',', '' ) : number_format( $order_postmeta['order_total_ht'], 2, ',', '' );
674
+						$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, ',', '' );
675
+						$summary_tpl_component['INVOICE_ORDER_TOTAL_HT'] = ($is_partial_payment) ? number_format(0, 2, ',', '') : number_format($order_postmeta['order_total_ht'], 2, ',', '');
676 676
 
677 677
 						$summary_tpl_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', '');
678 678
 
679 679
 						$total_payment = 0;
680 680
 
681 681
 						/** Amount paid **/
682
-						if ( empty($order_postmeta['order_invoice_ref']) ) {
682
+						if (empty($order_postmeta['order_invoice_ref'])) {
683 683
 							foreach ($order_postmeta['order_payment']['received'] as $key => $value) {
684
-								if ( !empty($value['invoice_ref']) && $value['invoice_ref'] === $tpl_component['INVOICE_ORDER_INVOICE_REF'] ) {
684
+								if (!empty($value['invoice_ref']) && $value['invoice_ref'] === $tpl_component['INVOICE_ORDER_INVOICE_REF']) {
685 685
 									$total_payment = number_format($value['received_amount'], 2, ',', '');
686 686
 								}
687 687
 							}
688 688
 						}
689 689
 						else {
690
-							$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'];
690
+							$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'];
691 691
 						}
692 692
 
693 693
 						$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Amount already paid', 'wpshop');
694
-						$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();
694
+						$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();
695 695
 						//$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();
696 696
 						$summary_tpl_component['INVOICE_SUMMARY_MORE'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
697
-						unset( $sub_tpl_component );
697
+						unset($sub_tpl_component);
698 698
 
699 699
 						$sub_tpl_component['SUMMARY_ROW_TITLE'] = __('Number of products', 'wpshop');
700 700
 						$sub_tpl_component['SUMMARY_ROW_VALUE'] = $count_products;
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
 
705 705
 						/** If Discount Exist **/
706
-						if ( !empty($order_postmeta['coupon_id']) && !empty($order_postmeta['order_discount_value']) ) {
706
+						if (!empty($order_postmeta['coupon_id']) && !empty($order_postmeta['order_discount_value'])) {
707 707
 							$tpl_discount_component = array();
708 708
 							$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, ',', '');
709 709
 
710 710
 							$tpl_discount_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', '');
711 711
 							$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = wpshop_display::display_template_element('invoice_discount_part', $tpl_discount_component, array(), 'common');
712
-							unset( $tpl_discount_component );
712
+							unset($tpl_discount_component);
713 713
 						}
714 714
 						else {
715 715
 							$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = '';
716 716
 						}
717 717
 
718
-						$summary_tpl_component[ 'PRICE_PILOTING' ] = 'HT' == $price_piloting ? __( 'ET', 'wpshop' ) : __( 'ATI', 'wpshop' );
718
+						$summary_tpl_component['PRICE_PILOTING'] = 'HT' == $price_piloting ? __('ET', 'wpshop') : __('ATI', 'wpshop');
719 719
 
720 720
 						$tpl_component['INVOICE_SUMMARY_PART'] = wpshop_display::display_template_element('invoice_summary_part', $summary_tpl_component, array(), 'common');
721
-						unset( $summary_tpl_component );
721
+						unset($summary_tpl_component);
722 722
 					}
723 723
 
724 724
 
725 725
 					/** IBAN Include on quotation **/
726
-					if ( $is_quotation ) {
726
+					if ($is_quotation) {
727 727
 						/** If admin want to include his IBAN to quotation */
728 728
 						$iban_options = get_option('wpshop_paymentMethod_options');
729 729
 						$payment_options = get_option('wps_payment_mode');
730
-						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' ) {
731
-							if ( !empty($iban_options) && !empty($iban_options['banktransfer']) /*&& !empty($iban_options['banktransfer']['add_in_quotation'])*/ ) {
732
-								$tpl_component['IBAN_INFOS']  = __('Payment by Bank Transfer on this bank account', 'wpshop'). ' : <br/>';
733
-								$tpl_component['IBAN_INFOS'] .= __('Bank name', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['bank_name']) ) ? $iban_options['banktransfer']['bank_name'] : ''). '<br/>';
734
-								$tpl_component['IBAN_INFOS'] .= __('IBAN', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['iban']) ) ? $iban_options['banktransfer']['iban'] : ''). '<br/>';
735
-								$tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['bic']) ) ? $iban_options['banktransfer']['bic'] : ''). '<br/>';
736
-								$tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['accountowner']) ) ? $iban_options['banktransfer']['accountowner'] : ''). '<br/>';
730
+						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') {
731
+							if (!empty($iban_options) && !empty($iban_options['banktransfer']) /*&& !empty($iban_options['banktransfer']['add_in_quotation'])*/) {
732
+								$tpl_component['IBAN_INFOS']  = __('Payment by Bank Transfer on this bank account', 'wpshop') . ' : <br/>';
733
+								$tpl_component['IBAN_INFOS'] .= __('Bank name', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['bank_name'])) ? $iban_options['banktransfer']['bank_name'] : '') . '<br/>';
734
+								$tpl_component['IBAN_INFOS'] .= __('IBAN', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['iban'])) ? $iban_options['banktransfer']['iban'] : '') . '<br/>';
735
+								$tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['bic'])) ? $iban_options['banktransfer']['bic'] : '') . '<br/>';
736
+								$tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop') . ' : ' . ((!empty($iban_options['banktransfer']['accountowner'])) ? $iban_options['banktransfer']['accountowner'] : '') . '<br/>';
737 737
 							}
738 738
 						}
739 739
 						else {
@@ -746,8 +746,8 @@  discard block
 block discarded – undo
746 746
 
747 747
 
748 748
 					/** Received payements **/
749
-					if ( !$is_partial_payment && !$bon_colisage  && !empty($order_postmeta['order_invoice_ref']) ) {
750
-						$tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part( $order_id );
749
+					if (!$is_partial_payment && !$bon_colisage && !empty($order_postmeta['order_invoice_ref'])) {
750
+						$tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part($order_id);
751 751
 					}
752 752
 					else {
753 753
 						$tpl_component['RECEIVED_PAYMENT'] = '';
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 					$output = wpshop_display::display_template_element('invoice_page_content', $tpl_component, array(), 'common');
761 761
 				}
762 762
 				else {
763
-					$output =  __('No order information has been found', 'wpshop');
763
+					$output = __('No order information has been found', 'wpshop');
764 764
 				}
765 765
 			}
766 766
 			else {
767
-				$output =  __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop');
767
+				$output = __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop');
768 768
 			}
769 769
 			return $output;
770 770
 		}
@@ -775,61 +775,61 @@  discard block
 block discarded – undo
775 775
 		 * @param integer $order_id
776 776
 		 * @return string
777 777
 		 */
778
-		public static function generate_received_payment_part( $order_id ) {
779
-			$date_ouput_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
778
+		public static function generate_received_payment_part($order_id) {
779
+			$date_ouput_format = get_option('date_format') . ' ' . get_option('time_format');
780 780
 			$output = '';
781 781
 			$tpl_component = array();
782 782
 			$tpl_component['ORDER_RECEIVED_PAYMENT_ROWS'] = '';
783
-			if ( !empty($order_id) ) {
783
+			if (!empty($order_id)) {
784 784
 				$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
785
-				if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) ) {
786
-					$wps_payment_option = get_option( 'wps_payment_mode' );
787
-					foreach( $order_postmeta['order_payment']['received'] as $payment ) {
788
-						if ( !empty($payment) ) {
785
+				if (!empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received'])) {
786
+					$wps_payment_option = get_option('wps_payment_mode');
787
+					foreach ($order_postmeta['order_payment']['received'] as $payment) {
788
+						if (!empty($payment)) {
789 789
 							$sub_tpl_component = array();
790
-							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_RECEIVED_AMOUNT'] = ( !empty($payment['received_amount']) ) ? number_format( $payment['received_amount'], 2, ',', '' ).' '.wpshop_tools::wpshop_get_currency() : 0;
791
-							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_DATE'] = (!empty($payment['date']) ) ? mysql2date($date_ouput_format, $payment['date'], true) : '';
792
-							$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' ) : '' ) );
793
-							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_PAYMENT_REFERENCE'] = ( !empty($payment['payment_reference']) ) ? $payment['payment_reference'] : '';
794
-							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_INVOICE_REF'] = ( !empty($payment['invoice_ref']) ) ? $payment['invoice_ref'] : '';
790
+							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_RECEIVED_AMOUNT'] = (!empty($payment['received_amount'])) ? number_format($payment['received_amount'], 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency() : 0;
791
+							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_DATE'] = (!empty($payment['date'])) ? mysql2date($date_ouput_format, $payment['date'], true) : '';
792
+							$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') : ''));
793
+							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_PAYMENT_REFERENCE'] = (!empty($payment['payment_reference'])) ? $payment['payment_reference'] : '';
794
+							$sub_tpl_component['INVOICE_RECEIVED_PAYMENT_INVOICE_REF'] = (!empty($payment['invoice_ref'])) ? $payment['invoice_ref'] : '';
795 795
 							$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');
796 796
 						}
797 797
 					}
798 798
 				}
799 799
 				$output = wpshop_display::display_template_element('received_payment', $tpl_component, array('type' => 'invoice_line', 'id' => 'partial_payment'), 'common');
800
-				unset( $tpl_component );
800
+				unset($tpl_component);
801 801
 			}
802 802
 			return $output;
803 803
 		}
804 804
 
805 805
 
806 806
 		/** Return the validity period of a quotation **/
807
-		public static function quotation_validate_period( $quotation_date ) {
807
+		public static function quotation_validate_period($quotation_date) {
808 808
 			$quotation_options = get_option('wpshop_quotation_validate_time');
809
-			if ( !empty($quotation_options) && !empty($quotation_options['number']) && !empty($quotation_options['time_type']) ) {
809
+			if (!empty($quotation_options) && !empty($quotation_options['number']) && !empty($quotation_options['time_type'])) {
810 810
 				$timestamp_quotation = strtotime($quotation_date);
811 811
 				$timestamp_validity_date_quotation = 0;
812 812
 				$query = '';
813 813
 				$date = '';
814 814
 				global $wpdb;
815
-				switch ( $quotation_options['time_type'] ) {
815
+				switch ($quotation_options['time_type']) {
816 816
 					case 'day' :
817
-						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " DAY) ");
817
+						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " DAY) ");
818 818
 						break;
819 819
 					case 'month' :
820
-						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " MONTH) ");
820
+						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " MONTH) ");
821 821
 						break;
822 822
 					case 'year' :
823
-						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " .$quotation_options['number']. " YEAR) ");
823
+						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL " . $quotation_options['number'] . " YEAR) ");
824 824
 						break;
825 825
 					default :
826 826
 						$query = $wpdb->prepare("SELECT DATE_ADD('" . $quotation_date . "', INTERVAL 15 DAY) ");
827 827
 						break;
828 828
 				}
829
-				if ( $query != null) {
829
+				if ($query != null) {
830 830
 					$date = mysql2date('d F Y', $wpdb->get_var($query), true);
831 831
 				}
832
-				return  sprintf( __('Quotation validity date %s', 'wpshop'), $date ) ;
832
+				return  sprintf(__('Quotation validity date %s', 'wpshop'), $date);
833 833
 			}
834 834
 		}
835 835
 
@@ -839,19 +839,19 @@  discard block
 block discarded – undo
839 839
 		 * @param string $invoice_ref
840 840
 		 * @return string
841 841
 		 */
842
-		public static function generate_invoice_for_email ( $order_id, $invoice_ref = '' ) {
842
+		public static function generate_invoice_for_email($order_id, $invoice_ref = '') {
843 843
 			/** Generate the PDF file for the invoice **/
844 844
 			$is_ok = false;
845
-			if ( !empty($invoice_ref) ) {
846
-				require_once(WPSHOP_LIBRAIRIES_DIR.'HTML2PDF/html2pdf.class.php');
845
+			if (!empty($invoice_ref)) {
846
+				require_once(WPSHOP_LIBRAIRIES_DIR . 'HTML2PDF/html2pdf.class.php');
847 847
 				try {
848
-					$html_content =  wpshop_modules_billing::generate_html_invoice( $order_id, $invoice_ref );
848
+					$html_content = wpshop_modules_billing::generate_html_invoice($order_id, $invoice_ref);
849 849
 					$html_content = wpshop_display::display_template_element('invoice_page_content_css', array(), array(), 'common') . '<page>' . $html_content . '</page>';
850 850
 					$html2pdf = new HTML2PDF('P', 'A4', 'fr');
851 851
 
852 852
 					$html2pdf->setDefaultFont('Arial');
853 853
 					$html2pdf->writeHTML($html_content);
854
-					$html2pdf->Output(WPSHOP_UPLOAD_DIR.$invoice_ref.'.pdf', 'F');
854
+					$html2pdf->Output(WPSHOP_UPLOAD_DIR . $invoice_ref . '.pdf', 'F');
855 855
 					$is_ok = true;
856 856
 				}
857 857
 				catch (HTML2PDF_exception $e) {
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 					exit;
860 860
 				}
861 861
 			}
862
-			return ( $is_ok ) ? WPSHOP_UPLOAD_DIR.$invoice_ref.'.pdf' : '';
862
+			return ($is_ok) ? WPSHOP_UPLOAD_DIR . $invoice_ref . '.pdf' : '';
863 863
 		}
864 864
 
865 865
 		/**
@@ -867,38 +867,38 @@  discard block
 block discarded – undo
867 867
 		 * @return Ambigous <string, string>
868 868
 		 */
869 869
 		public static function generate_invoice_sender_part() {
870
-			$output ='';
870
+			$output = '';
871 871
 			$company = get_option('wpshop_company_info', array());
872 872
 			$emails = get_option('wpshop_emails', array());
873
-			if ( !empty($company) ) {
874
-				$tpl_component['COMPANY_EMAIL'] = ( !empty($emails) && !empty($emails['contact_email']) ) ? $emails['contact_email'] : '';
873
+			if (!empty($company)) {
874
+				$tpl_component['COMPANY_EMAIL'] = (!empty($emails) && !empty($emails['contact_email'])) ? $emails['contact_email'] : '';
875 875
 				$tpl_component['COMPANY_WEBSITE'] = get_option('siteurl');
876
-				foreach ( $company as $company_info_key => $company_info_value ) {
876
+				foreach ($company as $company_info_key => $company_info_value) {
877 877
 					switch ($company_info_key) {
878 878
 						case 'company_rcs' :
879
-							$data = ( !empty($company_info_value) ) ? __('RCS', 'wpshop').' : '.$company_info_value : '';
879
+							$data = (!empty($company_info_value)) ? __('RCS', 'wpshop') . ' : ' . $company_info_value : '';
880 880
 							break;
881 881
 						case 'company_capital' :
882
-							$data = ( !empty($company_info_value) ) ? __('Capital', 'wpshop').' : '.$company_info_value : '';
882
+							$data = (!empty($company_info_value)) ? __('Capital', 'wpshop') . ' : ' . $company_info_value : '';
883 883
 							break;
884 884
 						case 'company_siren' :
885
-							$data = ( !empty($company_info_value) ) ? __('SIREN', 'wpshop').' : '.$company_info_value : '';
885
+							$data = (!empty($company_info_value)) ? __('SIREN', 'wpshop') . ' : ' . $company_info_value : '';
886 886
 							break;
887 887
 						case 'company_siret' :
888
-							$data = ( !empty($company_info_value) ) ? __('SIRET', 'wpshop').' : '.$company_info_value : '';
888
+							$data = (!empty($company_info_value)) ? __('SIRET', 'wpshop') . ' : ' . $company_info_value : '';
889 889
 							break;
890 890
 						case 'company_tva_intra' :
891
-							$data = ( !empty($company_info_value) ) ? __('TVA Intracommunautaire', 'wpshop').' : '.$company_info_value : '';
891
+							$data = (!empty($company_info_value)) ? __('TVA Intracommunautaire', 'wpshop') . ' : ' . $company_info_value : '';
892 892
 							break;
893 893
 						case 'company_legal_statut' :
894 894
 							$array_state_compagny = wpshop_company_options::get_legal_status();
895
-							$data = ( !empty( $array_state_compagny ) && !empty( $array_state_compagny[$company_info_value] ) ) ? $array_state_compagny[$company_info_value] : __( 'Auto-Entrepreneur', 'wpshop' ) ;
895
+							$data = (!empty($array_state_compagny) && !empty($array_state_compagny[$company_info_value])) ? $array_state_compagny[$company_info_value] : __('Auto-Entrepreneur', 'wpshop');
896 896
 							break;
897 897
 						default :
898 898
 							$data = $company_info_value;
899 899
 							break;
900 900
 					}
901
-					$tpl_component[ strtoupper( $company_info_key) ] = $data;
901
+					$tpl_component[strtoupper($company_info_key)] = $data;
902 902
 				}
903 903
 				$output = wpshop_display::display_template_element('invoice_sender_formatted_address', $tpl_component, array(), 'common');
904 904
 			}
@@ -911,49 +911,49 @@  discard block
 block discarded – undo
911 911
 		 * @param unknown_type $bon_colisage
912 912
 		 * @return Ambigous <string, string>
913 913
 		 */
914
-		public static function generate_receiver_part( $order_id, $bon_colisage = false ) {
914
+		public static function generate_receiver_part($order_id, $bon_colisage = false) {
915 915
 			$output = '';
916 916
 			$order_customer_postmeta = get_post_meta($order_id, '_order_info', true);
917
-			$order_postmeta = get_post_meta( $order_id, '_order_postmeta', true );
918
-			$address_info = ( $bon_colisage ) ? ( ( !empty($order_customer_postmeta['shipping']) && !empty($order_customer_postmeta['shipping']['address']) && is_array($order_customer_postmeta['shipping']['address']) )  ? $order_customer_postmeta['shipping']['address'] : array() ) : ( ( !empty($order_customer_postmeta['billing']) && !empty($order_customer_postmeta['billing']['address']) && is_array($order_customer_postmeta['billing']['address']) )  ? $order_customer_postmeta['billing']['address'] : array() );
917
+			$order_postmeta = get_post_meta($order_id, '_order_postmeta', true);
918
+			$address_info = ($bon_colisage) ? ((!empty($order_customer_postmeta['shipping']) && !empty($order_customer_postmeta['shipping']['address']) && is_array($order_customer_postmeta['shipping']['address'])) ? $order_customer_postmeta['shipping']['address'] : array()) : ((!empty($order_customer_postmeta['billing']) && !empty($order_customer_postmeta['billing']['address']) && is_array($order_customer_postmeta['billing']['address'])) ? $order_customer_postmeta['billing']['address'] : array());
919 919
 
920 920
 
921
-			if ( !empty($order_customer_postmeta) && !empty($address_info) ) {
921
+			if (!empty($order_customer_postmeta) && !empty($address_info)) {
922 922
 				$default_address_attributes = array('CIVILITY', 'ADDRESS_LAST_NAME', 'ADDRESS_FIRST_NAME', 'ADDRESS', 'POSTCODE', 'CITY', 'STATE', 'COUNTRY', 'PHONE', 'ADDRESS_USER_EMAIL', 'COMPANY');
923
-				foreach ( $default_address_attributes as $default_address_attribute ) {
923
+				foreach ($default_address_attributes as $default_address_attribute) {
924 924
 					$tpl_component[$default_address_attribute] = '';
925 925
 				}
926 926
 
927
-				foreach ( $address_info as $order_customer_info_key => $order_customer_info_value ) {
927
+				foreach ($address_info as $order_customer_info_key => $order_customer_info_value) {
928 928
 					$tpl_component[strtoupper($order_customer_info_key)] = '';
929
-					if ( $order_customer_info_key == 'civility') {
929
+					if ($order_customer_info_key == 'civility') {
930 930
 						global $wpdb;
931
-						$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id= %d', $order_customer_info_value);
931
+						$query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id= %d', $order_customer_info_value);
932 932
 						$civility = $wpdb->get_row($query);
933
-						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($civility) ) ? (!empty($civility->label)) ? $civility->label : __($civility->value, 'wpshop') : '';
933
+						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($civility)) ? (!empty($civility->label)) ? $civility->label : __($civility->value, 'wpshop') : '';
934 934
 					}
935
-					else if( $order_customer_info_key == 'country') {
935
+					else if ($order_customer_info_key == 'country') {
936 936
 						foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key=>$value) {
937
-							if ( $order_customer_info_value == $key) {
937
+							if ($order_customer_info_value == $key) {
938 938
 								$tpl_component[strtoupper($order_customer_info_key)] = $value;
939 939
 							}
940 940
 						}
941 941
 					}
942
-					elseif( $order_customer_info_key == 'phone' ){
943
-						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? __('Phone', 'wpshop').' : '.$order_customer_info_value : '';
942
+					elseif ($order_customer_info_key == 'phone') {
943
+						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value)) ? __('Phone', 'wpshop') . ' : ' . $order_customer_info_value : '';
944 944
 					}
945 945
 					else {
946
-						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? $order_customer_info_value : '';
946
+						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value)) ? $order_customer_info_value : '';
947 947
 					}
948 948
 				}
949 949
 
950
-				if ( empty($tpl_component['PHONE']) ) {
951
-					$tpl_component['PHONE'] = ( !empty( $order_customer_postmeta['billing']['address']['phone']) ) ? __('Phone', 'wpshop').' : '.$order_customer_postmeta['billing']['address']['phone'] : '';
950
+				if (empty($tpl_component['PHONE'])) {
951
+					$tpl_component['PHONE'] = (!empty($order_customer_postmeta['billing']['address']['phone'])) ? __('Phone', 'wpshop') . ' : ' . $order_customer_postmeta['billing']['address']['phone'] : '';
952 952
 				}
953 953
 
954
-				if ( empty($tpl_component['ADDRESS_USER_EMAIL']) || ( empty($tpl_component['ADDRESS_USER_EMAIL']) && $bon_colisage ) ){
955
-					$user_info = get_userdata( $order_postmeta['customer_id'] );
956
-					$tpl_component['ADDRESS_USER_EMAIL'] = ( !empty($user_info) && !empty($user_info->user_email) ) ? $user_info->user_email : '';
954
+				if (empty($tpl_component['ADDRESS_USER_EMAIL']) || (empty($tpl_component['ADDRESS_USER_EMAIL']) && $bon_colisage)) {
955
+					$user_info = get_userdata($order_postmeta['customer_id']);
956
+					$tpl_component['ADDRESS_USER_EMAIL'] = (!empty($user_info) && !empty($user_info->user_email)) ? $user_info->user_email : '';
957 957
 				}
958 958
 
959 959
 
@@ -968,36 +968,36 @@  discard block
 block discarded – undo
968 968
 		 * Genrate Footer invoice
969 969
 		 * @return Ambigous <string, string>
970 970
 		 */
971
-		public static function generate_footer_invoice(){
972
-			$output ='';
971
+		public static function generate_footer_invoice() {
972
+			$output = '';
973 973
 			$company = get_option('wpshop_company_info', array());
974 974
 			$emails = get_option('wpshop_emails', array());
975
-			if ( !empty($company) ) {
976
-				$tpl_component['COMPANY_EMAIL'] = ( !empty($emails) && !empty($emails['contact_email']) ) ? $emails['contact_email'] : '';
975
+			if (!empty($company)) {
976
+				$tpl_component['COMPANY_EMAIL'] = (!empty($emails) && !empty($emails['contact_email'])) ? $emails['contact_email'] : '';
977 977
 				$tpl_component['COMPANY_WEBSITE'] = site_url();
978
-				foreach ( $company as $company_info_key => $company_info_value ) {
978
+				foreach ($company as $company_info_key => $company_info_value) {
979 979
 
980 980
 					switch ($company_info_key) {
981 981
 						case 'company_rcs' :
982
-							$data = ( !empty($company_info_value) ) ? __('RCS', 'wpshop').' : '.$company_info_value : '';
982
+							$data = (!empty($company_info_value)) ? __('RCS', 'wpshop') . ' : ' . $company_info_value : '';
983 983
 							break;
984 984
 						case 'company_capital' :
985
-							$data = ( !empty($company_info_value) ) ? __('Capital', 'wpshop').' : '.$company_info_value : '';
985
+							$data = (!empty($company_info_value)) ? __('Capital', 'wpshop') . ' : ' . $company_info_value : '';
986 986
 							break;
987 987
 						case 'company_siren' :
988
-							$data = ( !empty($company_info_value) ) ? __('SIREN', 'wpshop').' : '.$company_info_value : '';
988
+							$data = (!empty($company_info_value)) ? __('SIREN', 'wpshop') . ' : ' . $company_info_value : '';
989 989
 							break;
990 990
 						case 'company_siret' :
991
-							$data = ( !empty($company_info_value) ) ? __('SIRET', 'wpshop').' : '.$company_info_value : '';
991
+							$data = (!empty($company_info_value)) ? __('SIRET', 'wpshop') . ' : ' . $company_info_value : '';
992 992
 							break;
993 993
 						case 'company_tva_intra' :
994
-							$data = ( !empty($company_info_value) ) ? __('TVA Intracommunautaire', 'wpshop').' : '.$company_info_value : '';
994
+							$data = (!empty($company_info_value)) ? __('TVA Intracommunautaire', 'wpshop') . ' : ' . $company_info_value : '';
995 995
 							break;
996 996
 						default :
997 997
 							$data = $company_info_value;
998 998
 							break;
999 999
 					}
1000
-					$tpl_component[ strtoupper( $company_info_key) ] = $data;
1000
+					$tpl_component[strtoupper($company_info_key)] = $data;
1001 1001
 				}
1002 1002
 				$output = wpshop_display::display_template_element('invoice_footer', $tpl_component, array(), 'common');
1003 1003
 			}
@@ -1013,33 +1013,33 @@  discard block
 block discarded – undo
1013 1013
 		 * @param id $product_id
1014 1014
 		 * @param string $invoice_ref
1015 1015
 		 */
1016
-		public static function check_product_price( $price_ht, $price_ati, $tva_amount, $tva_rate, $product_id, $invoice_ref, $order_id ) {
1016
+		public static function check_product_price($price_ht, $price_ati, $tva_amount, $tva_rate, $product_id, $invoice_ref, $order_id) {
1017 1017
 			$checking = true;
1018
-			$error_percent =  1;
1018
+			$error_percent = 1;
1019 1019
 
1020 1020
 			/** Check VAT Amount **/
1021
-			$formatted_tva_amount = number_format( $tva_amount, 2, '.', '' );
1022
-			$formatted_price_ht = number_format( $price_ht, 2, '.', '' );
1023
-			$formatted_price_ati = number_format( $price_ati, 2, '.', '' );
1024
-			$calculated_price_excluding_tax = $price_ati / ( 1 + ($tva_rate / 100) );
1021
+			$formatted_tva_amount = number_format($tva_amount, 2, '.', '');
1022
+			$formatted_price_ht = number_format($price_ht, 2, '.', '');
1023
+			$formatted_price_ati = number_format($price_ati, 2, '.', '');
1024
+			$calculated_price_excluding_tax = $price_ati / (1 + ($tva_rate / 100));
1025 1025
 			$unformatted = $formatted_price_ati - $calculated_price_excluding_tax;
1026
-			$checked_tva_amount = number_format( $unformatted, 2, '.', '' );
1026
+			$checked_tva_amount = number_format($unformatted, 2, '.', '');
1027 1027
 
1028
-			if ( ( $checked_tva_amount < ($formatted_tva_amount / ( 1 + ($error_percent / 100) ) ) ) || ( $checked_tva_amount > ($formatted_tva_amount * (1 + ($error_percent / 100) ) ) )  ) {
1028
+			if (($checked_tva_amount < ($formatted_tva_amount / (1 + ($error_percent / 100)))) || ($checked_tva_amount > ($formatted_tva_amount * (1 + ($error_percent / 100))))) {
1029 1029
 				$error_infos = array();
1030
-				$error_infos['real_datas']['price_ati'] =  $formatted_price_ati;
1031
-				$error_infos['real_datas']['price_ht'] =  $formatted_price_ht;
1032
-				$error_infos['real_datas']['tva_amount'] =  $formatted_tva_amount;
1030
+				$error_infos['real_datas']['price_ati'] = $formatted_price_ati;
1031
+				$error_infos['real_datas']['price_ht'] = $formatted_price_ht;
1032
+				$error_infos['real_datas']['tva_amount'] = $formatted_tva_amount;
1033 1033
 
1034 1034
 				$error_infos['corrected_data'] = $checked_tva_amount;
1035
-				self::invoice_error_check_administrator( $invoice_ref, __('VAT error', 'wpshop'), $product_id, $order_id, $error_infos );
1035
+				self::invoice_error_check_administrator($invoice_ref, __('VAT error', 'wpshop'), $product_id, $order_id, $error_infos);
1036 1036
 				$checking = false;
1037 1037
 			}
1038 1038
 
1039 1039
 			/** Check price ati **/
1040
-			$checked_price_ati =  $formatted_price_ht * ( 1 + ( $tva_rate / 100) );
1041
-			if ( ( $checked_price_ati < ($formatted_price_ati /( 1 + ($error_percent / 100) ) ) ) || ( $checked_price_ati > ($formatted_price_ati * (1 + ($error_percent / 100)) ) )  ) {
1042
-				self::invoice_error_check_administrator( $invoice_ref, __('ATI Price error', 'wpshop'), $product_id, $order_id );
1040
+			$checked_price_ati = $formatted_price_ht * (1 + ($tva_rate / 100));
1041
+			if (($checked_price_ati < ($formatted_price_ati / (1 + ($error_percent / 100)))) || ($checked_price_ati > ($formatted_price_ati * (1 + ($error_percent / 100))))) {
1042
+				self::invoice_error_check_administrator($invoice_ref, __('ATI Price error', 'wpshop'), $product_id, $order_id);
1043 1043
 				$checking = false;
1044 1044
 			}
1045 1045
 
@@ -1052,29 +1052,29 @@  discard block
 block discarded – undo
1052 1052
 		 * @param string $object
1053 1053
 		 * @param unknown_type $product_id
1054 1054
 		 */
1055
-		function invoice_error_check_administrator( $invoice_ref, $object, $product_id, $order_id, $errors_infos = array() ) {
1056
-			$wpshop_email_option = get_option( 'wpshop_emails');
1057
-			if ( !empty($wpshop_email_option) && !empty($wpshop_email_option['contact_email']) ) {
1055
+		function invoice_error_check_administrator($invoice_ref, $object, $product_id, $order_id, $errors_infos = array()) {
1056
+			$wpshop_email_option = get_option('wpshop_emails');
1057
+			if (!empty($wpshop_email_option) && !empty($wpshop_email_option['contact_email'])) {
1058 1058
 				$headers = "MIME-Version: 1.0\r\n";
1059 1059
 				$headers .= "Content-type: text/html; charset=UTF-8\r\n";
1060
-				$headers .= 'From: '.get_bloginfo('name').' <'.$wpshop_email_option['noreply_email'].'>' . "\r\n";
1061
-				$message  = '<b>'.__('Error type', 'wpshop').' : </b>'.$object.'<br/>';
1062
-				$message .= '<b>'.__( 'Product', 'wpshop').' : </b>'.get_the_title(  $product_id ).'<br/>';
1063
-				$message .= '<b>'.__( 'Invoice ref', 'wpshop').' : </b>'.$invoice_ref.'<br/>';
1064
-				$message .= '<b>'.__( 'Order ID', 'wpshop').' : </b>'.$order_id.'<br/>';
1065
-
1066
-				if ( !empty($errors_infos) && !empty($errors_infos['real_datas']) ) {
1067
-					$message .='<b>' .__( 'Bad datas', 'wpshop').' :</b> <ul>';
1068
-					foreach( $errors_infos['real_datas'] as $k => $errors_info ) {
1069
-						$message .= '<li><b>'.$k.' : </b>'.$errors_info.'</li>';
1060
+				$headers .= 'From: ' . get_bloginfo('name') . ' <' . $wpshop_email_option['noreply_email'] . '>' . "\r\n";
1061
+				$message  = '<b>' . __('Error type', 'wpshop') . ' : </b>' . $object . '<br/>';
1062
+				$message .= '<b>' . __('Product', 'wpshop') . ' : </b>' . get_the_title($product_id) . '<br/>';
1063
+				$message .= '<b>' . __('Invoice ref', 'wpshop') . ' : </b>' . $invoice_ref . '<br/>';
1064
+				$message .= '<b>' . __('Order ID', 'wpshop') . ' : </b>' . $order_id . '<br/>';
1065
+
1066
+				if (!empty($errors_infos) && !empty($errors_infos['real_datas'])) {
1067
+					$message .= '<b>' . __('Bad datas', 'wpshop') . ' :</b> <ul>';
1068
+					foreach ($errors_infos['real_datas'] as $k => $errors_info) {
1069
+						$message .= '<li><b>' . $k . ' : </b>' . $errors_info . '</li>';
1070 1070
 					}
1071 1071
 					$message .= '</ul>';
1072
-					if ( !empty($errors_infos['corrected_data']) ) {
1073
-						$message .= '<b>' . __( 'Good value', 'wpshop' ) . ' : </b>' . $errors_infos['corrected_data'];
1072
+					if (!empty($errors_infos['corrected_data'])) {
1073
+						$message .= '<b>' . __('Good value', 'wpshop') . ' : </b>' . $errors_infos['corrected_data'];
1074 1074
 					}
1075 1075
 				}
1076 1076
 
1077
-				wp_mail( $wpshop_email_option['contact_email'], __('Error on invoice generation', 'wpshop') , $message, $headers);
1077
+				wp_mail($wpshop_email_option['contact_email'], __('Error on invoice generation', 'wpshop'), $message, $headers);
1078 1078
 			}
1079 1079
 		}
1080 1080
 
@@ -1084,9 +1084,9 @@  discard block
 block discarded – undo
1084 1084
 		 * @param array $posted_datas
1085 1085
 		 * @return string
1086 1086
 		 */
1087
-		function force_invoice_generation_on_order( $order_metadata, $posted_datas ) {
1088
-			if ( !empty ($posted_datas['action_triggered_from']) && $posted_datas['action_triggered_from'] == 'generate_invoice') {
1089
-				$order_metadata['order_invoice_ref'] = $this->generate_invoice_number( $posted_datas['post_ID'] );
1087
+		function force_invoice_generation_on_order($order_metadata, $posted_datas) {
1088
+			if (!empty ($posted_datas['action_triggered_from']) && $posted_datas['action_triggered_from'] == 'generate_invoice') {
1089
+				$order_metadata['order_invoice_ref'] = $this->generate_invoice_number($posted_datas['post_ID']);
1090 1090
 			}
1091 1091
 			return $order_metadata;
1092 1092
 		}
@@ -1101,12 +1101,12 @@  discard block
 block discarded – undo
1101 1101
 		$partial_payment_current_config = get_option('wpshop_payment_partial', array('for_quotation' => array()));
1102 1102
 
1103 1103
 		$partial_for_quotation_is_activate = false;
1104
-		if ( !empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_quotation']) && !empty($partial_payment_current_config['for_quotation']['activate']) ) {
1104
+		if (!empty($partial_payment_current_config) && !empty($partial_payment_current_config['for_quotation']) && !empty($partial_payment_current_config['for_quotation']['activate'])) {
1105 1105
 			$partial_for_quotation_is_activate = true;
1106 1106
 		}
1107 1107
 
1108 1108
 		$output .= '
1109
-			<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>
1109
+			<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>
1110 1110
 			<div class="wpshop_partial_payment_quotation_config_container' . ($partial_for_quotation_is_activate ? '' : ' wpshopHide') . '" id="wpshop_partial_payment_quotation_config_container" >
1111 1111
 				<div class="alignleft" >
1112 1112
 					' . __('Value of partial payment', 'wpshop') . '<br/>
@@ -1128,6 +1128,6 @@  discard block
 block discarded – undo
1128 1128
 }
1129 1129
 
1130 1130
 /**	Instanciate the module utilities if not	*/
1131
-if ( class_exists("wpshop_modules_billing") ) {
1131
+if (class_exists("wpshop_modules_billing")) {
1132 1132
 	$wpshop_modules_billing = new wpshop_modules_billing();
1133 1133
 }
Please login to merge, or discard this patch.
Braces   +40 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 /**
3 5
  * Billing module bootstrap file
4 6
  *
@@ -57,8 +59,10 @@  discard block
 block discarded – undo
57 59
 			/*	Get custom frontend template	*/
58 60
 			if ( is_file(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php') ) {
59 61
 				require_once(get_stylesheet_directory() . '/wpshop/common/main_elements.tpl.php');
60
-				if (!empty($tpl_element))
61
-					$wpshop_template['common']['custom'] = ($tpl_element);unset($tpl_element);
62
+				if (!empty($tpl_element)) {
63
+									$wpshop_template['common']['custom'] = ($tpl_element);
64
+				}
65
+				unset($tpl_element);
62 66
 			}
63 67
 			$wpshop_display = new wpshop_display();
64 68
 			$templates = $wpshop_display->add_modules_template_to_internal( $wpshop_template, $templates );
@@ -136,7 +140,9 @@  discard block
 block discarded – undo
136 140
 		function wpshop_billing_number_figures_field() {
137 141
 			$wpshop_billing_number_figures = get_option('wpshop_billing_number_figures');
138 142
 			$readonly = !empty($wpshop_billing_number_figures) ? 'readonly="readonly"': null;
139
-			if(empty($wpshop_billing_number_figures)) $wpshop_billing_number_figures=5;
143
+			if(empty($wpshop_billing_number_figures)) {
144
+				$wpshop_billing_number_figures=5;
145
+			}
140 146
 
141 147
 			echo '<input name="wpshop_billing_number_figures" type="text" value="'.$wpshop_billing_number_figures.'" '.$readonly.' />
142 148
 		<a href="#" title="'.__('Number of figures to make appear on invoices','wpshop').'" class="wpshop_infobulle_marker">?</a>';
@@ -258,8 +264,7 @@  discard block
 block discarded – undo
258 264
 			/** If the counter doesn't exist, we initiate it */
259 265
 			if (!$billing_current_number) {
260 266
 				$billing_current_number = 1;
261
-			}
262
-			else {
267
+			} else {
263 268
 				$billing_current_number++;
264 269
 			}
265 270
 
@@ -315,7 +320,9 @@  discard block
 block discarded – undo
315 320
 
316 321
 				/** Check it is a shipping slip **/
317 322
 				$bon_colisage = !empty( $_GET['bon_colisage'] ) ? sanitize_key( $_GET['bon_colisage'] ) : false;
318
-				if ( $bon_colisage ) $bon_colisage = true;
323
+				if ( $bon_colisage ) {
324
+					$bon_colisage = true;
325
+				}
319 326
 
320 327
 				if ( !empty($order_postmeta) ) {
321 328
 					$tpl_component = array();
@@ -347,8 +354,7 @@  discard block
 block discarded – undo
347 354
 					/** Validate period for Quotation **/
348 355
 					if ( $is_quotation ) {
349 356
 						$quotation_validate_period = self::quotation_validate_period( $order_postmeta['order_date'] );
350
-					}
351
-					else {
357
+					} else {
352 358
 						$tpl_component['INVOICE_VALIDATE_TIME'] = '';
353 359
 					}
354 360
 
@@ -381,8 +387,7 @@  discard block
 block discarded – undo
381 387
 					$order_tva = array();
382 388
 					if ( $bon_colisage ) {
383 389
 						$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('bon_colisage_row_header', array(), array(), 'common');
384
-					}
385
-					else {
390
+					} else {
386 391
 						$tpl_component['INVOICE_HEADER'] = wpshop_display::display_template_element('invoice_row_header', array(), array(), 'common');
387 392
 						//if ( !$is_quotation ) {
388 393
 							/** Check if products have discounts **/
@@ -445,8 +450,9 @@  discard block
 block discarded – undo
445 450
 								if ( count($product_attribute_order_detail) > 0 && is_array($product_attribute_order_detail) ) {
446 451
 									foreach ( $product_attribute_order_detail as $product_attr_group_id => $product_attr_group_detail) {
447 452
 										foreach ( $product_attr_group_detail['attribut'] as $position => $attribute_def) {
448
-											if ( !empty($attribute_def->code) )
449
-												$output_order[$attribute_def->code] = $position;
453
+											if ( !empty($attribute_def->code) ) {
454
+																							$output_order[$attribute_def->code] = $position;
455
+											}
450 456
 										}
451 457
 									}
452 458
 								}
@@ -482,8 +488,7 @@  discard block
 block discarded – undo
482 488
 
483 489
 								if ( $bon_colisage ) {
484 490
 									$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('bon_colisage_row', $sub_tpl_component, array(), 'common');
485
-								}
486
-								else {
491
+								} else {
487 492
 									if ( $discounts_exists ) {
488 493
 										$discounted_total_per_item = $item['item_total_ht'];
489 494
 										/** Unit Discount **/
@@ -491,8 +496,7 @@  discard block
 block discarded – undo
491 496
 											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( $item['item_unit_discount_amount'], 2, '.', '');
492 497
 											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( $item['item_unit_discount_value'], 2, '.', '');
493 498
 											$discounted_total_per_item = $discounted_total_per_item - $item['item_unit_discount_amount'];
494
-										}
495
-										else {
499
+										} else {
496 500
 											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
497 501
 											$sub_tpl_component['INVOICE_ROW_ITEM_UNIT_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
498 502
 										}
@@ -502,8 +506,7 @@  discard block
 block discarded – undo
502 506
 											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( $item['item_global_discount_amount'], 2, '.', '');
503 507
 											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( $item['item_global_discount_value'], 2, '.', '');
504 508
 											$discounted_total_per_item = $discounted_total_per_item - $item['item_global_discount_amount'];
505
-										}
506
-										else {
509
+										} else {
507 510
 											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_AMOUNT'] = number_format( 0, 2, '.', '');
508 511
 											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
509 512
 										}
@@ -513,8 +516,7 @@  discard block
 block discarded – undo
513 516
 										$sub_tpl_component['INVOICE_ROW_ITEM_DISCOUNTED_HT_TOTAL'] = number_format( $discounted_total_per_item, 2, '.', '');
514 517
 
515 518
 										$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common');
516
-									}
517
-									else {
519
+									} else {
518 520
 										$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common');
519 521
 									}
520 522
 								}
@@ -523,8 +525,7 @@  discard block
 block discarded – undo
523 525
 								/** Check TVA **/
524 526
 								if ( empty($order_tva[ $item['item_tva_rate'] ]) ) {
525 527
 									$order_tva[ $item['item_tva_rate'] ] = $item['item_tva_total_amount'];
526
-								}
527
-								else {
528
+								} else {
528 529
 									$order_tva[ $item['item_tva_rate'] ] += $item['item_tva_total_amount'];
529 530
 								}
530 531
 
@@ -565,23 +566,20 @@  discard block
 block discarded – undo
565 566
 											$sub_tpl_component['INVOICE_ROW_ITEM_GLOBAL_DISCOUNT_VALUE'] = number_format( 0, 2, '.', '');
566 567
 
567 568
 											$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row_with_discount', $sub_tpl_component, array(), 'common');
568
-										}
569
-										else {
569
+										} else {
570 570
 											$tpl_component['INVOICE_ROWS'] .= wpshop_display::display_template_element('invoice_row', $sub_tpl_component, array(), 'common');
571 571
 										}
572 572
 									}
573 573
 
574 574
 									unset( $sub_tpl_component );
575 575
 									$total_partial_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0;
576
-								}
577
-								else if( 'payment_received' == $received_payment[ 'status' ] ) {
576
+								} else if( 'payment_received' == $received_payment[ 'status' ] ) {
578 577
 									$last_payment += ( !empty($received_payment['received_amount']) ) ? $received_payment['received_amount'] : 0;
579 578
 								}
580 579
 
581 580
 							}
582 581
 						}
583
-					}
584
-					else {
582
+					} else {
585 583
 						/** Display Partials payments **/
586 584
 						$total_partial_payment = 0; $last_payment = 0;
587 585
 						if ( !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['received']) && !$bon_colisage ) {
@@ -623,8 +621,7 @@  discard block
 block discarded – undo
623 621
 									$sub_tpl_component['SUMMARY_ROW_VALUE'] = wpshop_display::format_field_output('wpshop_product_price', $tax_amount) . ' ' . wpshop_tools::wpshop_get_currency();
624 622
 									$summary_tpl_component['INVOICE_SUMMARY_TAXES'] .= wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
625 623
 									unset( $sub_tpl_component );
626
-								}
627
-								elseif( $is_partial_payment ) {
624
+								} elseif( $is_partial_payment ) {
628 625
 									$tax_rate = 0;
629 626
 									$tax_amount = number_format( 0, 2, ',', '') . ' ' . wpshop_tools::wpshop_get_currency();
630 627
 									$sub_tpl_component['SUMMARY_ROW_TITLE'] = sprintf( __('Total taxes amount %1$s', 'wpshop'), $tax_rate . '%' );
@@ -654,8 +651,7 @@  discard block
 block discarded – undo
654 651
 							$sub_tpl_component['SUMMARY_ROW_VALUE'] = number_format( $total_discounted, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency();
655 652
 							$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = wpshop_display::display_template_element('invoice_summary_row', $sub_tpl_component, array(), 'common');
656 653
 							unset( $sub_tpl_component );
657
-						}
658
-						else {
654
+						} else {
659 655
 							$summary_tpl_component['INVOICE_SUMMARY_TOTAL_DISCOUNTED'] = '';
660 656
 						}
661 657
 
@@ -685,8 +681,7 @@  discard block
 block discarded – undo
685 681
 									$total_payment = number_format($value['received_amount'], 2, ',', '');
686 682
 								}
687 683
 							}
688
-						}
689
-						else {
684
+						} else {
690 685
 							$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'];
691 686
 						}
692 687
 
@@ -710,8 +705,7 @@  discard block
 block discarded – undo
710 705
 							$tpl_discount_component['TOTAL_BEFORE_DISCOUNT'] = number_format($order_postmeta['order_grand_total_before_discount'], 2, ',', '');
711 706
 							$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = wpshop_display::display_template_element('invoice_discount_part', $tpl_discount_component, array(), 'common');
712 707
 							unset( $tpl_discount_component );
713
-						}
714
-						else {
708
+						} else {
715 709
 							$summary_tpl_component['INVOICE_ORDER_DISCOUNT'] = '';
716 710
 						}
717 711
 
@@ -735,12 +729,10 @@  discard block
 block discarded – undo
735 729
 								$tpl_component['IBAN_INFOS'] .= __('BIC/SWIFT', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['bic']) ) ? $iban_options['banktransfer']['bic'] : ''). '<br/>';
736 730
 								$tpl_component['IBAN_INFOS'] .= __('Account owner name', 'wpshop'). ' : '.( (!empty($iban_options['banktransfer']['accountowner']) ) ? $iban_options['banktransfer']['accountowner'] : ''). '<br/>';
737 731
 							}
738
-						}
739
-						else {
732
+						} else {
740 733
 							$tpl_component['IBAN_INFOS'] = '';
741 734
 						}
742
-					}
743
-					else {
735
+					} else {
744 736
 						$tpl_component['IBAN_INFOS'] = '';
745 737
 					}
746 738
 
@@ -748,8 +740,7 @@  discard block
 block discarded – undo
748 740
 					/** Received payements **/
749 741
 					if ( !$is_partial_payment && !$bon_colisage  && !empty($order_postmeta['order_invoice_ref']) ) {
750 742
 						$tpl_component['RECEIVED_PAYMENT'] = self::generate_received_payment_part( $order_id );
751
-					}
752
-					else {
743
+					} else {
753 744
 						$tpl_component['RECEIVED_PAYMENT'] = '';
754 745
 					}
755 746
 
@@ -758,12 +749,10 @@  discard block
 block discarded – undo
758 749
 					$tpl_component['INVOICE_FOOTER'] = self::generate_footer_invoice();
759 750
 
760 751
 					$output = wpshop_display::display_template_element('invoice_page_content', $tpl_component, array(), 'common');
761
-				}
762
-				else {
752
+				} else {
763 753
 					$output =  __('No order information has been found', 'wpshop');
764 754
 				}
765
-			}
766
-			else {
755
+			} else {
767 756
 				$output =  __('You requested a page that does not exist anymore. Please verify your request or ask the site administrator', 'wpshop');
768 757
 			}
769 758
 			return $output;
@@ -853,8 +842,7 @@  discard block
 block discarded – undo
853 842
 					$html2pdf->writeHTML($html_content);
854 843
 					$html2pdf->Output(WPSHOP_UPLOAD_DIR.$invoice_ref.'.pdf', 'F');
855 844
 					$is_ok = true;
856
-				}
857
-				catch (HTML2PDF_exception $e) {
845
+				} catch (HTML2PDF_exception $e) {
858 846
 					echo $e;
859 847
 					exit;
860 848
 				}
@@ -931,18 +919,15 @@  discard block
 block discarded – undo
931 919
 						$query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id= %d', $order_customer_info_value);
932 920
 						$civility = $wpdb->get_row($query);
933 921
 						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($civility) ) ? (!empty($civility->label)) ? $civility->label : __($civility->value, 'wpshop') : '';
934
-					}
935
-					else if( $order_customer_info_key == 'country') {
922
+					} else if( $order_customer_info_key == 'country') {
936 923
 						foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key=>$value) {
937 924
 							if ( $order_customer_info_value == $key) {
938 925
 								$tpl_component[strtoupper($order_customer_info_key)] = $value;
939 926
 							}
940 927
 						}
941
-					}
942
-					elseif( $order_customer_info_key == 'phone' ){
928
+					} elseif( $order_customer_info_key == 'phone' ){
943 929
 						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? __('Phone', 'wpshop').' : '.$order_customer_info_value : '';
944
-					}
945
-					else {
930
+					} else {
946 931
 						$tpl_component[strtoupper($order_customer_info_key)] = (!empty($order_customer_info_value) ) ? $order_customer_info_value : '';
947 932
 					}
948 933
 				}
Please login to merge, or discard this patch.