Mwalker has submitted this change and it was merged.
Change subject: zero-left-pad zipcode during import-checks
......................................................................
zero-left-pad zipcode during import-checks
autodetect line endings
Change-Id: Ie22184a139eebb1bc6d3dc470330cd9c50faa793
---
M sites/all/modules/offline2civicrm/import_checks.drush.inc
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
Mwalker: Verified; Looks good to me, approved
diff --git a/sites/all/modules/offline2civicrm/import_checks.drush.inc
b/sites/all/modules/offline2civicrm/import_checks.drush.inc
index 0b82599..4748149 100644
--- a/sites/all/modules/offline2civicrm/import_checks.drush.inc
+++ b/sites/all/modules/offline2civicrm/import_checks.drush.inc
@@ -47,6 +47,7 @@
$args = drush_get_arguments();
$filename = $args[1];
+ ini_set( 'auto_detect_line_endings', true );
if( ( $file = fopen( $filename, 'r' )) === FALSE ){
watchdog('offline2civicrm', 'Import checks: Could not
open file for reading: ' . $filename, array(), WATCHDOG_ERROR);
return;
@@ -109,10 +110,16 @@
// CiviCRM gets all weird when there is no country set
// Making the assumption that none = US
if( _get_value( 'Country', $row, $headers ) == ''){
- // set to the default, no TY will be sent
$msg['country'] = "US";
} else {
$msg['country'] = _get_value( 'Country', $row,
$headers );
+ }
+
+ if ( $msg['country'] === "US" ) {
+ // left-pad the zipcode
+ if ( preg_match( '/^(\d{1,4})(-\d+)?$/',
$msg['postal_code'], $matches ) ) {
+ $msg['postal_code'] = str_pad(
$matches[1], 5, "0", STR_PAD_LEFT ) . $matches[2];
+ }
}
// Generating a transaction id so that we don't import
the same rows multiple times
@@ -127,6 +134,7 @@
continue;
}
+ //TODO un-nest
try {
$contribution =
wmf_civicrm_contribution_message_import( $msg );
}
--
To view, visit https://gerrit.wikimedia.org/r/52551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie22184a139eebb1bc6d3dc470330cd9c50faa793
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/civicrm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits