diff --git a/UPGRADE b/UPGRADE index 68460168..c91fa13b 100644 --- a/UPGRADE +++ b/UPGRADE @@ -539,6 +539,11 @@ OTHER CHANGES: all of the leads inside the lists set to this campaign in order to call them in the order you have specified. +122. Added option to use the owner field to define a time zone abbreviation code + Works across web/api/cli lead loading methods. There is also an option + in the time zone updating script to use this method. + + diff --git a/bin/ADMIN_adjust_GMTnow_on_leads.pl b/bin/ADMIN_adjust_GMTnow_on_leads.pl index 50fba1aa..3425274f 100644 --- a/bin/ADMIN_adjust_GMTnow_on_leads.pl +++ b/bin/ADMIN_adjust_GMTnow_on_leads.pl @@ -27,6 +27,7 @@ # 91129-2155 - Replaced SELECT STAR queries with field lists, formatting fixes # 100117-2122 - Added force-date option and activated FSO-FSA and LSS-FSA # 110406-0652 - Added omitlistid option +# 110424-0834 - Added ownertimezone option # use Time::Local; @@ -61,6 +62,7 @@ if (length($ARGV[0])>1) print " [--nanpa-prefix-gmt] = Attempt nanpa prefix lookup for timezones\n"; print " [--singlelistid=XXX] = Only lookup and alter leads in one list_id\n"; print " [--omitlistid=XXX-YYY-ZZZ] = Skip these list_ids, separated by dash\n"; + print " [--ownertimezone] = Check the owner field for time zone abbreviation: (EST,CST,etc...)\n"; print " [--force-date=YYYY-MM-DD] = Force this date as date to run\n"; print "\n"; @@ -97,6 +99,11 @@ if (length($ARGV[0])>1) $searchNANPA=1; if ($q < 1) {print "\n----- DO NANPA PREFIX LOOKUP -----\n\n";} } + if ($args =~ /--ownertimezone/i) + { + $ownertimezone=1; + if ($q < 1) {print "\n----- OWNER TIMEZONE CHECK -----\n\n";} + } if ($args =~ /-singlelistid=/i) { @data_in = split(/-singlelistid=/,$args); @@ -243,6 +250,7 @@ if (length($omitlistidSQL)> 0) {$omitlistidSQL = "where list_id NOT IN('$omitlistidSQL')";} } else {$XomitlistidSQL=''; $omitlistidSQL='';} + $stmtA = "select distinct phone_code from vicidial_list $listSQL $omitlistidSQL;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -250,7 +258,7 @@ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_countY=0; @phone_codes=@MT; -$phone_codes_list='|'; +$phone_codes_list="'"; while ($sthArows > $rec_countY) { @@ -260,20 +268,46 @@ while ($sthArows > $rec_countY) $phone_codes_ORIG[$rec_countY] = $aryA[0]; $phone_codes[$rec_countY] =~ s/011|0011| |\t|\r|\n//gi; - # if ( ($phone_codes_list !~ /\|$phone_codes[$rec_countY]\|/) && (length($phone_codes[$rec_countY]) > 0) ) - # { - # $phone_codes_list .= "$phone_codes[$rec_countY]|"; - # } + $phone_codes_list .= "$aryA[0]'"; if ($DBX) {print "|",$aryA[0],"|","\n";} $rec_countY++; } $sthA->finish(); if ($DB) {print " - Unique Country dial codes found: $rec_countY\n";} +if (length($phone_codes_list)<2) {$phone_codes_list="''";} +if ($ownertimezone > 0) + { + $stmtA = "select distinct tz_code,GMT_offset,country_code from vicidial_phone_codes where country_code IN($phone_codes_list);"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countC=0; + @tz_codes=@MT; + @tz_offset=@MT; + @tz_country=@MT; + $tz_codes_list='|'; + + while ($sthArows > $rec_countC) + { + @aryA = $sthA->fetchrow_array; + + $tz_codes[$rec_countC] = $aryA[0]; + $tz_offset[$rec_countC] = $aryA[1]; + $tz_country[$rec_countC] = $aryA[2]; + + $tz_codes_list .= "$aryA[0]|"; + + $rec_countC++; + } + $sthA->finish(); + if ($DB) {print " - Unique time zone codes found: $rec_countC $tz_codes_list\n";} + } ##### Put all country/area code records into an array for speed -$stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes;"; +$stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description,tz_code from vicidial_phone_codes;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -283,7 +317,7 @@ $rec_countZ=0; while ($sthArows > $rec_countZ) { @aryA = $sthA->fetchrow_array; - $codefile[$rec_countZ] = "$aryA[0]\t$aryA[1]\t$aryA[2]\t$aryA[3]\t$aryA[4]\t$aryA[5]\t$aryA[6]\t$aryA[7]\n"; + $codefile[$rec_countZ] = "$aryA[0]\t$aryA[1]\t$aryA[2]\t$aryA[3]\t$aryA[4]\t$aryA[5]\t$aryA[6]\t$aryA[7]\t$aryA[8]\n"; $rec_countZ++; } @@ -887,6 +921,188 @@ foreach (@phone_codes) $TOTALnanpa_updated_count = ($TOTALnanpa_updated_count + $nanpa_updated_count); + + + + ##### START RUN LOOP FOR EACH TIME ZONE CODE RECORD ##### + $tzcode_updated_count=0; + if ($ownertimezone > 0) + { + if ($DB) {print "TIME ZONE CODE RUN START...\n";} + $e=0; + foreach (@tz_codes) + { + $area_GMT_method=''; + $area_GMT = $tz_offset[$e]; + $area_GMT =~ s/\+//gi; + $area_GMT = ($area_GMT + 0); + + $stmtA = "select distinct DST_range from vicidial_phone_codes where tz_code='$tz_codes[$e]' and country_code='$tz_country[$e]' order by DST_range desc limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @aryA = $sthA->fetchrow_array; + $area_GMT_method = $aryA[0]; + $sthA->finish(); + + if ($DBX) {print "PROCESSING THIS TIME ZONE CODE: $tz_codes[$e]|$tz_country[$e]|$area_GMT|$area_GMT_method\n";} + + $stmtA = "select count(*) from vicidial_list where owner='$tz_codes[$e]' and phone_code='$tz_country[$e]' $XlistSQL $XomitlistidSQL;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countZ=0; + @aryA = $sthA->fetchrow_array; + $rec_countZ = $aryA[0]; + $sthA->finish(); + + if (!$rec_countZ) + { + # if ($DB) {print " IGNORING: $tzcodefile[$e]\n";} + $ei++; + } + else + { + $AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($time + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$hour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + + if ( (!$AC_processed) && ($area_GMT_method =~ /SSM-FSN/) ) + { + if ($DBX) {print " Second Sunday March to First Sunday November\n";} + &USACAN_dstcalc; + if ($DBX) {print " DST: $USACAN_DST\n";} + if ($USACAN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &NA_dstcalc; + if ($DBX) {print " DST: $NA_DST\n";} + if ($NA_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-FSA/) ) + { + if ($DBX) {print " First Sunday October to First Sunday April\n";} + &AUSE_dstcalc; + if ($DBX) {print " DST: $AUSE_DST\n";} + if ($AUSE_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSS-FSA/) ) + { + if ($DBX) {print " Last Sunday September to First Sunday April\n";} + &NZLN_dstcalc; + if ($DBX) {print " DST: $NZLN_DST\n";} + if ($NZLN_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /TSO-LSF/) ) + { + if ($DBX) {print " Third Sunday October to Last Sunday February\n";} + &BZL_dstcalc; + if ($DBX) {print " DST: $BZL_DST\n";} + if ($BZL_DST) {$area_GMT++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($AC_processed) + { + $stmtA = "select count(*) from vicidial_list where owner='$tz_codes[$e]' and phone_code='$tz_country[$e]' and (gmt_offset_now != '$area_GMT' or gmt_offset_now IS NULL) $XlistSQL $XomitlistidSQL;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countW=0; + @aryA = $sthA->fetchrow_array; + $rec_countW = $aryA[0]; + $sthA->finish(); + + if (!$rec_countW) + { + if ($DBX) {print " ALL GMT ALREADY CORRECT FOR : $tz_codes[$e] $tz_country[$e] $area_GMT\n";} + $ei++; + } + else + { + $stmtA = "UPDATE vicidial_list set gmt_offset_now='$area_GMT' where owner='$tz_codes[$e]' and phone_code='$tz_country[$e]' and (gmt_offset_now != '$area_GMT' or gmt_offset_now IS NULL) $XlistSQL $XomitlistidSQL;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + $tzcode_updated_count = ($tzcode_updated_count + $affected_rows); + } + $Prec_countW = sprintf("%8s", $rec_countW); + if ($DB) {print " $Prec_countW records in $tz_codes[$e] $tz_country[$e] updated to $area_GMT\n";} + $ee++; + # sleep(1); + } + } + } + + $ep++; + $e++; + } + } + ##### STOP RUN LOOP FOR EACH TIME ZONE CODE RECORD ##### + if($DB){print "Time Zone Code Updates: $tzcode_updated_count\n";} + $TOTALtzcode_updated_count = ($TOTALtzcode_updated_count + $tzcode_updated_count); + + + $d++; } @@ -898,6 +1114,7 @@ if($DB){print "\nGRAND TOTALS:\n";} if($DB){print "Postal Updates: $TOTALpostal_updated_count\n";} if($DB){print "Area Code Updates: $TOTALarea_updated_count\n";} if($DB){print "NANPA Updates: $TOTALnanpa_updated_count\n";} +if($DB){print "TIME ZONE Updates: $TOTALtzcode_updated_count\n";} if($DB){print "\nDONE\n";} $secy = time(); $secz = ($secy - $secX); $minz = ($secz/60); # calculate script runtime so far if ($q < 1) {print " - process runtime ($secz sec) ($minz minutes)\n";} diff --git a/bin/ADMIN_area_code_populate.pl b/bin/ADMIN_area_code_populate.pl index d9909e33..33d2fcc2 100644 --- a/bin/ADMIN_area_code_populate.pl +++ b/bin/ADMIN_area_code_populate.pl @@ -1,8 +1,8 @@ #!/usr/bin/perl # -# ADMIN_area_code_populate.pl version 2.2.0 +# ADMIN_area_code_populate.pl version 2.4 # -# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # Description: # server application that allows load areacodes into to asterisk list database @@ -18,6 +18,7 @@ # 90204-0806 - Added duplicate check to nanpa list loading # 90317-2353 - Added city, state, postal_code, country to nanpa format # 100902-1536 - Move old data files if wgetting new ones +# 110424-0735 - Added timezone abbreviation column # @@ -25,7 +26,7 @@ $PATHconf = "/etc/astguiclient.conf"; $domain = "http://phonecodes.vicidial.com"; #$URL1 = "$domain/phone_codes_GMT-latest.txt"; -$URL1 = "$domain/phone_codes_GMT-latest-220.txt"; +$URL1 = "$domain/phone_codes_GMT-latest-24.txt"; $URL2 = "$domain/GMT_USA_zip-latest.txt"; @@ -285,7 +286,7 @@ else print STDERR "Downloading latest phone codes tables\n"; # move old files - `mv -f $PATHhome/phone_codes_GMT-latest-220.txt $PATHhome/phone_codes_GMT-latest-220-old.txt`; + `mv -f $PATHhome/phone_codes_GMT-latest-24.txt $PATHhome/phone_codes_GMT-latest-24-old.txt`; `mv -f $PATHhome/GMT_USA_zip-latest.txt $PATHhome/GMT_USA_zip-latest-old.txt`; # get files @@ -293,8 +294,8 @@ else `wget $URL2`; } - #### BEGIN vicidial_phone_codes population from phone_codes_GMT-latest-220.txt file #### - open(codefile, "$PATHhome/phone_codes_GMT-latest-220.txt") || die "can't open $PATHhome/phone_codes_GMT-latest-220.txt: $!\n"; + #### BEGIN vicidial_phone_codes population from phone_codes_GMT-latest-24.txt file #### + open(codefile, "$PATHhome/phone_codes_GMT-latest-24.txt") || die "can't open $PATHhome/phone_codes_GMT-latest-24.txt: $!\n"; @codefile = ; close(codefile); if ( ($purge_table > 0) && ($#codefile > 10) ) @@ -316,6 +317,7 @@ else if ($codefile[$pc] !~ /GEOGRAPHIC DESCRIPTION/) { $pc++; + $row[8] =~ s/\r|\n|\t| $//gi; $row[7] =~ s/\r|\n|\t| $//gi; $row[6] =~ s/\r|\n|\t| $//gi; $row[5] =~ s/\r|\n|\t| $//gi; @@ -324,7 +326,7 @@ else $row[2] =~ s/\r|\n|\t| $//gi; $row[1] =~ s/\r|\n|\t| $//gi; $row[0] =~ s/\r|\n|\t| $//gi; - $ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]'), "; + $ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]', '$row[8]'), "; if ($pc =~ /00$/) { chop($ins_stmt); diff --git a/bin/AST_DB_calltime_change.pl b/bin/AST_DB_calltime_change.pl index 914ef095..e20e3001 100644 --- a/bin/AST_DB_calltime_change.pl +++ b/bin/AST_DB_calltime_change.pl @@ -147,7 +147,7 @@ use DBI; $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; -##### change Pacific Mountain +##### change call time $stmtA = "UPDATE vicidial_call_times set call_time_comments='auto-modified $timestamp' $startSQL $stopSQL where call_time_id='$calltime';"; if($DB){print STDERR "\n|$stmtA|\n";} diff --git a/bin/AST_call_log_export.pl b/bin/AST_call_log_export.pl index 92717813..845ed3c7 100644 --- a/bin/AST_call_log_export.pl +++ b/bin/AST_call_log_export.pl @@ -9,11 +9,12 @@ # # /usr/share/astguiclient/AST_call_log_export.pl --campaign=GOODB-GROUP1-GROUP3-GROUP4-SPECIALS-DNC_BEDS --output-format=tab-basic --debug --filename=BEDSsaleDATETIME.txt --email-list=test@gmail.com --email-sender=test@test.com # -# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 # # CHANGES # 100310-0112 - First version # 110202-2214 - Added ncad14csv format +# 110423-0350 - Do not die on email issue # $txt = '.txt'; @@ -543,7 +544,7 @@ if ( (length($Ealert)>5) && (length($email_list) > 3) ) $mail{body} .= "$boundary"; $mail{body} .= "--\n"; - sendmail(%mail) or die $mail::Sendmail::error; + sendmail(%mail); # or die $mail::Sendmail::error; if (!$Q) {print "ok. log says:\n", $mail::sendmail::log;} ### print mail log for status } diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 73e26827..78cbf7d4 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -50,9 +50,10 @@ # 100624-2143 - Added dccsvref52 file format # 100928-1121 - Added file-prefix-filter option # 110420-0944 - Fixed file prefix issue with multiple processes running +# 110424-0948 - Added time-zone-code-gmt option to use time zone code from the owner field # -$version = '110420-0944'; +$version = '110424-0948'; $secX = time(); $MT[0]=''; @@ -166,6 +167,7 @@ if (length($ARGV[0])>1) print " [--duplicate-tap-list-check] = checks for the same title/alt-number in the same list ID before inserting lead\n"; print " [--duplicate-tap-system-check] = checks for the same title/alt-number in the entire system before inserting lead\n"; print " [--postal-code-gmt] = checks for the time zone based on the postal code given where available\n"; + print " [--time-zone-code-gmt] = checks for the time zone based on the owner field time zone code given where available\n"; print " [--ftp-pull] = grabs lead files from a remote FTP server, uses REPORTS FTP login information\n"; print " [--ftp-dir=leads_in] = remote FTP server directory to grab files from, should have a DONE sub-directory\n"; print " [--email-list=test@test.com:test2@test.com] = send email results for each file to these addresses\n"; @@ -310,6 +312,11 @@ if (length($ARGV[0])>1) $postalgmt=1; if ($q < 1) {print "\n----- POSTAL CODE TIMEZONE -----\n\n";} } + if ($args =~ /-time-zone-code-gmt/i) + { + $tzcodegmt=1; + if ($q < 1) {print "\n----- TZ CODE TIMEZONE -----\n\n";} + } if ($args =~ /-new-list-for-each-file/i) { @@ -1754,6 +1761,40 @@ foreach(@FILES) $sthA->finish(); } } + if ( ($tzcodegmt > 0) && (length($owner)>1) ) + { + $dst_range=''; + $dst='N'; + $gmt_offset=0; + + $stmtA="select GMT_offset from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $gmt_offset = $aryA[0]; $gmt_offset =~ s/\+| //gi; + $PC_processed++; + $postalgmt_found++; + } + $sthA->finish(); + + $stmtA = "select distinct DST_range from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' order by DST_range desc limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $dst_range = $aryA[0]; + if (length($dst_range)>2) {$dst = 'Y';} + if ($DBX) {print " TZcode GMT record found for $owner: |$gmt_offset|$dst|$dst_range|\n";} + } + $sthA->finish(); + } if ($postalgmt_found < 1) { $PC_processed=0; diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index a8248ac9..42cd82ef 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -56,6 +56,7 @@ Changes: 110316-2035 - Added reset_time variable and NAMEPHONE dup search 110404-1356 - Added uniqueid search parameter to recording_lookup function 110409-0822 - Added run_time logging of API functions +110424-0854 - Added option for time zone code lookups using owner field in add_lead function @@ -301,6 +302,9 @@ duplicate_check - Check for duplicate records in the system, can select more tha custom_fields - Y or N, default is N. Defines whether the API will accept custom field data when inserting leads into the vicidial_list table For custom fields to be inserted, just add the field label as a variable to the URL string For example, if the field_label is "favorite_color" you would add "&favorite_color=blue" +tz_method - , POSTAL or TZCODE, default is which will use the country code and areacode for time zone lookups + POSTAL relies on the postal_code field + TZCODE relies on the owner field being populated with a proper time zone code (for fields with spaces in the values, you can replace the space with a plus + sign[address, city, first_name, etc...]) OPTIONAL FIELDS- diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index cf9c3fb3..64edf904 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -880,7 +880,8 @@ state VARCHAR(4), GMT_offset VARCHAR(6), DST enum('Y','N'), DST_range VARCHAR(8), -geographic_description VARCHAR(30) +geographic_description VARCHAR(30), +tz_code VARCHAR(4) default '' ); CREATE TABLE vicidial_inbound_groups ( @@ -2454,7 +2455,7 @@ ALTER TABLE vicidial_call_notes_archive MODIFY notesid INT(9) UNSIGNED NOT NULL; CREATE TABLE vicidial_lead_search_log_archive LIKE vicidial_lead_search_log; ALTER TABLE vicidial_lead_search_log_archive MODIFY search_log_id INT(9) UNSIGNED NOT NULL; -UPDATE system_settings SET db_schema_version='1269',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1270',db_schema_update_date=NOW(); GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/extras/upgrade_2.4.sql b/extras/upgrade_2.4.sql index e64415ba..955fa64a 100644 --- a/extras/upgrade_2.4.sql +++ b/extras/upgrade_2.4.sql @@ -735,3 +735,7 @@ UPDATE system_settings SET db_schema_version='1268',db_schema_update_date=NOW(); ALTER TABLE vicidial_api_log ADD run_time VARCHAR(20) default '0'; UPDATE system_settings SET db_schema_version='1269',db_schema_update_date=NOW(); + +ALTER TABLE vicidial_phone_codes ADD tz_code VARCHAR(4) default ''; + +UPDATE system_settings SET db_schema_version='1270',db_schema_update_date=NOW(); diff --git a/www/vicidial/admin_listloader_third_gen.php b/www/vicidial/admin_listloader_third_gen.php index 5b6a5f41..08c9b255 100644 --- a/www/vicidial/admin_listloader_third_gen.php +++ b/www/vicidial/admin_listloader_third_gen.php @@ -2,7 +2,7 @@ # admin_listloader_third_gen.php - version 2.4 # (based upon - new_listloader_superL.php script) # -# Copyright (C) 2010 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2011 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # ViciDial web-based lead loader from formatted file # @@ -40,10 +40,11 @@ # 100707-1156 - Made it so you cannot submit with no lead file selected. Also fixed Start Over Link # 100712-1416 - Added entry_list_id field to vicidial_list to preserve link to custom fields if any # 100728-0900 - Filtered uploaded filenames for unsupported characters +# 110424-0926 - Added option for time zone code in the owner field # -$version = '2.4-39'; -$build = '100728-0900'; +$version = '2.4-40'; +$build = '110424-0926'; require("dbconnect.php"); @@ -439,7 +440,7 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard") ) ) Lead Time Zone Lookup: - +          @@ -824,7 +825,7 @@ if ($OK_to_process) else {$phone_list .= "$phone_number$US$list_id|";} - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner); if (strlen($custom_SQL)>3) { @@ -1204,7 +1205,7 @@ if (($leadfile) && ($LF_path)) else {$phone_list .= "$phone_number$US$list_id|";} - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner); if ($multi_insert_counter > 8) { @@ -1450,7 +1451,7 @@ exit; -function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner) { global $link; @@ -1474,6 +1475,35 @@ function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$ } } } + if ( ($postalgmt=="TZCODE") && (strlen($owner)>1) ) + { + $dst_range=''; + $dst='N'; + $gmt_offset=0; + + $stmt="select GMT_offset from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[0]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $PC_processed++; + $postalgmt_found++; + $post++; + } + + $stmt = "select distinct DST_range from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' order by DST_range desc limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dst_range = $row[0]; + if (strlen($dst_range)>2) {$dst = 'Y';} + } + } + if ($postalgmt_found < 1) { $PC_processed=0; diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 8964a8c0..0c7c1e1d 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -46,10 +46,11 @@ # 110316-2035 - Added reset_time variable and NAMEPHONE dup search # 110404-1356 - Added uniqueid search parameter to recording_lookup function # 110409-0822 - Added run_time logging of API functions +# 110424-0854 - Added option for time zone code lookups using owner field # -$version = '2.4-32'; -$build = '110409-0822'; +$version = '2.4-33'; +$build = '110424-0854'; $startMS = microtime(); @@ -240,6 +241,8 @@ if (isset($_GET["reset_time"])) {$reset_time=$_GET["reset_time"];} elseif (isset($_POST["reset_time"])) {$reset_time=$_POST["reset_time"];} if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["tz_method"])) {$tz_method=$_GET["tz_method"];} + elseif (isset($_POST["tz_method"])) {$tz_method=$_POST["tz_method"];} header ("Content-type: text/html; charset=utf-8"); @@ -365,6 +368,7 @@ if ($non_latin < 1) $delete_leads=ereg_replace("[^A-Z]","",$delete_leads); $reset_time=ereg_replace("[^-_0-9]","",$reset_time); $uniqueid=ereg_replace("[^- \.\_0-9a-zA-Z]","",$uniqueid); + $tz_method = ereg_replace("[^-\_0-9a-zA-Z]","",$tz_method); } else { @@ -385,7 +389,6 @@ $CIDdate = date("mdHis"); $ENTRYdate = date("YmdHis"); $ip = getenv("REMOTE_ADDR"); $MT[0]=''; -$postalgmt=''; $api_script = 'non-agent'; $api_logging = 1; @@ -2832,7 +2835,7 @@ if ($function == 'add_lead') ### get current gmt_offset of the phone_number - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner); ### insert a new lead in the system with this phone number @@ -3472,7 +3475,7 @@ if ($function == 'update_lead') else { ### get current gmt_offset of the phone_number - $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code); + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner); if (strlen($status)<1) {$status='NEW';} @@ -3688,12 +3691,12 @@ exit; ##### LOOKUP GMT, FINDS THE CURRENT GMT OFFSET FOR A PHONE NUMBER ##### -function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code) +function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$tz_method,$postal_code,$owner) { require("dbconnect.php"); $postalgmt_found=0; -if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) +if ( (eregi("POSTAL",$tz_method)) && (strlen($postal_code)>4) ) { if (preg_match('/^1$/', $phone_code)) { @@ -3712,6 +3715,34 @@ if ( (eregi("POSTAL",$postalgmt)) && (strlen($postal_code)>4) ) } } } +if ( ($tz_method=="TZCODE") && (strlen($owner)>1) ) + { + $dst_range=''; + $dst='N'; + $gmt_offset=0; + + $stmt="select GMT_offset from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[0]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $PC_processed++; + $postalgmt_found++; + $post++; + } + + $stmt = "select distinct DST_range from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' order by DST_range desc limit 1;"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $dst_range = $row[0]; + if (strlen($dst_range)>2) {$dst = 'Y';} + } + } if ($postalgmt_found < 1) { $PC_processed=0;