Changeset 3454441
- Timestamp:
- 02/05/2026 10:05:10 AM (2 weeks ago)
- Location:
- shift8-integration-for-gravity-forms-and-sap-business-one/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
shift8-gravitysap.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shift8-integration-for-gravity-forms-and-sap-business-one/trunk/readme.txt
r3454222 r3454441 5 5 * Requires at least: 5.0 6 6 * Tested up to: 6.8 7 * Stable tag: 1.3. 77 * Stable tag: 1.3.8 8 8 * Requires PHP: 7.4 9 9 * License: GPLv3 … … 104 104 105 105 == Changelog == 106 107 = 1.3.8 = 108 * **FIX**: Test data values now properly save with "Update Settings" button 109 * **ENHANCEMENT**: Test data fields moved into main settings form for consistent save behavior 106 110 107 111 = 1.3.7 = -
shift8-integration-for-gravity-forms-and-sap-business-one/trunk/shift8-gravitysap.php
r3454222 r3454441 4 4 * Plugin URI: https://github.com/stardothosting/shift8-gravitysap 5 5 * Description: Integrates Gravity Forms with SAP Business One, automatically creating Business Partners from form submissions. 6 * Version: 1.3. 76 * Version: 1.3.8 7 7 * Author: Shift8 Web 8 8 * Author URI: https://shift8web.ca … … 28 28 29 29 // Plugin constants 30 define('SHIFT8_GRAVITYSAP_VERSION', '1.3. 7');30 define('SHIFT8_GRAVITYSAP_VERSION', '1.3.8'); 31 31 define('SHIFT8_GRAVITYSAP_PLUGIN_FILE', __FILE__); 32 32 define('SHIFT8_GRAVITYSAP_PLUGIN_DIR', plugin_dir_path(__FILE__)); … … 542 542 </td> 543 543 </tr> 544 545 <?php if (!empty(rgar($settings, 'field_mapping'))): ?> 546 <tr> 547 <th scope="row"><?php esc_html_e('Test Data Values', 'shift8-gravity-forms-sap-b1-integration'); ?></th> 548 <td> 549 <?php $this->render_test_data_table($settings); ?> 550 </td> 551 </tr> 552 <?php endif; ?> 544 553 </table> 545 554 … … 1359 1368 <input type="hidden" name="subview" value="sap_integration" /> 1360 1369 1370 <!-- Hidden inputs for test values - populated from main form by JavaScript --> 1371 <div id="test-values-hidden-container"></div> 1372 1361 1373 <h3><?php esc_html_e('Test SAP Integration', 'shift8-gravity-forms-sap-b1-integration'); ?></h3> 1362 1374 <p><?php esc_html_e('Send test data to SAP Business One to validate your field mapping configuration.', 'shift8-gravity-forms-sap-b1-integration'); ?></p> 1363 1364 <?php $this->render_test_data_table($settings); ?> 1375 <p class="description"><?php esc_html_e('Uses the Test Data Values from the settings above. Save your settings first to update test values.', 'shift8-gravity-forms-sap-b1-integration'); ?></p> 1365 1376 1366 1377 <p class="submit"> … … 1371 1382 </p> 1372 1383 </form> 1384 1385 <script type="text/javascript"> 1386 jQuery(document).ready(function($) { 1387 // Before submitting test form, copy test values from main form 1388 $('#test-sap-form').on('submit', function() { 1389 var container = $('#test-values-hidden-container'); 1390 container.empty(); 1391 1392 // Copy all test_values inputs from main form to hidden container 1393 $('input[name^="test_values["]').each(function() { 1394 var name = $(this).attr('name'); 1395 var value = $(this).val(); 1396 container.append('<input type="hidden" name="' + name + '" value="' + value + '">'); 1397 }); 1398 }); 1399 }); 1400 </script> 1373 1401 <?php endif; ?> 1374 1402 <?php … … 1383 1411 private function render_test_data_table($settings) { 1384 1412 $field_mapping = rgar($settings, 'field_mapping', array()); 1413 $saved_test_values = rgar($settings, 'test_values', array()); 1385 1414 1386 1415 // Use the SAME field array as the mapping table … … 1404 1433 'BPAddresses.Country' => 'US', 1405 1434 ); 1435 1436 // Merge saved values over defaults (saved values take priority) 1437 $test_values = array_merge($default_test_values, $saved_test_values); 1406 1438 ?> 1407 1408 <table class="form-table"> 1409 <tr> 1410 <th scope="row"> 1411 <label><?php esc_html_e('Test Data', 'shift8-gravity-forms-sap-b1-integration'); ?></label> 1412 </th> 1413 <td> 1414 <table class="widefat field-mapping-table"> 1415 <thead> 1416 <tr> 1417 <th><?php esc_html_e('SAP Field', 'shift8-gravity-forms-sap-b1-integration'); ?></th> 1418 <th><?php esc_html_e('Test Value', 'shift8-gravity-forms-sap-b1-integration'); ?></th> 1419 </tr> 1420 </thead> 1421 <tbody> 1422 <?php foreach ($sap_fields as $sap_field => $label): ?> 1423 <?php $mapped_field_id = rgar($field_mapping, $sap_field); ?> 1424 <?php if (!empty($mapped_field_id)): ?> 1425 <tr> 1426 <td><?php echo esc_html($label); ?></td> 1427 <td> 1428 <input type="text" 1429 name="test_values[<?php echo esc_attr($sap_field); ?>]" 1430 value="<?php echo esc_attr(rgar($default_test_values, $sap_field)); ?>" 1431 class="regular-text" /> 1432 </td> 1433 </tr> 1434 <?php endif; ?> 1435 <?php endforeach; ?> 1436 </tbody> 1437 </table> 1438 <p class="description"> 1439 <?php esc_html_e('These test values will be sent to SAP Business One using your current field mapping configuration.', 'shift8-gravity-forms-sap-b1-integration'); ?> 1440 <br><strong><?php esc_html_e('Note:', 'shift8-gravity-forms-sap-b1-integration'); ?></strong> 1441 <?php esc_html_e('Use state codes (CA, NY) not full names, and 2-letter country codes (US, CA) to avoid SAP field length errors.', 'shift8-gravity-forms-sap-b1-integration'); ?> 1442 </p> 1443 </td> 1444 </tr> 1439 <table class="widefat field-mapping-table"> 1440 <thead> 1441 <tr> 1442 <th><?php esc_html_e('SAP Field', 'shift8-gravity-forms-sap-b1-integration'); ?></th> 1443 <th><?php esc_html_e('Test Value', 'shift8-gravity-forms-sap-b1-integration'); ?></th> 1444 </tr> 1445 </thead> 1446 <tbody> 1447 <?php foreach ($sap_fields as $sap_field => $label): ?> 1448 <?php $mapped_field_id = rgar($field_mapping, $sap_field); ?> 1449 <?php if (!empty($mapped_field_id)): ?> 1450 <tr> 1451 <td><?php echo esc_html($label); ?></td> 1452 <td> 1453 <input type="text" 1454 name="test_values[<?php echo esc_attr($sap_field); ?>]" 1455 value="<?php echo esc_attr(rgar($test_values, $sap_field)); ?>" 1456 class="regular-text" /> 1457 </td> 1458 </tr> 1459 <?php endif; ?> 1460 <?php endforeach; ?> 1461 </tbody> 1445 1462 </table> 1463 <p class="description"> 1464 <?php esc_html_e('These test values will be sent to SAP Business One when you click "Test Integration" below.', 'shift8-gravity-forms-sap-b1-integration'); ?> 1465 <br><strong><?php esc_html_e('Note:', 'shift8-gravity-forms-sap-b1-integration'); ?></strong> 1466 <?php esc_html_e('Use SAP codes (e.g., 102 for Group, USD for Currency), state codes (CA, NY), and 2-letter country codes (US, CA).', 'shift8-gravity-forms-sap-b1-integration'); ?> 1467 </p> 1446 1468 <?php 1447 1469 } … … 1475 1497 'create_quotation' => rgpost('sap_create_quotation') === '1' ? '1' : '0', 1476 1498 'field_mapping' => array(), 1477 'quotation_field_mapping' => array() 1499 'quotation_field_mapping' => array(), 1500 'test_values' => array() 1478 1501 ); 1502 1503 // Save test values 1504 $test_values = rgpost('test_values'); 1505 if (is_array($test_values)) { 1506 $allowed_fields = $this->get_allowed_sap_fields(); 1507 foreach ($test_values as $field => $value) { 1508 if (in_array($field, $allowed_fields, true)) { 1509 if ($field === 'EmailAddress' || strpos($field, 'E_Mail') !== false) { 1510 $settings['test_values'][$field] = sanitize_email($value); 1511 } else { 1512 $settings['test_values'][$field] = sanitize_text_field($value); 1513 } 1514 } 1515 } 1516 } 1479 1517 1480 1518 // Validate and sanitize Business Partner field mapping
Note: See TracChangeset
for help on using the changeset viewer.