@@ -26,21 +26,34 @@ my $dsn = "DBI:mysql:database=$cfg{database};host=$cfg{dbhost};port=0";
26
26
my $dbh = DBI-> connect ($dsn , @{cfg }{qw( dbuser dbpassword) })
27
27
or die " Cannot connect to db: " .$DBI::errstr ;
28
28
my $sth = $dbh -> prepare(<<SQL );
29
- SELECT s .username , d .domain , r .recur , r .id
29
+ SELECT s .username , d .domain , r .recur , r .id , vup . value as lang
30
30
FROM provisioning .voip_reminder r
31
31
LEFT JOIN provisioning .voip_subscribers s ON r .subscriber_id = s .id
32
32
LEFT JOIN provisioning .voip_domains d ON s .domain_id = d .id
33
33
LEFT JOIN billing .v_subscriber_timezone tz ON tz .uuid = s .uuid
34
- WHERE
35
- r .active = 1
36
- AND r .time = time_format(CONVERT_TZ(now(), " localtime" , tz .name ), ' %H:%i:00' );
34
+ LEFT JOIN provisioning .voip_usr_preferences vup ON r .subscriber_id = vup .subscriber_id
35
+ LEFT JOIN provisioning .voip_preferences vp ON vp .id = vup .attribute_id
36
+ WHERE r .active = 1
37
+ AND vp .attribute = " language"
38
+ AND r .time = time_format(CONVERT_TZ(now(), " localtime" , tz .name ), ' %H:%i:00' )
39
+ UNION
40
+ SELECT s .username , d .domain , r .recur , r .id , vdp .value as lang
41
+ FROM provisioning .voip_reminder r
42
+ LEFT JOIN provisioning .voip_subscribers s ON r .subscriber_id = s .id
43
+ LEFT JOIN provisioning .voip_domains d ON s .domain_id = d .id
44
+ LEFT JOIN billing .v_subscriber_timezone tz ON tz .uuid = s .uuid
45
+ LEFT JOIN provisioning .voip_dom_preferences vdp ON vdp .domain_id = d .id
46
+ LEFT JOIN provisioning .voip_preferences vp ON vp .id = vdp .attribute_id
47
+ WHERE r .active = 1
48
+ AND vp .attribute = " language"
49
+ AND r .time = time_format(CONVERT_TZ(now(), " localtime" , tz .name ), ' %H:%i:00' ) LIMIT 1 ;
37
50
SQL
38
51
my $sth_d = $dbh -> prepare(" UPDATE voip_reminder SET active=0 WHERE id=?" );
39
52
40
53
$sth -> execute() or die " Cannot execute: " .$DBI::errstr ;
41
54
42
55
while (my $ref = $sth -> fetchrow_hashref()) {
43
- print " $ref ->{'username'}\@ $ref ->{'domain'}, recur=$ref ->{'recur'}\n " ;
56
+ print " $ref ->{'username'}\@ $ref ->{'domain'}, recur=$ref ->{'recur'}, language= $ref ->{'lang'} \n " ;
44
57
45
58
if ($ref -> {' recur' } eq " weekdays" ) {
46
59
my ($sec ,$min ,$hour ,$mday ,$mon ,$year ,$wday ,$yday ,$isdst ) = gmtime (time );
@@ -62,6 +75,7 @@ while (my $ref = $sth->fetchrow_hashref()) {
62
75
print $tmp " Extension: s\n " ;
63
76
print $tmp " Context: $cfg {context}\n " ;
64
77
print $tmp " Priority: 1\n " ;
78
+ print $tmp " Setvar: LANG=$ref ->{'lang'}\n " ;
65
79
close $tmp ;
66
80
67
81
my ($login ,$pass ,$uid ,$gid ) = getpwnam ($owner )
0 commit comments