From ab5cbf2c8ace7498f2fcd59a00cf0de1feeaa6a1 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 16 Mar 2018 11:56:34 +0000 Subject: [PATCH] Translated phrases fixes, issue #1081 Added AST_expired_list_exporter.pl script git-svn-id: svn://192.168.202.10@2944 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../trunk/bin/AST_expired_list_exporter.pl | 436 ++++++++++++++++++ agc_2-X/trunk/www/vicidial/admin.php | 9 +- .../trunk/www/vicidial/admin_lists_custom.php | 7 +- 3 files changed, 445 insertions(+), 7 deletions(-) create mode 100644 agc_2-X/trunk/bin/AST_expired_list_exporter.pl diff --git a/agc_2-X/trunk/bin/AST_expired_list_exporter.pl b/agc_2-X/trunk/bin/AST_expired_list_exporter.pl new file mode 100644 index 00000000..204326b6 --- /dev/null +++ b/agc_2-X/trunk/bin/AST_expired_list_exporter.pl @@ -0,0 +1,436 @@ +#!/usr/bin/perl +# +# AST_expired_list_exporter.pl +# +# This program can export and transfer defunct lists/leads from the dialer +# when they are moved to a holding campaign of the user's choice, and then +# delete them from the system when the export and transfer are complete. +# Settings are determined by creation of a setting container in the admin +# interface, whose name must be passed to the script at the time of it's +# execution, as shown below. +# +# 0 1 * * * /usr/share/astguiclient/AST_expired_list_exporter.pl --container_id=TEST +# +# This program assumes that a setting container exists in the dialer whose +# name matches the name of the container_id passed to the script. There are +# seven settings that can be recognized by this script: +# --campaign_id (required, name of holding campaign) +# --last_call_date_days (required, number of days list must be inactive before purging) +# --custom_ftp_host (required, FTP host) +# --custom_ftp_user (required, FTP user) +# --custom_ftp_pwd (required, FTP password) +# --ftp_passive (optional, set to a non-zero value to FTP transfer in passive mode, defaults to active if not set) +# --custom_ftp_port (optional, defaults to 21) +# --destination_folder (optional, used for specifying a destination folder to +# transfer to once logged into the FTP account) +# +# Copyright (C) 2018 Matt Florell , Joe Johnson LICENSE: AGPLv2 +# +# 180307-2120 - First Build +# + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$FTPdate = "$year-$mon-$mday"; +$timestamp="$year$mon$mday$hour$min$sec"; + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; +$FTPdb=0; +$FTPpassive=0; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) + {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) + {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} + if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) + {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} + if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) + {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) + {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} + if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) + {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} + if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) + {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} + $i++; + } + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n"; + print " [--help] = this screen\n"; + print " [--debug] = debug\n"; + print " [--debugX] = super debug\n"; + print " [--FTPdb] = show FTP debug output\n"; + print " [--test] = will execute script and transfer files, but not delete lists from dialer\n"; + print " [--container_id=XXX] = System settings container to pull info from\n"; + print "\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER DEBUG -----\n\n"; + } + if ($args =~ /--FTPdb/i) + { + $FTPdb=1; + print "\n----- FTP DEBUG -----\n\n"; + } + if ($args =~ /--test/i) + { + $T=1; + print "\n----- TEST EXECUTION -----\n\n"; + } + if ($args =~ /--container_id/i) + { + my @data_in = split(/--container_id=/,$args); + $container_id = $data_in[1]; + $container_id =~ s/ .*//gi; + if ($DB) {print "\n----- SYSTEM CONTAINER: $container_id -----\n\n";} + } + } + } + +if (!-d "$PATHweb/vicidial/export_bkups") { + `mkdir $PATHweb/vicidial/export_bkups`; + if (!-d "$PATHweb/vicidial/export_bkups") { + print "Directory $PATHweb/vicidial/export_bkups does not exist and can't be created.\n"; + exit; + } +} + +if (!$container_id) { + print "Missing required container_id variable\n"; + exit; +} + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP +if (!$VARDB_port) {$VARDB_port='3306';} + +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +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; +$dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; +$dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; +$dbhD = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +$header_stmt="show columns from vicidial_list"; +$header_rslt=$dbhA->prepare($header_stmt); +$header_rslt->execute(); +$CSV_header=""; +while (@header_row=$header_rslt->fetchrow_array) + { + $CSV_header.="\"$header_row[0]\","; + # print $header_row[0]."\n"; + } + +$stmt="select * from vicidial_settings_containers where container_id='$container_id' and container_type='PERL_CLI'"; +if ($DBX) {print "\n$stmt\n\n";} +$rslt=$dbhA->prepare($stmt); +$rslt->execute(); +if ($rslt->rows>0) + { + @row=$rslt->fetchrow_array; + $row[4]=~s/\r//g; + @container_settings=split(/\n/, $row[4]); + for ($i=0; $iprepare($list_stmt); + $list_rslt->execute(); + $lists_to_export=$list_rslt->rows; + + if ($lists_to_export>0) + { + use Net::Ping; + use Net::FTP; + + $p = Net::Ping->new(); + $ping_good = $p->ping("$VARFTP_host"); + if (!$ping_good) + { + $p = Net::Ping->new("icmp"); + $ping_good = $p->ping("$VARFTP_host"); + } + + if ($ping_good) + { + $ftp = Net::FTP->new("$custom_ftp_host", Port => $custom_ftp_port, Passive => $FTPpassive, Debug => $FTPdb); + $ftp->login("$custom_ftp_user","$custom_ftp_pwd"); + if ($destination_folder) {$ftp->cwd("$destination_folder");} + } + else + { + if($DB){print "ERROR: Could not ping server $VARFTP_host\n";} + exit; + } + } + else + { + if($DB){print "No lists to export\n";} + exit; + } + + $l=0; + while ($l<$lists_to_export) + { + @list_row=$list_rslt->fetchrow_array; + $list_id=$list_row[0]; + + $export_filename="EXPORT_".$list_id."_".$timestamp.".csv"; + + $custom_tbl_stmt="show tables like 'custom_".$list_id."'"; + if ($DBX) {print "\n$custom_tbl_stmt\n";} + $custom_tbl_rslt=$dbhC->prepare($custom_tbl_stmt); + $custom_tbl_rslt->execute(); + $CSV_custom_header=""; + if ($custom_tbl_rslt->rows==1) + { + $pull_custom_info=1; + $col_stmt="show columns from custom_".$list_id; + $col_rslt=$dbhD->prepare($col_stmt); + $col_rslt->execute(); + while (@col_row=$col_rslt->fetchrow_array) + { + $CSV_custom_header.="\"$col_row[0]\","; + } + $col_rslt->finish; + } + $custom_tbl_rslt->finish; + + $CSV_full_header=$CSV_header.$CSV_custom_header; + $CSV_full_header=~s/,$//; + + open(EXPORT, "> $PATHweb/vicidial/export_bkups/$export_filename"); + print EXPORT $CSV_full_header."\n"; + + $exp_stmt="select * from vicidial_list where list_id='$list_id' order by lead_id asc"; + if ($DBX) {print "\n$exp_stmt\n";} + $exp_rslt=$dbhC->prepare($exp_stmt); + $exp_rslt->execute(); + while (@exp_row=$exp_rslt->fetchrow_array) + { + $CSV_data=""; + $lead_id=$exp_row[0]; + for ($q=0; $qprepare($cdata_stmt); + $cdata_rslt->execute(); + if ($cdata_rslt->rows>0) + { + @cdata_row=$cdata_rslt->fetchrow_array; + for ($c=1; $cfinish; + } + $CSV_data=~s/,$//; + print EXPORT $CSV_data."\n"; + } + $exp_rslt->finish; + + close(EXPORT); + $ExportFileSize = (-s "$PATHweb/vicidial/export_bkups/$export_filename"); + + + $ftp->binary(); + $ftp->put("$PATHweb/vicidial/export_bkups/$export_filename", "$export_filename"); + $FTPfilesize = $ftp->size("$export_filename"); + if($DBX){print STDERR "FTP FILESIZE: $FTPfilesize/$ExportFileSize | $export_filename\n";} + + if ( !$FTPfilesize || (($ExportFileSize > 100) && ($FTPfilesize < 100)) ) + { + print "ERROR! File did not transfer, exiting: $FTPfilesize / $ExportFileSize | $export_filename\n"; + exit; + } + + if (!$T) + { + $del_stmt="delete from vicidial_list where list_id='$list_id'"; + $del_rslt=$dbhC->prepare($del_stmt); + $del_rslt->execute(); + $del_rslt->finish; + + $del_stmt="delete from vicidial_lists where list_id='$list_id'"; + $del_rslt=$dbhC->prepare($del_stmt); + $del_rslt->execute(); + $del_rslt->finish; + + $del_stmt="delete from vicidial_hopper where list_id='$list_id'"; + $del_rslt=$dbhC->prepare($del_stmt); + $del_rslt->execute(); + $del_rslt->finish; + } + + $l++; + } + + $list_rslt->finish; + + } +else + { + if ($DB) {print "No setting container \"$conatiner_id\" of type PERL_CLI found.\n";} + exit; + } + +$rslt->finish; + diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 2b3bf7ea..be0c9d49 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -4326,12 +4326,13 @@ else # 180306-1718 - Added script_top_dispo feature # 180310-2230 - Added bulk change function for campaign and ingroup ranks in user modify page # 180310-2321 - Added source_id_display system option +# 180316-0751 - Translated phrases fixes, issue #1081 # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-664a'; -$build = '180310-2321'; +$admin_version = '2.14-665a'; +$build = '180316-0751'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -22506,7 +22507,7 @@ if ($ADD==31) echo "$NWB#campaigns-list_order_mix$NWE"; @@ -24883,7 +24884,7 @@ if ($ADD==34) echo "$NWB#campaigns-list_order_mix$NWE"; diff --git a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php index e9625908..4f1f5701 100644 --- a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php +++ b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php @@ -49,10 +49,11 @@ # 171116-1544 - Added option for duplicate custom field entries(field_duplicate) # 180123-1817 - cleanup of enc code # 180125-1733 - Added more reserved words from MySQL/MariaDB +# 180316-0754 - Translated phrases fixes, issue #1081 # -$admin_version = '2.14-41'; -$build = '180125-1733'; +$admin_version = '2.14-42'; +$build = '180316-0754'; require("dbconnect_mysqli.php"); require("functions.php"); @@ -1110,7 +1111,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) echo "$A_field_rank[$o] - $A_field_order[$o]     "; echo " $LcolorB$A_field_label[$o]$LcolorE     "; echo " $A_field_name[$o]     "; - echo " $A_field_type[$o]     "; + echo " "._QXZ("$A_field_type[$o]")."     "; if ($hide_enc < 1) { echo " $A_field_encrypt[$o]     ";