diff --git a/www/vicidial/admin_modify_lead.php b/www/vicidial/admin_modify_lead.php index cca159be..bbd9c29a 100644 --- a/www/vicidial/admin_modify_lead.php +++ b/www/vicidial/admin_modify_lead.php @@ -437,9 +437,10 @@ if ($lead_id == 'NEW') $LOCAL_GMT_OFF_STD = $SERVER_GMT; $USarea = substr($phone_number, 0, 3); + $USprefix = substr($phone_number, 3, 1); $postalgmt=''; - $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,$USprefix); $comments = preg_replace("/\n/",'!N',$comments); $comments = preg_replace("/\r/",'',$comments); $stmt="INSERT INTO vicidial_list set status='" . mysqli_real_escape_string($link, $status) . "',title='" . mysqli_real_escape_string($link, $title) . "',first_name='" . mysqli_real_escape_string($link, $first_name) . "',middle_initial='" . mysqli_real_escape_string($link, $middle_initial) . "',last_name='" . mysqli_real_escape_string($link, $last_name) . "',address1='" . mysqli_real_escape_string($link, $address1) . "',address2='" . mysqli_real_escape_string($link, $address2) . "',address3='" . mysqli_real_escape_string($link, $address3) . "',city='" . mysqli_real_escape_string($link, $city) . "',state='" . mysqli_real_escape_string($link, $state) . "',province='" . mysqli_real_escape_string($link, $province) . "',postal_code='" . mysqli_real_escape_string($link, $postal_code) . "',country_code='" . mysqli_real_escape_string($link, $country_code) . "',alt_phone='" . mysqli_real_escape_string($link, $alt_phone) . "',phone_number='$phone_number',phone_code='$phone_code',email='" . mysqli_real_escape_string($link, $email) . "',security_phrase='" . mysqli_real_escape_string($link, $security) . "',comments='" . mysqli_real_escape_string($link, $comments) . "',rank='" . mysqli_real_escape_string($link, $rank) . "',owner='" . mysqli_real_escape_string($link, $owner) . "',vendor_lead_code='" . mysqli_real_escape_string($link, $vendor_id) . "', list_id='" . mysqli_real_escape_string($link, $list_id) . "',date_of_birth='" . mysqli_real_escape_string($link, $date_of_birth) . "',gmt_offset_now='$gmt_offset',entry_date=NOW();"; diff --git a/www/vicidial/functions.php b/www/vicidial/functions.php index 4c738a0d..4a16623f 100644 --- a/www/vicidial/functions.php +++ b/www/vicidial/functions.php @@ -24,6 +24,7 @@ # 150210-1358 - Added precision S default to 0 in sec_convert # 150216-1528 - Fixed non-latin problem, issue #828 # 150514-1522 - Added lookup_gmt function, copied from agc/functions.php +# 150516-1206 - Added missing TZCODE segment to gmt_lookup function # ##### BEGIN validate user login credentials, check for failed lock out ##### @@ -418,7 +419,7 @@ function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metr ##### 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,$postalgmt,$postal_code,$owner,$USprefix) { global $link; @@ -442,6 +443,52 @@ 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_to_mysqli($stmt, $link); + $pc_recs = mysqli_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysqli_fetch_row($rslt); + $gmt_offset = $row[0]; $gmt_offset = preg_replace("/\+/i","",$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_to_mysqli($stmt, $link); + $pc_recs = mysqli_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysqli_fetch_row($rslt); + $dst_range = $row[0]; + if (strlen($dst_range)>2) {$dst = 'Y';} + } + } + if ( (preg_match("/NANPA/i",$tz_method)) && (strlen($USarea)>2) && (strlen($USprefix)>2) ) + { + $stmt="select GMT_offset,DST from vicidial_nanpa_prefix_codes where areacode='$USarea' and prefix='$USprefix';"; + $rslt=mysql_to_mysqli($stmt, $link); + $pc_recs = mysqli_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysqli_fetch_row($rslt); + $gmt_offset = $row[0]; $gmt_offset = preg_replace("/\+/i","",$gmt_offset); + $dst = $row[1]; + $dst_range = ''; + if ($dst == 'Y') + {$dst_range = 'SSM-FSN';} + $PC_processed++; + $postalgmt_found++; + $post++; + } + } if ($postalgmt_found < 1) { $PC_processed=0;