Adding cms_alert option

This commit is contained in:
ragu 2023-04-05 07:41:11 +02:00
parent cc82e0856a
commit b7e6c91efd
13 changed files with 106 additions and 54 deletions

View file

@ -14,6 +14,7 @@ use POSIX;
use CGI; # only for debugging
use JSON;
use Digest::MD5 qw(md5 md5_hex);
use Digest::SHA qw(sha256_base64);
use Scalar::Util qw(looks_like_number);
use DateTime;
use DateTime::Format::Pg;
@ -3059,7 +3060,9 @@ sub authorization(){
my $pass_name = $q->escapeHTML($user_pw);
$pass_name =~ s/\s//g;
my $pwmd5=md5_hex($pass_name);
my $pwsha256=sha256_base64($pass_name);
$authref->{txt11} = "$pwmd5";
#$authref->{txt04} = "$pwsha256";#enable after migration
#Servicetool, only users with users.int09=1
#shareetool

View file

@ -23,7 +23,6 @@ use Mod::DBtank;
use Mod::Basework;
use Mod::Shareework;
use Mod::APIfunc;
use Digest::MD5 qw(md5 md5_hex);
use Data::Dumper;
use Sys::Hostname;
my $hostname = hostname;

View file

@ -1799,7 +1799,7 @@ sub search_json(){
my $table = shift;
my $search = shift || "";
my $template_id = shift || "";
my $c_id = shift || "";
my $c_id = shift || 0;
my $catch_equal = shift || 0;
my $sel = "1=2";

View file

@ -16,7 +16,6 @@ use DBI;
use Apache2::RequestUtil ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(OK);
use Digest::MD5 qw(md5 md5_hex);
use Scalar::Util qw(looks_like_number);
use Lib::Config;
@ -386,6 +385,8 @@ sub handler {
if($users_dms->{u_id} && $users_dms->{int08} == 2){
if($R::rel_edit eq "save_ctuser" && $R::main_id && $R::main_id >= 200000){
$return = $pl->save_service_desc($q,$R::c_id,$users_dms);
}elsif($R::rel_edit eq "save_user"){
$feedb = $pl->save_content($q,$users_dms,$node_meta,$R::c_id) if(looks_like_number($R::c_id));
}elsif($R::base_edit eq "new_contentcms" && $R::main_id && $R::main_id >= 200000){
$feedb = $pl->new_content($q,$users_dms);
}elsif($R::base_edit eq "save_contentcms" && $R::main_id && $R::main_id >= 200000){
@ -402,7 +403,7 @@ sub handler {
}
#DMS Faktura
if($R::ct_trans && $node_meta->{ct_table} eq "contenttrans"){
if($node_meta->{ct_table} eq "contenttrans"){
$bw->log("DMS action from $users_dms->{u_id} on $node_meta->{ct_table}",$q,"");
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
my $users_dms_primary = { u_id => 0 };

View file

@ -577,23 +577,26 @@ sub preinit(){
#SET state alias Zahlung buchen
if($R::set_state && !$R::close_time){
my $state = $R::state || "";
my $sum_paid = "null";
my $sum_operatorcredit = "null";
my $state = $R::state || "";
$update_ctt->{state} = "$state";
$update_ctt->{int14} = 2;#set OPOS
if($R::set_state eq "buchen" && $R::sum_paid){
$sum_paid = $R::sum_paid;
$sum_paid =~ s/,/\./;
$update_ctt->{int01} = $sum_paid;
}
my $sum_operatorcredit = "null";
if($R::set_state eq "buchen" && $R::sum_operatorcredit){
$sum_operatorcredit = $R::sum_operatorcredit;
$sum_operatorcredit =~ s/,/\./;
$update_ctt->{int02} = $sum_operatorcredit;
$update_ctt->{int14} = "null";
}
$update_ctt->{state} = "$state";
$update_ctt->{int14} = 2;#set OPOS
$u_rows += $dbt->update_record($dbh,$update_ctt,$ctt);
if($state =~ /payone/){

View file

@ -15,13 +15,14 @@ use CGI; # only for debugging
use LWP::UserAgent;
use URI::Encode;
use JSON;
use Scalar::Util qw(looks_like_number);
use Lib::Config;
use Mod::DBtank;
use Mod::Basework;
use Data::Dumper;
my $q = new CGI;
my $cf = new Config;
my $dbt = new DBtank;
my $bw = new Basework;
@ -104,9 +105,10 @@ sub sms_ack_digest {
sub sms_message {
my $self = shift;
my $todo = shift;
my $hotline = shift;
my $contact_hotline = shift;
my $sms_to = shift;
my $bike = shift;
my %varenv = $cf->envonline();
my $sms_from = "Mietradinfo";
my $sms_message = "";
@ -126,18 +128,24 @@ sub sms_message {
#todo locking_progress
if($todo eq "locking_progress"){
$sms_message .= "Ihre Miete von $bike wurde nicht beendet! Ihre kostenpflichtige Miete läuft weiter! Stellen Sie sicher, dass das Schloss geschlossen ist. $hotline";
$sms_message .= "Ihre Miete von $bike wurde nicht beendet! Ihre kostenpflichtige Miete läuft weiter! Stellen Sie sicher, dass das Schloss geschlossen ist. $contact_hotline";
}
#todo if > 24h rental
if($todo eq "24h_occupied"){
$sms_message .= "Zur Info! Sie haben $bike seit 24 Stunden kostenpflichtig gemietet!. $hotline";
$sms_message .= "Zur Info! Sie haben $bike seit 24 Stunden kostenpflichtig gemietet!. $contact_hotline";
}
if($todo eq "48h_occupied"){
$sms_message .= "Zur Info! Sie haben $bike seit 48 Stunden kostenpflichtig gemietet!. $hotline";
$sms_message .= "Zur Info! Sie haben $bike seit 48 Stunden kostenpflichtig gemietet!. $contact_hotline";
}
if($todo eq "72h_occupied"){
$sms_message .= "Zur Info! Sie haben $bike seit 72 Stunden kostenpflichtig gemietet!. $hotline";
$sms_message .= "Zur Info! Sie haben $bike seit 72 Stunden kostenpflichtig gemietet!. $contact_hotline";
}
#todo send_alarm2hotline
if($todo eq "send_alarm2hotline"){
$sms_from = "RadAlarm";
$sms_message .= "Diebstahlalarm $bike. Öffne das Alarmjournal für weitere Informationen: $dbt->{operator}->{$varenv{dbname}}->{operatorDMS}/DMS/Alarmjournal";
}
#todo fraud_rental

View file

@ -17,7 +17,7 @@ use Mod::Buttons;
use Lib::Config;
use Mod::APIfunc;
use Digest::MD5 qw(md5 md5_hex);
use Digest::SHA qw(sha1_base64);
use Digest::SHA qw(sha1_base64 sha256_base64);
use Scalar::Util qw(looks_like_number);
use URI::Encode;
use Mod::Prelib;
@ -217,7 +217,9 @@ sub save_account(){
$pw_dummy = "1";
}elsif($valxx){
my $pwmd5 = md5_hex($valxx);
my $pwsha256=sha256_base64($valxx);
$u_rows = $dbt->update_one($dbh,$update_primary,"txt11='$pwmd5'");
$u_rows = $dbt->update_one($dbh,$update_primary,"txt04='$pwsha256'");
}
}
#operators, only if saved by operator DMS
@ -840,9 +842,11 @@ sub send_password(){
$bw->log("$varenv{basedir}/src/Mod/newsletter_tink.pl",$email,"");
my $pwmd5 = md5_hex($coo);
my $pwsha256=sha256_base64($coo);#after migration, adjust length test
if($email && $email =~ /\w\@\w/ && $pwmd5 && length($pwmd5) > 20 && $email !~ /$dbt->{copri_conf}->{test_accounts}/i){
$db->updater("contentadr","1","1","txt11","$pwmd5","$owner","txt08","ilike","$email");
$db->updater("contentadr","1","1","txt04","$pwsha256","$owner","txt08","ilike","$email");
system(`$varenv{basedir}/src/Mod/newsletter_tink.pl "$varenv{basedir}" "$varenv{wwwhost}" "send_password" "$email" "$coo"`);
}

View file

@ -161,8 +161,10 @@ sub tpl(){
}
if(!$end_date_time){
my $days4month = Days_in_Month($year,$mon);
$end_date_time = "$days4month.$mon.$year";
#my $days4month = Days_in_Month($year,$mon);
#$end_date_time = "$days4month.$mon.$year";
my ($nyear,$nmon,$nday) = Add_Delta_YMD($year,$mon,1, 0,1,0);
$end_date_time = "$nday.$nmon.$nyear";
}

View file

@ -93,13 +93,16 @@ sub tpl(){
my $year = strftime "%Y", localtime;
($year,$mon,$day,$hh,$mm) = $lb->split_date($users_dms->{cal_start}) if($users_dms->{cal_start});
my $start_date_time = $R::start_date_time;
my $start_date_time = $R::start_date_time || "";
$start_date_time = "01.$mon.$year" if(!$start_date_time);
my $end_date_time = $R::end_date_time;
my $days4month = Days_in_Month($year,$mon);
$end_date_time = "$days4month.$mon.$year" if(!$end_date_time);
my $end_date_time = $R::end_date_time || "";
if(!$end_date_time){
#my $days4month = Days_in_Month($year,$mon);
#$end_date_time = "$days4month.$mon.$year";
my ($nyear,$nmon,$nday) = Add_Delta_YMD($year,$mon,1, 0,1,0);
$end_date_time = "$nday.$nmon.$nyear";
}
my $c_date; my $start_chck=0;my $end_chck=0;my $message;
if($start_date_time){
($start_date_time,$start_chck) = $lb->checkdate($start_date_time) if($start_date_time ne "%");
@ -110,20 +113,8 @@ sub tpl(){
$message .= ">>> Datum Eingabefehler: $end_date_time <<<" if($end_chck);
}
my $search_startdt = $start_date_time;
my $search_enddt = $end_date_time;
$end_date_time .= " 23:59" if($end_date_time !~ / \d\:\d/);
if("$start_date_time" eq "01.$mon.$year"){
$search_startdt = "date \'$start_date_time\' - integer \'31\'"
}else{
$search_startdt = "\'$start_date_time\'"
}
if("$end_date_time" eq "$days4month.$mon.$year"){
$search_enddt = "date \'$end_date_time\' + integer \'31\'"
}else{
$search_enddt = "\'$end_date_time\'"
}
my $search_startdt = "\'$start_date_time\'";
my $search_enddt = "\'$end_date_time\'";
my $cttpos = {};
my $cttpos_trans = {};

View file

@ -125,8 +125,8 @@ sub utctime {
#'deviceTime' => '2021-10-14T08:19:35.000+0000',
#'serverTime' => '2021-10-14T07:19:37.000+0000',
#$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch += $latency;
$time = gmtime($utc_epoch);#epoch
@ -431,6 +431,9 @@ sub get_positions {
if($theftmove_count < 10){
system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''");
print FILE "$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''\n\n";
if($op_name->{sms_alert}){
system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/sms_message.pl '$op_name->{syshost}' 'send_alarm2hotline' '' '$c_id'");
}
}
}

View file

@ -93,8 +93,8 @@ sub utctime {
my $time = Time::Piece->strptime($date, "%Y-%m-%dT%H:%M:%S");
print FILE "localtime: " . $time->datetime . "\n";#localtime
my $utc_epoch = $time->epoch;
#$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch += $latency;
$time = gmtime($utc_epoch);#epoch
print FILE "utctime: " . $time->datetime . "\n";#utc zulu date time
@ -179,7 +179,7 @@ sub get_tripsum {
if($ctpos->{int13} eq $resp->{deviceId}){
print FILE "device Id: $resp->{deviceId}" . "\n";
print FILE "distance: $resp->{distance}" . "\n";
if($resp->{distance}){
if($resp->{distance} && $resp->{distance} > 0){
#my $distance = $resp->{distance} / 1000 * 1.60934; #distance in Meilen
my $distance = $resp->{distance} / 1000;
$distance = sprintf('%.2f', $distance);

View file

@ -9,6 +9,8 @@
#SMS message locking_progress after 60sec
#sudo su www-data -c "./src/scripts/sms_message.pl shareeapp-operator locking_progress '0179xxxx372' $pos_id"
#
#SMS theftalarm
#sudo su www-data -c "./src/scripts/sms_message.pl shareedms-kn 'send_alarm2hotline' '' '18498'"
#
use vars qw($syshost);
@ -23,11 +25,13 @@ use warnings;
use POSIX;
use DateTime;
use DateTime::Format::Pg;
use Data::Dumper;
use Lib::Config;
use Mod::DBtank;
use Mod::SMSTransport;
use Data::Dumper;
my $cf = new Config;
my %varenv = $cf->envonline();
my $dbt = new DBtank;
my $smstrans = new SMSTransport;
@ -35,6 +39,7 @@ my $todo = $ARGV[1] || die 'todo not defined';
my $phone = $ARGV[2] || "";
my $pos_id = $ARGV[3] || "";
my $dbh = "";
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix} || "";
#operator contact
my $pref_cc = {
@ -45,9 +50,9 @@ my $dbh = "";
};
my $record_cc = { c_id => 0 };
$record_cc = $dbt->fetch_record($dbh,$pref_cc);
my $hotline = "";
my $contact_hotline = "";
$record_cc->{txt07} =~ s/\s//g;
$hotline = "Hotline $record_cc->{txt01} $record_cc->{txt07}";
$contact_hotline = "Hotline $record_cc->{txt01} $record_cc->{txt07}";
#SMS message if 24h,48h,72h occupied
@ -82,8 +87,8 @@ if($todo eq "24h_occupied"){
if($dt1 >= $dt2_72h_occupied){
if($cttpos->{$pid}->{int33} != 3){
$todo = "72h_occupied";
print $dt1 . ">=" . $dt2_72h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
print $dt1 . ">=" . $dt2_72h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
$dbt->update_one($dbh,$update_pos,"int33=3",$cttpos->{$pid}->{c_id});
}
}
@ -91,16 +96,16 @@ if($todo eq "24h_occupied"){
#elsif($dt1 >= $dt2_48h_occupied){
# if($cttpos->{$pid}->{int33} != 2){
# $todo = "48h_occupied";
# print $dt1 . ">=" . $dt2_48h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
# $smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
# print $dt1 . ">=" . $dt2_48h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
# $smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
# $dbt->update_one($dbh,$update_pos,"int33=2",$cttpos->{$pid}->{c_id});
# }
#}
elsif($dt1 >= $dt2_24h_occupied){
if($cttpos->{$pid}->{int33} != 1){
$todo = "24h_occupied";
print $dt1 . ">=" . $dt2_24h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
print $dt1 . ">=" . $dt2_24h_occupied . "|$todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
$smstrans->sms_message($todo,$contact_hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
$dbt->update_one($dbh,$update_pos,"int33=1",$cttpos->{$pid}->{c_id});
}
}
@ -123,14 +128,44 @@ if($todo eq "locking_progress" && $phone && $pos_id){
my $booking = { c_id => 0 };
$booking = $dbt->fetch_tablerecord($dbh,$booking_pos);
if($booking->{int20} == 3){
$smstrans->sms_message($todo,$hotline,$phone,$booking->{ct_name});
$smstrans->sms_message($todo,$contact_hotline,$phone,$booking->{ct_name});
}
}#end
#SMS message theftalarm
if($todo eq "send_alarm2hotline" && $pos_id){
my $sms_to = "$dbt->{copri_conf}->{sms_to}";
#will be executed by Ilockit cron, that's because extern
my $client_encoding = "iso-8859-1";
my $dbh_operator = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},$client_encoding);
my $pref_ctu = {
table => "contentuser",
fetch => "one",
c_id => "1",#Kontakt-hotline
};
my $uadr = { c_id => 0 };
$uadr = $dbt->fetch_tablerecord($dbh_operator,$pref_ctu);
my $phone = $uadr->{txt07} || $sms_to;
my $pref_ct = {
table => "contenttheftpos",
fetch => "one",
c_id => $pos_id,
};
my $ct = { c_id => 0 };
$ct = $dbt->fetch_tablerecord($dbh_operator,$pref_ct);
$smstrans->sms_message($todo,"",$phone,"$oprefix$ct->{barcode}");
}#end
#SMS message fraud to me
if($todo eq "fraud_rental" && $pos_id){
#my $sms_to = "$dbt->{copri_conf}->{sms_to}";
my $sms_to = "01759776061";
my $sms_to = "$dbt->{copri_conf}->{sms_to}";
my $booking_pos = {
table => "contenttranspos",
@ -144,3 +179,5 @@ if($todo eq "fraud_rental" && $pos_id){
$smstrans->sms_message($todo,"",$sms_to,$booking->{ct_name});
}#end

View file

@ -60,6 +60,7 @@
map_zoom="13"
cache_station=0
withpub=0
sms_alert=0
<database>
dbname=sharee_operator
host=localhost