Changeset 3403989
- Timestamp:
- 11/27/2025 11:08:36 AM (3 months ago)
- Location:
- drivefx-woocommerce/trunk
- Files:
-
- 9 edited
-
PHCLibrary/invoices.php (modified) (2 diffs)
-
PHCLibrary/orders.php (modified) (6 diffs)
-
class.DriveFxWoocommerce.php (modified) (8 diffs)
-
drivefx-woocommerce-settings.php (modified) (2 diffs)
-
drivefx-woocommerce.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
settings/backend.php (modified) (13 diffs)
-
settings/import-products.php (modified) (2 diffs)
-
settings/syncro_gate.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
drivefx-woocommerce/trunk/PHCLibrary/invoices.php
r3160801 r3403989 448 448 if($response['result'][0]['draftRecord'] == 1){ 449 449 //Save ftstamp of invoice 450 $_SESSION['ftstamp'] = $response['result'][0]['ftstamp']; 451 $_SESSION['fno'] = $response['result'][0]['fno']; 450 $ftstamp = isset($response['result'][0]['ftstamp']) ? sanitize_text_field($response['result'][0]['ftstamp']) : ''; 451 $fno = isset($response['result'][0]['fno']) ? sanitize_text_field($response['result'][0]['fno']) : ''; 452 453 $_SESSION['ftstamp'] = $ftstamp; 454 $_SESSION['fno'] = $fno; 455 452 456 453 457 //Sign document … … 506 510 } else { 507 511 //Save id of customer 508 $_SESSION['numberClient'] = $response['result'][0]['no']; 509 512 $numberClient = isset($response['result'][0]['no']) 513 ? sanitize_text_field($response['result'][0]['no']) 514 : ''; 515 516 $_SESSION['numberClient'] = $numberClient; 517 510 518 //Set customer NIF if is generic customer 511 519 if($response['result'][0]['clivd'] == 1){ -
drivefx-woocommerce/trunk/PHCLibrary/orders.php
r3059006 r3403989 240 240 #Save internal document 241 241 $response = $this->utils_services->paramsSave($ch, $credentials, 'BoWS', $response); 242 //$this->logs->writeFileLog('save update order:', $response);242 $this->logs->writeFileLog('save update order:', $response); 243 243 244 244 if (curl_error($ch)) { … … 407 407 } 408 408 //$this->logs->writeFileLog('bis build:', $response['result'][0]['bis']); 409 $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response); 410 if (curl_error($ch)) { 411 $this->logs->writeFileLog('addNewOrder13.2', $ch); 412 } else if(empty($response)){ 413 $this->logs->writeFileLog('addNewOrder13.2', 'EMPTY RESPONSE'); 414 } else if(isset($response['messages'][0]['messageCodeLocale']) && $response['messages'][0]['messageCode']!='messages.Business.Stocks.InvalidRefAutoCreate'){ 415 $this->logs->writeFileLog('addNewOrder13.2', $response['messages'][0]['messageCodeLocale']); 416 } 409 417 410 418 #shipping … … 455 463 $bi->ivaincl = false; 456 464 } 457 $response['result'][0]['bis'][]= $bi;465 // $response['result'][0]['bis'][]= $bi; 458 466 } 459 467 //actEntity … … 684 692 array_push($response['result'][0]['bis'], $discount); 685 693 } 686 687 694 //actEntity 688 695 $response = $this->utils_services->actEntity($ch, $credentials, 'BoWS', $response); 689 //$this->logs->writeFileLog('actEntity2:', $response);690 696 691 697 if (curl_error($ch)) { … … 720 726 $response['result'][0]['obrano'] = $order->nextPostId; 721 727 } 728 //$this->logs->writeFileLog('addNewOrder15-bis', $response['result'][0]['bis']); 722 729 723 730 //Insert designation for products … … 726 733 if ($bis['ref'] == $product['ref'] && $bis['design'] == "") { 727 734 //fill the designation 735 $this->logs->writeFileLog('addNewOrder15', $bis); 736 728 737 $bis['design'] = $product['design']; 729 738 } 730 739 } 731 740 } 741 //$this->logs->writeFileLog('addNewOrder15', $response); 732 742 733 743 #Save internal document -
drivefx-woocommerce/trunk/class.DriveFxWoocommerce.php
r3394987 r3403989 251 251 add_settings_section('backend-section', null, null, 'backend-options'); 252 252 add_settings_field(null, null, null, 'backend-options', 'backend-section'); 253 register_setting('backend-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 254 253 register_setting('backend-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME, array( 254 'sanitize_callback' => function( $value ) { 255 if ( is_array( $value ) ) { 256 // Sanitizar recursivamente 257 return array_map( function( $item ) { 258 if ( is_array( $item ) ) { 259 return array_map( 'sanitize_text_field', $item ); 260 } 261 return sanitize_text_field( $item ); 262 }, $value ); 263 } 264 if ( !is_scalar( $value ) ) { 265 $value = json_encode($value); 266 } 267 return sanitize_text_field( $value ); 268 } 269 )); 270 271 255 272 // Import settings section 256 273 add_settings_section('import-section', null, null, 'import-options'); 257 274 add_settings_field(null, null, null, 'import-options', 'import-section'); 258 register_setting('import-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 259 } 260 261 public function register_scripts() { 262 ?> <script> 263 var pathPlugin = "<?php echo plugins_url('/' , __FILE__ ); ?>"; 264 </script> <?php 265 266 // register scripts that will be used later on 267 wp_register_script(DRIVEFXWOOCOMMERCE_PLUGIN_NAME, plugins_url('/js/'.DRIVEFXWOOCOMMERCE_PLUGIN_NAME.'.js' , __FILE__ )); 268 wp_register_script('datatable_min', plugins_url('/js/datatable_min.js' , __FILE__ )); 269 270 // register css that will be used later on 271 wp_register_style('style_datatable_jquery', plugins_url('/css/style_datatable_jquery.css' , __FILE__ )); 272 wp_register_style('datatable_css', plugins_url('/css/style_datatable.css' , __FILE__ )); 273 } 275 register_setting('import-options', DRIVEFXWOOCOMMERCE_PLUGIN_NAME, array( 276 'sanitize_callback' => function( $value ) { 277 if ( is_array( $value ) ) { 278 // Sanitizar recursivamente 279 return array_map( function( $item ) { 280 if ( is_array( $item ) ) { 281 return array_map( 'sanitize_text_field', $item ); 282 } 283 return sanitize_text_field( $item ); 284 }, $value ); 285 } 286 if ( !is_scalar( $value ) ) { 287 $value = json_encode($value); 288 } 289 return sanitize_text_field( $value ); 290 } 291 )); 292 293 } 294 295 296 public function register_scripts() { 297 ?> <script> 298 var pathPlugin = "<?php echo esc_url( plugins_url( '/', __FILE__ ) ); ?>"; 299 </script> <?php 300 301 // Register scripts 302 wp_register_script( 303 DRIVEFXWOOCOMMERCE_PLUGIN_NAME, 304 esc_url( plugins_url( '/js/' . DRIVEFXWOOCOMMERCE_PLUGIN_NAME . '.js', __FILE__ ) ), 305 array(), // dependencies 306 null, // version 307 true // in footer 308 ); 309 310 wp_register_script( 311 'datatable_min', 312 esc_url( plugins_url( '/js/datatable_min.js', __FILE__ ) ), 313 array('jquery'), // example dependency 314 null, 315 true 316 ); 317 318 // Register styles 319 wp_register_style( 320 'style_datatable_jquery', 321 esc_url( plugins_url( '/css/style_datatable_jquery.css', __FILE__ ) ), 322 array(), 323 null 324 ); 325 326 wp_register_style( 327 'datatable_css', 328 esc_url( plugins_url( '/css/style_datatable.css', __FILE__ ) ), 329 array(), 330 null 331 ); 332 333 } 334 335 336 /** 337 * Sanitize backend options 338 * 339 * @param mixed $value The value being sanitized. 340 * @return array Sanitized value. 341 */ 342 public function sanitize_backend_options( $value ) { 343 if ( ! is_array( $value ) ) { 344 return array(); 345 } 346 347 $sanitized = array(); 348 foreach ( $value as $key => $val ) { 349 $sanitized[ sanitize_key( $key ) ] = sanitize_text_field( $val ); 350 } 351 352 return $sanitized; 353 } 354 355 /** 356 * Sanitize import options 357 * 358 * @param mixed $value The value being sanitized. 359 * @return array Sanitized value. 360 */ 361 public function sanitize_import_options( $value ) { 362 if ( ! is_array( $value ) ) { 363 return array(); 364 } 365 366 $sanitized = array(); 367 foreach ( $value as $key => $val ) { 368 $sanitized[ sanitize_key( $key ) ] = sanitize_text_field( $val ); 369 } 370 371 return $sanitized; 372 } 373 274 374 275 375 # Create page of settings … … 500 600 $settings = apply_filters('woocommerce_email_settings', array( 501 601 array('type' => 'sectionend', 'id' => 'email_recipient_options' ), 502 array('title' => __( 'Email Sender Options', ' woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'woocommerce' ), 'id' => 'email_options' ),503 array('title' => __( '"From" Name', ' woocommerce' ),602 array('title' => __( 'Email Sender Options', 'drivefx-woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect the sender (email address and name) used in WooCommerce emails.', 'drivefx-woocommerce' ), 'id' => 'email_options' ), 603 array('title' => __( '"From" Name', 'drivefx-woocommerce' ), 504 604 'desc' => '', 505 605 'id' => 'woocommerce_email_from_name', … … 509 609 'autoload' => false 510 610 ), 511 array('title' => __( '"From" Email Address', ' woocommerce' ),611 array('title' => __( '"From" Email Address', 'drivefx-woocommerce' ), 512 612 'desc' => '', 513 613 'id' => 'woocommerce_email_from_address', … … 519 619 ), 520 620 array( 'type' => 'sectionend', 'id' => 'email_options' ), 521 array( 'title' => __( 'Email Template', ' woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>. For more advanced control copy <code>woocommerce/templates/emails/</code> to <code>yourtheme/woocommerce/emails/</code>.', 'woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ),522 array( 'title' => __( 'Header Image', ' woocommerce' ),523 'desc' => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the <a href="%s">media uploader</a>.', ' woocommerce' ), admin_url('media-new.php')),621 array( 'title' => __( 'Email Template', 'drivefx-woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customise the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>. For more advanced control copy <code>woocommerce/templates/emails/</code> to <code>yourtheme/woocommerce/emails/</code>.', 'drivefx-woocommerce' ), wp_nonce_url(admin_url('?preview_woocommerce_mail=true'), 'preview-mail')), 'id' => 'email_template_options' ), 622 array( 'title' => __( 'Header Image', 'drivefx-woocommerce' ), 623 'desc' => sprintf(__( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the <a href="%s">media uploader</a>.', 'drivefx-woocommerce' ), admin_url('media-new.php')), 524 624 'id' => 'woocommerce_email_header_image', 525 625 'type' => 'text', … … 528 628 'autoload' => false 529 629 ), 530 array('title' => __( 'Email Footer Text', ' woocommerce' ),531 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', ' woocommerce' ),630 array('title' => __( 'Email Footer Text', 'drivefx-woocommerce' ), 631 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', 'drivefx-woocommerce' ), 532 632 'id' => 'woocommerce_email_footer_text', 533 633 'css' => 'width:100%; height: 75px;', 534 634 'type' => 'textarea', 535 'default' => get_bloginfo('title') . ' - ' . __( 'Powered by WooCommerce', ' woocommerce' ),635 'default' => get_bloginfo('title') . ' - ' . __( 'Powered by WooCommerce', 'drivefx-woocommerce' ), 536 636 'autoload' => false 537 637 ), 538 array('title' => __( 'Base Colour', ' woocommerce' ),539 'desc' => __( 'The base colour for WooCommerce email templates. Default <code>#557da1</code>.', ' woocommerce' ),638 array('title' => __( 'Base Colour', 'drivefx-woocommerce' ), 639 'desc' => __( 'The base colour for WooCommerce email templates. Default <code>#557da1</code>.', 'drivefx-woocommerce' ), 540 640 'id' => 'woocommerce_email_base_color', 541 641 'type' => 'color', … … 545 645 ), 546 646 array( 547 'title' => __( 'Background Colour', ' woocommerce' ),548 'desc' => __( 'The background colour for WooCommerce email templates. Default <code>#f5f5f5</code>.', ' woocommerce' ),647 'title' => __( 'Background Colour', 'drivefx-woocommerce' ), 648 'desc' => __( 'The background colour for WooCommerce email templates. Default <code>#f5f5f5</code>.', 'drivefx-woocommerce' ), 549 649 'id' => 'woocommerce_email_background_color', 550 650 'type' => 'color', … … 554 654 ), 555 655 array( 556 'title' => __( 'Email Body Background Colour', ' woocommerce' ),557 'desc' => __( 'The main body background colour. Default <code>#fdfdfd</code>.', ' woocommerce' ),656 'title' => __( 'Email Body Background Colour', 'drivefx-woocommerce' ), 657 'desc' => __( 'The main body background colour. Default <code>#fdfdfd</code>.', 'drivefx-woocommerce' ), 558 658 'id' => 'woocommerce_email_body_background_color', 559 659 'type' => 'color', … … 563 663 ), 564 664 array( 565 'title' => __( 'Email Body Text Colour', ' woocommerce' ),566 'desc' => __( 'The main body text colour. Default <code>#505050</code>.', ' woocommerce' ),665 'title' => __( 'Email Body Text Colour', 'drivefx-woocommerce' ), 666 'desc' => __( 'The main body text colour. Default <code>#505050</code>.', 'drivefx-woocommerce' ), 567 667 'id' => 'woocommerce_email_text_color', 568 668 'type' => 'color', -
drivefx-woocommerce/trunk/drivefx-woocommerce-settings.php
r3059006 r3403989 14 14 15 15 <a href="https://www.phcgo.net/" target="_blank" title="PHC GO" class="alignleft" style="margin-right: 10px;"> 16 <img src="<?php echo plugins_url('images/logo_phcgo.svg', __FILE__) ?>" width="135" height="135">16 <img src="<?php echo esc_url( plugins_url('images/logo_phcgo.svg', __FILE__) ); ?>" width="135" height="135" alt="Logo"> 17 17 </a> 18 18 … … 26 26 <div class="clear"></div> 27 27 28 <h2 class="nav-tab-wrapper"> 29 <a href="?page=<?php echo DRIVEFXWOOCOMMERCE_PLUGIN_NAME ?>&tab=backend" class="nav-tab <?php echo $tab==='backend' ? 'nav-tab-active' : '' ?>">Backend Options</a> 30 <?php if(!empty($_SESSION['username'])){ ?> 31 <a href="?page=<?php echo DRIVEFXWOOCOMMERCE_PLUGIN_NAME ?>&tab=import" class="nav-tab <?php echo $tab==='import' ? 'nav-tab-active' : '' ?>">Import Products</a> 32 <?php } ?> 28 <h2 class="nav-tab-wrapper"> 29 <?php $page_name = esc_attr(DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 30 $tab_safe = isset($tab) ? sanitize_text_field($tab) : ''; 31 ?> 32 33 <a href="?page=<?php echo $page_name; ?>&tab=backend" class="nav-tab <?php echo ($tab_safe==='backend') ? 'nav-tab-active' : ''; ?>">Backend Options</a> 34 <?php if(!empty($_SESSION['username'])): ?> 35 <a href="?page=<?php echo $page_name; ?>&tab=import" class="nav-tab <?php echo ($tab_safe==='import') ? 'nav-tab-active' : ''; ?>">Import Products</a> 36 <?php endif; ?> 37 33 38 </h2> 34 39 -
drivefx-woocommerce/trunk/drivefx-woocommerce.php
r3394987 r3403989 3 3 * Plugin Name: PHC GO Commerce Sync 4 4 * Description: Easy integration between Woocommerce WordPress and your PHC GO software installation. 5 * Version: 5. 0.05 * Version: 5.1.0 6 6 * Author: Cegid PHC 7 7 * License: GPL v2 or later 8 8 * Author URI: https://phcsoftware.com/pt/phc-go 9 9 * Requires Plugins: woocommerce 10 * Text Domain: phcgo-commerce-sync10 * Text Domain: drivefx-woocommerce 11 11 */ 12 12 13 // Prevent direct access data leaks 13 // Prevent direct access data leaks 14 14 if ( ! defined( 'ABSPATH' ) ) { 15 15 exit; -
drivefx-woocommerce/trunk/readme.txt
r3399073 r3403989 1 1 === PHC GO Commerce Sync === 2 2 Contributors: phcgo 3 Tags: cegid, phc software, drivefx, fx, phc go, go, invoices, client, internal document, products, plugin, business3 Tags: cegid, phc go, invoices, commerce sync 4 4 Requires at least: 4.5 5 Tested up to: 6. 76 Stable tag: 5. 0.15 Tested up to: 6.8 6 Stable tag: 5.1.0 7 7 License: GPLv2 or later 8 8 Requires Plugins: woocommerce 9 9 10 10 11 Sync your online shop with your PHC GO accountingsoftware. Integrate your WooCommerce Orders, Customers, Products and PHC GO stocks.11 Sync your online shop with your PHC GO software. Integrate your WooCommerce Orders, Customers, Products and PHC GO stocks. 12 12 13 13 == Description == … … 93 93 * improvements and adjustments to information related with the plugin 94 94 95 = 5.1 = 96 * security improvements and adjustments 95 97 -
drivefx-woocommerce/trunk/settings/backend.php
r2964024 r3403989 2 2 // get stored settings 3 3 $settings = get_option(DRIVEFXWOOCOMMERCE_PLUGIN_NAME); 4 4 5 5 global $wpdb; 6 6 … … 33 33 </th> 34 34 <td> 35 <?php 36 if(is_array($settings['backend']['url'])){ 37 $settings['backend']['url'] = ''; 38 } ?> 39 <input class="regular-text" id="url" type="text" name="drivefx-woocommerce[backend][url]" value="<?php echo $settings['backend']['url'] ?>"> 35 <?php 36 // Inicializa $settings se não existir 37 if (!isset($settings) || !is_array($settings)) { 38 $settings = []; 39 } 40 41 // Inicializa $settings['backend'] como array, se não existir ou se for string 42 if (!isset($settings['backend']) || !is_array($settings['backend'])) { 43 $settings['backend'] = []; 44 } 45 46 // Agora podemos acessar com segurança 47 $backend_url = $settings['backend']['url'] ?? ''; // retorna string vazia se não existir 48 49 ?> 50 <input class="regular-text" id="url" type="text" name="drivefx-woocommerce[backend][url]" 51 value="<?php echo $settings['backend']['url'] ?? ''; ?>"> 40 52 41 53 <?php if(isset($resultDB->meta_value) && $resultDB->meta_value != ''){ ?> 42 54 <div id="backend_url_initialize" class="button button-primary" title="Autenticate plugin"> 43 <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Autenticate plugin"> 55 <img 56 id="plus" 57 src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>" 58 title="<?php echo esc_attr('Authenticate plugin'); ?>" 59 alt="Plus Icon" 60 > 44 61 <span id="autenticatePlugin">Re-Autenticate</span> 45 62 </div> … … 49 66 <?php } else { ?> 50 67 <div id="backend_url_initialize" class="button button-primary" title="Autenticate plugin"> 51 <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Autenticate plugin"> 68 <img 69 id="plus" 70 src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>" 71 title="<?php echo esc_attr('Authenticate plugin'); ?>" 72 alt="Plus Icon" 73 > 52 74 <span id="autenticatePlugin">Autenticate</span> 53 75 </div> … … 83 105 <tr> 84 106 <th scope="row"> 85 <label for="<?php echo $id ?>"><?php echo $opts['label']?></label>107 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 86 108 </th> 87 109 <td> 88 <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>"> 89 <span style='color:red;'>*</span> 90 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 91 </td> 110 <input 111 class="regular-text" 112 id="<?php echo esc_attr($id); ?>" 113 type="<?php echo esc_attr($opts['type']); ?>" 114 name="<?php echo esc_attr($name); ?>" 115 value="<?php echo esc_attr($value); ?>" 116 > 117 <span style="color:red;">*</span> 118 <?php if (isset($opts['descr'])): ?> 119 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 120 <?php endif; ?> 121 </td> 92 122 </tr> 93 123 <?php break; … … 95 125 ?><tr> 96 126 <th scope="row"> 97 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 98 </th> 99 <td> 100 <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>"> 101 <span style='color:red;'>*</span> 102 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 127 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 128 </th> 129 <td> 130 <input 131 class="regular-text" 132 id="<?php echo esc_attr($id); ?>" 133 type="<?php echo esc_attr($opts['type']); ?>" 134 name="<?php echo esc_attr($name); ?>" 135 value="<?php echo esc_attr($value); ?>" 136 > 137 <span style="color:red;">*</span> 138 <?php if (isset($opts['descr'])): ?> 139 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 140 <?php endif; ?> 103 141 </td> 104 142 </tr> … … 107 145 ?><tr> 108 146 <th scope="row"> 109 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 110 </th> 111 <td> 112 <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>"> 113 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 147 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 148 </th> 149 <td> 150 <input 151 class="regular-text" 152 id="<?php echo esc_attr($id); ?>" 153 type="<?php echo esc_attr($opts['type']); ?>" 154 name="<?php echo esc_attr($name); ?>" 155 value="<?php echo esc_attr($value); ?>" 156 > 157 <?php if (isset($opts['descr'])): ?> 158 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 159 <?php endif; ?> 114 160 </td> 115 161 </tr> … … 131 177 <th scope="row"> 132 178 <?php if($_SESSION['manageStockParameter'] === 'S' && $_SESSION['gamaDRIVEFX'] >= 9) { ?> 133 <label for="<?php echo $id?>">Create Clients, Orders and Invoices</label>179 <label for="<?php echo esc_attr($id); ?>">Create Clients, Orders and Invoices</label> 134 180 <?php } else { ?> 135 <label for="<?php echo $id?>">Create Clients and Invoices</label>181 <label for="<?php echo esc_attr($id); ?>">Create Clients and Invoices</label> 136 182 <?php } ?> 137 183 </th> … … 161 207 <tr> 162 208 <th scope="row"> 163 <label for="<?php echo $id ?>"><?php echo $opts['label']?></label>209 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 164 210 </th> 165 211 <td> … … 169 215 $checkbox = ''; 170 216 } ?> 171 <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"> 172 <span><?php echo $opts['checkboxDescription'] ?></span> 173 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 217 <input 218 style="width: 0;" 219 class="regular-text" 220 <?php echo esc_attr($checkedBox); ?> 221 id="<?php echo esc_attr($id); ?>" 222 type="<?php echo esc_attr($opts['type']); ?>" 223 name="<?php echo esc_attr($name); ?>" 224 > 225 <span><?php echo esc_html($opts['checkboxDescription']); ?></span> 226 <?php if (isset($opts['descr'])): ?> 227 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 228 <?php endif; ?> 174 229 </td> 175 230 </tr> … … 181 236 <tr> 182 237 <th scope="row"> 183 <label for="<?php echo $id ?>"><?php echo $opts['label']?></label>238 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 184 239 </th> 185 240 <td> … … 189 244 $checkbox = ''; 190 245 } ?> 191 <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"> 192 <span><?php echo $opts['checkboxDescription'] ?></span> 193 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 246 <input 247 style="width: 0;" 248 class="regular-text" 249 <?php echo esc_attr($checkedBox); ?> 250 id="<?php echo esc_attr($id); ?>" 251 type="<?php echo esc_attr($opts['type']); ?>" 252 name="<?php echo esc_attr($name); ?>" 253 > 254 <span><?php echo esc_html($opts['checkboxDescription']); ?></span> 255 <?php if (isset($opts['descr'])): ?> 256 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 257 <?php endif; ?> 194 258 </td> 195 259 </tr> … … 198 262 if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?> 199 263 <tr> 264 <th scope="row"> 265 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 266 </th> 267 <td> 268 <select id="<?php echo $id ?>" name="<?php echo $name ?>"> 269 <?php if(!empty($_SESSION[$id])){ ?> 270 <option value="0">Select one...</option> 271 <?php } 272 echo $_SESSION[$id]; ?> 273 </td> 274 </tr> 275 <?php } break; 276 // CC email 277 case 'emailCC': 278 if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?> 279 <tr> 280 <th scope="row"> 281 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 282 </th> 283 <td> 284 <input 285 class="regular-text" 286 id="<?php echo esc_attr($id); ?>" 287 type="<?php echo esc_attr($opts['type']); ?>" 288 name="<?php echo esc_attr($name); ?>" 289 value="<?php echo esc_attr($value); ?>" 290 > 291 <?php if (isset($opts['descr'])): ?> 292 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 293 <?php endif; ?> 294 </td> 295 </tr> 296 <?php } break; 297 // Text for email body 298 case 'emailBody': 299 if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?> 300 <tr> 301 <th scope="row"> 302 <label for="<?php echo esc_attr($id); ?>"><?php echo esc_html($opts['label']); ?></label> 303 </th> 304 <td> 305 <textarea 306 class="regular-text" 307 id="<?php echo esc_attr($id); ?>" 308 name="<?php echo esc_attr($name); ?>" 309 ><?php echo esc_textarea($value); ?></textarea> 310 311 <?php if (isset($opts['descr'])): ?> 312 <p class="description"><?php echo esc_html($opts['descr']); ?></p> 313 <?php endif; ?> 314 </td> 315 </tr> 316 <?php } break; 317 // Type of Invoice PT 318 case 'typeOfInvoice': 319 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 320 <tr> 321 <th scope="row"> 322 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 323 </th> 324 <td> 325 <select id="<?php echo $id ?>" name="<?php echo $name ?>"> 326 <?php if(!empty($_SESSION[$id])){ ?> 327 <option value="0">Select one...</option> 328 <?php } 329 echo $_SESSION[$id]; ?> 330 </td> 331 </tr> 332 <?php } break; 333 case 'typeOf_EU_Invoice': 334 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 335 <tr> 200 336 <th scope="row"> 201 337 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> … … 210 346 </tr> 211 347 <?php } break; 212 // CC email213 case 'emailCC':214 if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>215 <tr>216 <th scope="row">217 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>218 </th>219 <td>220 <input class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>" value="<?php echo $value ?>">221 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>222 </td>223 </tr>224 <?php } break;225 // Text for email body226 case 'emailBody':227 if((isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '') && (isset($settings['backend']['sendInvoice']) && $settings['backend']['sendInvoice'] != '')){ ?>228 <tr>229 <th scope="row">230 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>231 </th>232 <td>233 <textarea class="regular-text" id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"><?php echo $value ?></textarea>234 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p>235 </td>236 </tr>237 <?php } break;238 // Type of Invoice PT239 case 'typeOfInvoice':240 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>241 <tr>242 <th scope="row">243 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>244 </th>245 <td>246 <select id="<?php echo $id ?>" name="<?php echo $name ?>">247 <?php if(!empty($_SESSION[$id])){ ?>248 <option value="0">Select one...</option>249 <?php }250 echo $_SESSION[$id]; ?>251 </td>252 </tr>253 <?php } break;254 case 'typeOf_EU_Invoice':255 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?>256 <tr>257 <th scope="row">258 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label>259 </th>260 <td>261 <select id="<?php echo $id ?>" name="<?php echo $name ?>">262 <?php if(!empty($_SESSION[$id])){ ?>263 <option value="0">Select one...</option>264 <?php }265 echo $_SESSION[$id]; ?>266 </td>267 </tr>268 <?php } break;269 348 case 'toSignInvoice': 270 349 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 271 <tr> 272 <th scope="row"> 273 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 274 </th> 275 <td> 276 <?php if($value == 'on'){ 277 $checkedBox = 'checked'; 278 } else { 279 $checkbox = ''; 280 } ?> 281 <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"> 282 <span><?php echo $opts['checkboxDescription'] ?></span> 283 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 284 </td> 285 </tr> 286 287 <?php } break; 288 289 case 'fieldNif': 290 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 291 <tr> 292 <th scope="row"> 293 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 294 </th> 295 <td> 296 <select id="<?php echo $id ?>" name="<?php echo $name ?>"> 297 <?php echo $_SESSION[$id];?> 298 299 </td> 300 </tr> 301 <?php } break; 302 303 case 'includeTaxonSendCost': 350 <tr> 351 <th scope="row"> 352 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 353 </th> 354 <td> 355 <?php if($value == 'on'){ 356 $checkedBox = 'checked'; 357 } else { 358 $checkbox = ''; 359 } ?> 360 <input style="width: 0;" class="regular-text" <?php echo $checkedBox ?> id="<?php echo $id ?>" type="<?php echo $opts['type'] ?>" name="<?php echo $name ?>"> 361 <span><?php echo $opts['checkboxDescription'] ?></span> 362 <p class="description"><?php if (isset($opts['descr'])) echo $opts['descr'] ?></p> 363 </td> 364 </tr> 365 366 <?php } break; 367 368 case 'fieldNif': 369 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 370 <tr> 371 <th scope="row"> 372 <label for="<?php echo $id ?>"><?php echo $opts['label'] ?></label> 373 </th> 374 <td> 375 <select id="<?php echo $id ?>" name="<?php echo $name ?>"> 376 <?php echo $_SESSION[$id];?> 377 378 </td> 379 </tr> 380 <?php } break; 381 case 'includeTaxonSendCost': 304 382 if((isset($_SESSION['username']) && $_SESSION['username'] != '') && (isset($settings['backend']['createInvoice']) && $settings['backend']['createInvoice'] != '')){ ?> 305 383 <tr> -
drivefx-woocommerce/trunk/settings/import-products.php
r3147200 r3403989 11 11 <div id="loader"></div> 12 12 <div id="importToShop" class="button button-primary" title="List all products from PHC"> 13 <img id="list" src="<?php echo plugins_url('/../images/list.png', __FILE__) ?>" title="List all products from PHC"> List Products 13 <img 14 id="list" 15 src="<?php echo esc_url( plugins_url('../images/list.png', __FILE__) ); ?>" 16 title="<?php echo esc_attr('List all products from PHC'); ?>" 17 alt="List Products" 18 > List Products 14 19 </div> 15 20 … … 20 25 <div id="loader2"></div> 21 26 <div id="saveProductInShop" class="button button-primary" title="Import new products from PHC"> 22 <img id="plus" src="<?php echo plugins_url('/../images/plus.png', __FILE__) ?>" title="Save selected product in yout online store"> Import New Products 27 <img 28 id="plus" 29 src="<?php echo esc_url( plugins_url('../images/plus.png', __FILE__) ); ?>" 30 title="<?php echo esc_attr('Save selected product in your online store'); ?>" 31 alt="Import New Products" 32 > Import New Products 23 33 </div> 24 34 25 35 <?php if($_SESSION['manageStockParameter'] === 'S' && $_SESSION['gamaDRIVEFX'] >= 9){ ?> 26 36 <div id="updateStocks" class="button button-primary" title="Update stocks in your online store"> 27 <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all stocks of products from PHC"> Update Stocks 37 <img 38 id="plus" 39 src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>" 40 title="<?php echo esc_attr('Update all stocks of products from PHC'); ?>" 41 alt="Update Stocks" 42 > Update Stocks 28 43 </div> 29 44 <?php } ?> 30 45 31 46 <div id="updatePrices" class="button button-primary" title="Update prices in your online store"> 32 <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all prices of products from PHC"> Update Prices 47 <img 48 id="plus" 49 src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>" 50 title="<?php echo esc_attr('Update all prices of products from PHC'); ?>" 51 alt="Update Prices" 52 > Update Prices 33 53 </div> 34 54 35 55 <div id="updateAllFields" class="button button-primary" title="Update all fields of products from PHC"> 36 <img id="plus" src="<?php echo plugins_url('/../images/update.png', __FILE__) ?>" title="Update all data of products in your online store"> Update all Fields 56 <img 57 id="plus" 58 src="<?php echo esc_url( plugins_url('../images/update.png', __FILE__) ); ?>" 59 title="<?php echo esc_attr('Update all data of products in your online store'); ?>" 60 alt="Update all Fields" 61 > Update all Fields 37 62 </div> 38 63 -
drivefx-woocommerce/trunk/settings/syncro_gate.php
r3399073 r3403989 261 261 if(!empty($value)){ 262 262 // get shipping tax rate ID 263 $shipping_tax_rate_id = $key;263 $shipping_tax_rate_id = isset($key) ? intval($key) : 0; 264 264 } 265 265 } … … 269 269 // order shipping tax rate 270 270 $getShippingTax = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$shipping_tax_rate_id."' LIMIT 1")); 271 } else {271 } else { 272 272 //$this->logs->writeFileLog('Warning', 'Can not obtain the tax rate ID for shipping, so we apply manual calculation'); 273 273 } … … 488 488 489 489 // order tax rate country 490 $getTaxID = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".$wpdb->prefix."woocommerce_order_itemmeta WHERE meta_key='rate_id' ORDER BY order_item_id DESC LIMIT 1" ) ); 491 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$getTaxID."' LIMIT 1" ) ); 492 490 $getTaxID = $wpdb->get_var( $wpdb->prepare( 491 "SELECT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = %s ORDER BY order_item_id DESC LIMIT 1", 492 'rate_id' 493 ) ); 494 495 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( 496 "SELECT tax_rate_country FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1", 497 intval($getTaxID) 498 ) ); 493 499 //order Item ID 494 500 //$getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$product['design']."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) ); 495 $getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$wc_product->get_name()."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) ); 496 497 //order Item product by order Item ID 498 $item = new WC_Order_Item_Product($getOrderItemID); 501 $getOrderItemID = $wpdb->get_var( $wpdb->prepare( 502 "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_name = %s AND order_item_type = %s AND order_id = %d LIMIT 1", 503 $wc_product->get_name(), 504 'line_item', 505 intval($orderid) 506 ) ); 507 508 // order Item product by order Item ID 509 $item = new WC_Order_Item_Product($getOrderItemID); 499 510 500 511 // The product name … … 515 526 if(!empty($tax_rate_id)){ 516 527 // order item tax rate 517 $getTaxOrder = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1")); 518 } else { 528 $getTaxOrder = $wpdb->get_var( $wpdb->prepare( 529 "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1", 530 intval($tax_rate_id) 531 ) ); 532 } else { 519 533 $this->logs->writeFileLog('Warning', 'check the way to obtain the tax rate for items'); 520 534 } … … 551 565 $_SESSION['listOfValueItem'] = []; 552 566 553 foreach( $products as $product ) { 554 array_push($_SESSION['listOfSku'], $product->sku); 555 array_push($_SESSION['listOfQuantity'], $product->quantity); 556 array_push($_SESSION['listOfValueItem'], $product->value); 557 } 567 foreach( $products as $product ) { 568 // Sanitize SKU (text) 569 $sku = sanitize_text_field( $product->sku ); 570 571 // Sanitize quantity (integer) 572 $quantity = absint( $product->quantity ); 573 574 // Sanitize value (float) 575 $value = (float) $product->value; 576 577 // Push sanitized values to session 578 array_push($_SESSION['listOfSku'], $sku); 579 array_push($_SESSION['listOfQuantity'], $quantity); 580 array_push($_SESSION['listOfValueItem'], $value); 581 } 582 558 583 return $products; 559 584 } … … 671 696 # get product ref & design 672 697 global $wpdb; 673 $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $product['ref'])); 698 $product_id = $wpdb->get_var( $wpdb->prepare( 699 "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1", 700 '_sku', 701 $product['ref'] 702 ) ); 674 703 if(empty($product_id) && !empty($product['productId'])){ 675 704 $product_id = $product['productId']; … … 698 727 $tax_rate_id = $item->get_rate_id(); // Tax rate ID 699 728 } 700 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_country FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1" ) ); 701 729 $getTaxCountry = $wpdb->get_var( $wpdb->prepare( 730 "SELECT tax_rate_country FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1", 731 intval($tax_rate_id) 732 ) ); 702 733 //order Item ID 703 $getOrderItemID = $wpdb->get_var( $wpdb->prepare("SELECT order_item_id FROM ".$wpdb->prefix."woocommerce_order_items WHERE order_item_name ='".$wc_prod->get_name()."' and order_item_type = 'line_item' and order_id = '".$orderid."' LIMIT 1" ) ); 704 //order Item product by order Item ID 734 $getOrderItemID = $wpdb->get_var( $wpdb->prepare( 735 "SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_name = %s AND order_item_type = %s AND order_id = %d LIMIT 1", 736 $wc_prod->get_name(), 737 'line_item', 738 intval($orderid) 739 ) ); 740 //order Item product by order Item ID 705 741 $item = new WC_Order_Item_Product($getOrderItemID); 706 742 //$this->logs->writeFileLog('item', $item); … … 721 757 } 722 758 // order item tax rate 723 $getTaxProduct = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM ".$wpdb->prefix."woocommerce_tax_rates WHERE tax_rate_id='".$tax_rate_id."' LIMIT 1")); 724 } 759 $getTaxProduct = $wpdb->get_var( $wpdb->prepare( 760 "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d LIMIT 1", 761 intval($tax_rate_id) 762 ) ); 763 } 725 764 726 765 if (isset($getTaxCountry)){ … … 751 790 } 752 791 753 public function setFtProductsSession($ftProducts){ 754 //Save items of cart 755 $_SESSION['listOfSku'] = []; 756 $_SESSION['listOfQuantity'] = []; 757 $_SESSION['listOfValueItem'] = []; 758 759 foreach( $ftProducts as $ftProduct ) { 760 array_push($_SESSION['listOfSku'], $ftProduct->sku); 761 array_push($_SESSION['listOfQuantity'], $ftProduct->quantity); 762 array_push($_SESSION['listOfValueItem'], $ftProduct->value); 763 } 764 return $ftProducts; 765 } 792 public function setFtProductsSession($ftProducts) { 793 // Initialize arrays 794 $_SESSION['listOfSku'] = []; 795 $_SESSION['listOfQuantity'] = []; 796 $_SESSION['listOfValueItem'] = []; 797 798 foreach ($ftProducts as $ftProduct) { 799 // Sanitize SKU (string) 800 $sku = sanitize_text_field($ftProduct->sku); 801 802 // Sanitize Quantity (integer) 803 $quantity = absint($ftProduct->quantity); 804 805 // Sanitize Value (float) 806 $value = (float) $ftProduct->value; 807 808 // Push sanitized data to session 809 array_push($_SESSION['listOfSku'], $sku); 810 array_push($_SESSION['listOfQuantity'], $quantity); 811 array_push($_SESSION['listOfValueItem'], $value); 812 } 813 814 return $ftProducts; 815 } 816 766 817 767 818
Note: See TracChangeset
for help on using the changeset viewer.