From 7736fee89d706d61868e78848479ff493201996d Mon Sep 17 00:00:00 2001 From: ragu Date: Thu, 1 Jun 2023 07:50:17 +0200 Subject: [PATCH] Refactoring some mailing methodes and adding cms text --- copri4/main/css/local_style20230105.css | 14 +- copri4/main/src/Mod/APIfunc.pm | 37 +- copri4/main/src/Mod/APIjsonserver.pm | 61 +- copri4/main/src/Mod/APIsigclient.pm | 11 +- copri4/main/src/Mod/DBtank.pm | 10 +- copri4/main/src/Mod/Modalbox3.pm | 2 +- copri4/main/src/Mod/Payment.pm | 6 +- copri4/main/src/Mod/Prelib.pm | 2 +- copri4/main/src/Mod/Prelogic.pm | 16 +- copri4/main/src/Mod/SMSTransport.pm | 2 +- copri4/main/src/Mod/Shareework.pm | 40 +- copri4/main/src/Mod/newsletter_tink.pl | 530 ------------------ copri4/main/src/Tpl/BaseEdit.pm | 24 +- copri4/main/src/Tpl/Calorin.pm | 11 +- copri4/main/src/Tpl/TransPositionen.pm | 4 +- copri4/main/src/scripts/Ilockit_cloud.pl | 15 +- .../main/src/scripts/Ilockit_trackingcloud.pl | 4 +- copri4/main/src/scripts/mailTransport.pl | 1 - copri4/main/src/scripts/mailTransportcms.pl | 306 ++++++---- copri4/main/src/scripts/sms_message.pl | 11 +- 20 files changed, 376 insertions(+), 731 deletions(-) delete mode 100755 copri4/main/src/Mod/newsletter_tink.pl delete mode 120000 copri4/main/src/scripts/mailTransport.pl diff --git a/copri4/main/css/local_style20230105.css b/copri4/main/css/local_style20230105.css index 444d21d..286db87 100755 --- a/copri4/main/css/local_style20230105.css +++ b/copri4/main/css/local_style20230105.css @@ -110,12 +110,7 @@ div#Container_cms { text-align: left; border: 0px; } -.content2_cms { - padding:4px 3px; - min-width:100px; - vertical-align: top; - text-align: left; -} + /**/ img {border:0px solid black;} @@ -369,6 +364,8 @@ div#Oline { } .etxt2 { font-size:100%; + border: 1px solid #FF5F1F; + padding:1px; margin:1px; } .stxt { @@ -420,6 +417,11 @@ div#Oline { border: 1px solid silver; background-color: #ffffff; } +.eselect2 { + font-size:1em; + border: 1px solid #FF5F1F; + background-color: #ffffff; +} .eselect_multiple { font-size:1em; border: 1px solid silver; diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index b236ad0..343d278 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -907,7 +907,7 @@ sub booking_request(){ my $response_text = ""; #state and lock_state is only defined if requestes incl. occupied - $bw->log("booking_request bike to state $bike | $state | $lock_state, tarif $ct_tariff->{barcode}, auth:$auth->{c_id}",$auth->{c_id},""); + $bw->log("log booking_request bike:$bike, state:$state, lock_state:$lock_state, tarif:$ct_tariff->{barcode}, auth:$auth->{c_id}",$auth->{txt08},""); my $update_adr = { table => "contentadr", @@ -1154,7 +1154,14 @@ sub booking_update(){ $gps_data->{gps} = "$gps_data->{latitude},$gps_data->{longitude}" if($gps_data->{latitude} && $gps_data->{longitude}); } - $bw->log("booking_update bike to state $bike | $state | $lock_state, auth:$auth->{c_id}, gps:$gps_data->{gps}",$auth->{c_id},""); + my $update_pos = { + table => "contenttranspos", + mtime => "now()", + }; + + my $logging = "log booking_update bike:$bike, state:$state, lock_state:$lock_state, userID:$auth->{c_id}, gps:$gps_data->{gps}"; + $bw->log("$logging",$auth->{c_id},""); + $update_pos->{txt24} = $record_pos->{txt24} . "\n$logging"; my $Ilockit_GUID = ""; $Ilockit_GUID = $q->escapeHTML($q->param('Ilockit_GUID')) if($q->param('Ilockit_GUID') && $q->param('Ilockit_GUID') =~ /\w+-\w+-\w+-\w+$/); @@ -1185,10 +1192,6 @@ sub booking_update(){ #set rent state if lock_system 2=Ilockit || 3=sigo if($record_pos->{int11} && ($record_pos->{int11} == 2 || $record_pos->{int11} == 3)){ - my $update_pos = { - table => "contenttranspos", - mtime => "now()", - }; if($user_agent && $user_agent !~ /axios/){#keep device info if sig push $update_pos->{txt21} = $q->escapeHTML($q->param('user_device')) if($q->param('user_device')); @@ -1413,10 +1416,18 @@ sub booking_update(){ my $booking = $dbt->fetch_tablerecord($dbh,$booking_pos); if(ref($booking) eq "HASH" && $booking->{ct_name}){ - #$booking_values->{bike} = "$booking->{ct_name}"; + #deprecated $booking_values->{bike} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$booking->{barcode}"; $booking_values->{state} = "$dbt->{copri_conf}->{bike_state}->{$booking->{int10}}"; $booking_values->{lock_state} = "$dbt->{copri_conf}->{lock_state}->{$booking->{int20}}"; + #new object after rental end + $booking_values->{bike_returned} = {}; + if($booking->{int10} == 1){ + $booking_values->{bike_returned}->{bike} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$booking->{barcode}"; + $booking_values->{bike_returned}->{station} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$booking->{int04}"; + $booking_values->{bike_returned}->{state} = "$dbt->{copri_conf}->{bike_state}->{$booking->{int10}}"; + $booking_values->{bike_returned}->{lock_state} = "$dbt->{copri_conf}->{lock_state}->{$booking->{int20}}"; + } #user_miniquest_count on operator my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); @@ -2001,8 +2012,8 @@ sub bikes_all(){ my $pref = { table => "content", fetch => "all", - keyfield => "barcode",#2018-02-21 changed to bike id - template_id => "205",#Leihrad_liste + keyfield => "barcode", + template_id => "205", }; my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie')); @@ -2018,7 +2029,11 @@ sub bikes_all(){ $pref->{int04} = "=::$station_id" if(looks_like_number($station_id)); if(looks_like_number($bike_id)){ $pref->{ barcode} = "=::$bike_id"; - $pref->{int10} = "!=::3";#2022-12-02 do not select occupied bikes in servicetool by direct bike-select + #2022-12-02 not select occupied bikes in servicetool by direct select-bike + $pref->{int10} = "!=::3"; + #}else{ + #2023-05-23 not select requested and occupied bikes in servicetool by list-bikes? + #$pref->{int10} = "IN::(1,4,5,6)"; } my $record = {}; @@ -2201,7 +2216,7 @@ sub stations_available(){ }elsif($station_group && $type_id =~ /(\d+)/){ my $group_id = $1; if($group_id == $station_group){ - $pref_sql = " and ct.txt25 like '%$group_id%' and ct.int42=0"; + $pref_sql = " and ct.txt25 like '%$group_id%' and (ct.int42=0 OR ct.int42 is null)"; } } } diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index c25bc4a..6df8078 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -68,7 +68,7 @@ my $response = { apiserver => "$apiserver", response => "$respreq", uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}", - copri_version => "4.1.23.03", + copri_version => "4.1.23.10", user_id => "", authcookie => "", new_authcoo => "0", @@ -161,7 +161,9 @@ if($q->param('request') eq "auth_verify"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; if(ref($auth) eq "HASH" && $auth->{authcookie}){ $response = { %$response, %$auth }; @@ -211,7 +213,9 @@ elsif($q->param('request') eq "booking_request"){ my $rows = 0; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; if(ref($auth) eq "HASH" && $auth->{authcookie}){ my $bike = $q->escapeHTML($q->param('bike')) || ""; @@ -343,7 +347,9 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); my $rows = 0; $response = { %$response, %$auth }; @@ -436,7 +442,9 @@ elsif($q->param('request') eq "user_bikes_occupied"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); if(ref($auth) eq "HASH" && $auth->{authcookie}){ $response = { %$response, %$auth }; ($response->{bikes_occupied},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,""); @@ -446,8 +454,9 @@ elsif($q->param('request') eq "user_bikes_occupied"){ } }else{ - - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); if(ref($auth) eq "HASH" && $auth->{authcookie}){ $response = { %$response, %$auth }; my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog"); @@ -508,8 +517,10 @@ elsif($q->param('request') eq "bikes_all"){ ($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id')); $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - - my ($auth,$authraw) = $apif->auth_verify($q); + + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; ($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,""); }else{ @@ -650,7 +661,9 @@ elsif($q->param('request') eq "stations_all"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; ($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,""); }else{ @@ -673,7 +686,9 @@ elsif($q->param('request') eq "stations_available"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); my $user_agent_subversion = 1000; #$user_agent = "Meinkonrad/3.0.363";#test @@ -684,7 +699,7 @@ elsif($q->param('request') eq "stations_available"){ my $localtime = Time::Piece->strptime($lnow, "%Y-%m-%d %H:%M:%S"); my $epoch_now = $localtime->epoch; my $merchant_message_start = Time::Piece->strptime("2023-05-15 00:00:00", "%Y-%m-%d %H:%M:%S"); - my $merchant_message_end = Time::Piece->strptime("2023-05-21 23:00:00", "%Y-%m-%d %H:%M:%S"); + my $merchant_message_end = Time::Piece->strptime("2023-05-21 23:59:00", "%Y-%m-%d %H:%M:%S"); my $epoch_start = $merchant_message_start->epoch; my $epoch_end = $merchant_message_end->epoch; @@ -705,6 +720,12 @@ elsif($q->param('request') eq "stations_available"){ $response->{merchant_message} = $varenv{cms}->{'App-merchant-message'}->{txt}; } } + #disabled sig is offline message + if(1==2 && $user_agent =~ /bayern/i){ + if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){ + $response->{merchant_message} = $varenv{cms}->{'App-merchant-message-bayern'}->{txt}; + } + } $response = { %$response, %$auth }; ($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,""); @@ -715,6 +736,10 @@ elsif($q->param('request') eq "stations_available"){ $q->param(-name=>'request',-value=>"user_bikes_occupied"); ($response->{bikes_occupied},my $uri_operator_array,my $user_group,my $user_tour) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,$last_used_operator); } + if(length($coo) > 20 && !$auth->{authcookie}){ + $response->{response_state} = "Failure 1001: authcookie not defined"; + $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; + } }else{ ($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id')); @@ -743,7 +768,9 @@ elsif($q->param('request') eq "user_feedback" || $q->param('request') eq "user_m $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; $response->{uri_operator} = "$varenv{wwwhost}"; @@ -783,7 +810,9 @@ elsif($q->param('request') eq "service_done"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); my $station_id = $1 if($q->param('station') =~ /(\d+)/); #my $bike_id = $1 if($q->param('bike') =~ /(\d+)/); @@ -956,7 +985,9 @@ elsif($q->param('request') eq "service_work"){ $varenv{merchant_id} = $return_merchant->{merchant_id}; $response = { %$response, %$return_merchant }; - my ($auth,$authraw) = $apif->auth_verify($q); + my $auth = {}; + my $authraw = {}; + ($auth,$authraw) = $apif->auth_verify($q); my $station_id = ""; $station_id = $1 if($q->param('station') =~ /(\d+)/); #$bike_id = $1 if($q->param('bike') =~ /(\d+)/); diff --git a/copri4/main/src/Mod/APIsigclient.pm b/copri4/main/src/Mod/APIsigclient.pm index 61774b4..5437fd0 100755 --- a/copri4/main/src/Mod/APIsigclient.pm +++ b/copri4/main/src/Mod/APIsigclient.pm @@ -125,7 +125,6 @@ sub sig_available { $response_out->{$station}->{description} = ""; #$response_out->{$station}->{description} = "$resp->{site}->{address}" || ""; $response_out->{$station}->{description} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$resp->{site}->{address})) || ""; - $response_out->{$station}->{station_group} = ["SX300101"];#Lastenrad alias type_id $response_out->{$station}->{gps}->{latitude} = "$resp->{site}->{lat}" || ""; $response_out->{$station}->{gps}->{longitude} = "$resp->{site}->{lon}" || ""; $response_out->{$station}->{gps_radius} = "75"; @@ -138,6 +137,13 @@ sub sig_available { $response_out->{$station}->{state} = "maintenance"; } + #new station category + $response_out->{$station}->{station_type}->{$dbt->{copri_conf}->{type_id}->{'300101'}}->{bike_group} = "SX300101"; + $response_out->{$station}->{station_type}->{$dbt->{copri_conf}->{type_id}->{'300101'}}->{bike_count} = "$response_out->{$station}->{bike_count}"; + + #deprecated + $response_out->{$station}->{station_group} = ["SX300101"];#Lastenrad alias type_id + $response_out->{$station}->{operator_data} = { "operator_name" => "", "operator_hours" => "", @@ -402,12 +408,13 @@ sub sig_booking { my $self = shift; my $varenv = shift || {}; my $todo = shift || ""; - my $ctadr = shift || {}; + my $authraw = shift || {}; my $ct_bike = shift || {}; my $ctpos = shift || {}; my $dbh = ""; my $owner = 169; + my $ctadr = $authraw; my $sig_book = {}; open(FILE,">>$varenv->{logdir}/APIsigclient.log"); diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index f4fd244..72ffef8 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -689,12 +689,14 @@ sub collect_post(){ sub fetch_cms { my $self = shift; my $dbh = shift || $dbh_intern; - my $fetch = shift; + my $fetch = shift || {}; my $langfield = "txt02";#default to en - $langfield = "txt01" if($fetch->{lang} eq "de"); - $langfield = "txt03" if($fetch->{lang} eq "fr"); - my $sql = "SELECT ct_name, coalesce($langfield, txt02) AS txt FROM contentuser, relation where template_id=194 and c_id=content_id"; + my $lang = ""; + $lang = lc($fetch->{lang}) if($fetch->{lang}); + $langfield = "txt01" if($lang eq "de"); + $langfield = "txt03" if($lang eq "fr"); + my $sql = "SELECT ct_name, coalesce($langfield, txt01) AS txt FROM contentuser, relation where template_id=194 and c_id=content_id"; my $sth = $dbh->prepare($sql); my $rc = $sth->execute(); diff --git a/copri4/main/src/Mod/Modalbox3.pm b/copri4/main/src/Mod/Modalbox3.pm index 6c23e2c..95d8df9 100755 --- a/copri4/main/src/Mod/Modalbox3.pm +++ b/copri4/main/src/Mod/Modalbox3.pm @@ -44,7 +44,7 @@ sub mobox3(){ my $bg_color = "white"; my $bg_color2 = $node_meta->{bg_color} || "grey"; my $title = "Content Editor \"$node_meta->{tpl_name}\""; - $title = "Artikel Editor" if($node_meta->{ct_table} eq "content"); + $title = "Parts Editor" if($node_meta->{ct_table} eq "content"); $title = "Kunden Editor" if($node_meta->{ct_table} eq "contentadr"); $title = "DMS-Account Zugriffsberechtigung" if($node_meta->{ct_table} eq "users"); $title = "Service Editor" if($node_meta->{ct_table} eq "contentpos"); diff --git a/copri4/main/src/Mod/Payment.pm b/copri4/main/src/Mod/Payment.pm index 03b3241..00d4d0e 100755 --- a/copri4/main/src/Mod/Payment.pm +++ b/copri4/main/src/Mod/Payment.pm @@ -742,9 +742,9 @@ sub payone_capture(){ print EMA "\n$now_dt\n$topdf --page-size A4 \"$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$owner\&pkey=$apikeyconf{pdfprinter}->{pkey}\" $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\n"; #send_invoice infomail, only if eMail never sent - if(-f "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf" && !$ctt->{txt30}){ - system("$varenv->{basedir}/src/scripts/mailTransport.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{c_id}' '$praefix-$ctt->{ct_name}.pdf'"); - print EMA "---> Sent Invoice e-mail command: $varenv->{basedir}/src/scripts/mailTransport.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{c_id}' '$praefix-$ctt->{ct_name}.pdf'\n"; + if(-f "$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && !$ctt->{txt30}){ + system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' ''"); + print EMA "---> Payment send_invoice e-mail command: $dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '$praefix-$ctt->{ct_name}.pdf' ''\n"; } close EMA; } diff --git a/copri4/main/src/Mod/Prelib.pm b/copri4/main/src/Mod/Prelib.pm index 0935218..b72936a 100755 --- a/copri4/main/src/Mod/Prelib.pm +++ b/copri4/main/src/Mod/Prelib.pm @@ -248,7 +248,7 @@ sub save_content { $valxx = $q->escapeHTML("$val"); $valxx =~ s/,/./; $valxx =~ s/\s//g; - if($valxx && looks_like_number($valxx)){ + if(looks_like_number($valxx) || $valxx == 0){ $update_ct->{$_} = "$valxx"; }elsif(!$valxx || $valxx eq "null"){ $update_ct->{$_} = "null"; diff --git a/copri4/main/src/Mod/Prelogic.pm b/copri4/main/src/Mod/Prelogic.pm index 9d0db97..f6ca6f2 100755 --- a/copri4/main/src/Mod/Prelogic.pm +++ b/copri4/main/src/Mod/Prelogic.pm @@ -671,6 +671,9 @@ sub preinit(){ my $c_id4print = $R::c_id4trans; $c_id4print= $R::c_id if($R::printer_id =~ /Adresse|Kunde/); if($c_id4print){ + open(EMA, ">> $varenv{logdir}/copri-print.log"); + print EMA "$today4db\n"; + my $print_return = ""; my $exit_code = 1; my $table = "contenttrans"; @@ -695,13 +698,8 @@ sub preinit(){ $print_return = `$topdf --page-size $psize "$varenv{wwwhost}$script/Printpreview?printer_id=$R::printer_id\&mandant_main_id=$mandant_main_id\&main_id=$node->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$c_id4print\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey}" "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" 2>&1`; $exit_code = $?; - if(1==1){#debugging my $filesize = -s "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf"; - open(EMA, ">> $varenv{logdir}/copri-print.log"); - print EMA "$today4db\n$topdf --page-size $psize $varenv{wwwhost}$script/Printpreview?printer_id=$R::printer_id\&mandant_main_id=$mandant_main_id\&main_id=$node->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$c_id4print\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey} $varenv{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\nset_state: $R::set_state\n"; - close EMA; - #exit 0; - } + print EMA "$topdf --page-size $psize $varenv{wwwhost}$script/Printpreview?printer_id=$R::printer_id\&mandant_main_id=$mandant_main_id\&main_id=$node->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$c_id4print\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey} $varenv{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\nset_state: $R::set_state\n"; if($R::set_state ne "buchen"){#no redirect if buchen incl. print_pdf if( -f "$varenv{basedir}/pdf/$praefix-$ctt->{ct_name}.pdf"){ @@ -714,11 +712,13 @@ sub preinit(){ } } - if(-f "$varenv{basedir}/pdf/$praefix-$ctt->{ct_name}.pdf" && (($R::set_state eq "buchen" && $R::send_invoice && $ctt->{int01} && $ctt->{int01} != 0) || ($ib_key eq "send_invoice_again"))){ - system("$varenv{basedir}/src/scripts/mailTransport.pl '$varenv{syshost}' 'send_invoice' '$ctt->{c_id}' '$praefix-$ctt->{ct_name}.pdf'"); + if(-f "$varenv{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && (($R::set_state eq "buchen" && $R::send_invoice && $ctt->{int01} && $ctt->{int01} != 0) || ($ib_key eq "send_invoice_again"))){ + system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' ''"); + print EMA "---> Prelogic send_invoice e-mail command: $dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '$praefix-$ctt->{ct_name}.pdf'\n"; } # + close EMA; }#end c_id4print #SET Tagesabschluss diff --git a/copri4/main/src/Mod/SMSTransport.pm b/copri4/main/src/Mod/SMSTransport.pm index 2af1432..3469cae 100755 --- a/copri4/main/src/Mod/SMSTransport.pm +++ b/copri4/main/src/Mod/SMSTransport.pm @@ -145,7 +145,7 @@ sub sms_message { #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"; + $sms_message .= "Alarmmeldung zu Rad $bike. Öffne das Alarmjournal für weitere Informationen: $dbt->{operator}->{$varenv{dbname}}->{operatorDMS}/DMS/Alarmjournal"; } #todo fraud_rental diff --git a/copri4/main/src/Mod/Shareework.pm b/copri4/main/src/Mod/Shareework.pm index 71d03a7..6a6c762 100755 --- a/copri4/main/src/Mod/Shareework.pm +++ b/copri4/main/src/Mod/Shareework.pm @@ -757,31 +757,30 @@ sub save_transact(){ #Send sms after payable check and !int13 -sub smsack(){ +sub smsack { my $self = shift; my $ctadr = shift; $smstrans->sms_ack_digest($ctadr); + return; } #Send email after payable check and !int04 -sub emailack(){ +sub emailack { my $self = shift; my $varenv = shift; my $adr_id = shift || ""; - - system(`$varenv->{basedir}/src/Mod/newsletter_tink.pl "$varenv->{basedir}" "$varenv->{wwwhost}" "emailack" "$adr_id" ""`); - #TODO - #system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_emailack' '$adr_id' ''"); + system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_emailack' '$adr_id' ''"); + return; } #Password forgotten send email -sub send_password(){ +sub send_password { my $self = shift; my $varenv = shift; my $email = shift || ""; my $coo = shift || ""; my $owner = shift || ""; - + my $dbh = ""; $email = $q->escapeHTML($email); $email =~ s/\s//g; @@ -789,12 +788,27 @@ sub send_password(){ if($email && $email =~ /\w\@\w/ && $pwmd5 && length($pwmd5) > 20 && $email !~ /$dbt->{copri_conf}->{test_accounts}/i){ my $pwsha256=sha256_base64($pwmd5) || ""; - $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"`); - #TODO - #system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_password' '$c_id' ''"); - } + my $authref = { + table => "contentadr", + fetch => "one", + template_id => "202", + txt08 => "ilike::" . $q->escapeHTML($email), + int05 => "1", + }; + my $ctadr = { c_id => 0 }; + $ctadr = $dbt->fetch_record($dbh,$authref); + my $c_id = $ctadr->{c_id}; + my $update_primary = { + table => "contentadr", + mtime => "now()", + owner => "$owner", + txt04 => "$pwsha256", + }; + $dbt->update_record($dbh,$update_primary,$ctadr) if($c_id > 0); + system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_password' '$c_id' '' '$coo'"); + } + return; } #sigbike just like caching and not realy used by app diff --git a/copri4/main/src/Mod/newsletter_tink.pl b/copri4/main/src/Mod/newsletter_tink.pl deleted file mode 100755 index 365e4b5..0000000 --- a/copri4/main/src/Mod/newsletter_tink.pl +++ /dev/null @@ -1,530 +0,0 @@ -#!/usr/bin/perl -w -# -## SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (c) Rainer Gümpelein, TeilRad GmbH -# -#TODO, migrate to MailTransport.pm -# -#su www-data -c "./src/Mod/newsletter_tink.pl '/var/www/copri4/shareeapp-operator' 'https://shareeapp-operator.copri-bike.de' 'emailack' '1842'" - -#on command -#sudo su www-data -c "./src/Mod/newsletter_tink.pl '/var/www/copri3/konrad' 'https://konrad.tink-konstanz.de' 'send_password' 'ragu@gnu-systems.de' '59e5c7bce6'" - -#su www-data -c "./src/Mod/newsletter_tink.pl '/var/www/copri3/tinkdms' 'https://tinkdms.copri.eu' 'send_invoice' '1842' '2866'" - - -use strict; -use warnings; -use utf8; -use Encode; -use CGI ':standard'; -use DBI; -use POSIX; -use Email::MIME; -use IO::All; -use Email::MIME::CreateHTML; -use Email::Sender::Simple qw(sendmail); -#use Email::Sender::Transport::SMTPS; -use Net::SMTP; -use Try::Tiny; -use Config::General; -use URI::Encode; -my $uri_encode = URI::Encode->new( { encode_reserved => 1 } ); -use Data::Dumper; - -use Sys::Hostname; -my $hostname = hostname; - -my $q = new CGI; -my $basedir = $ARGV[0]; -my $wwwhost = $ARGV[1]; -my $todo = $ARGV[2]; -my $c_id=""; -my $ct_name=""; -my $emailpw=""; -my $coopw=""; -if($todo =~ /emailack|send_invoice|send_capture_fail/){ - $c_id = $ARGV[3] || "";#contentadr.c_id - $ct_name = $ARGV[4] || "";#contenttrans.c_id -}elsif($todo eq "send_password"){ - $emailpw = $ARGV[3] || ""; - $emailpw =~ s/\s//g; - $coopw = $ARGV[4] || ""; -} - -my $today = strftime("%d.%m.%Y %H:%M:%S",localtime(time)); - -my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg"; -my $gconf = Config::General->new($globalconf_file); -my %globalconf = $gconf->getall; - -my $mailx_file = "/var/www/copri4/shareeconf/mailx.cfg"; -my $mconf = Config::General->new($mailx_file); -my %mailxconf = $mconf->getall; - -require "$basedir/src/Lib/Config.pm"; -my %varenv = &Config::envonline("","$wwwhost"); -#print Dumper(%varenv); - -open(EMA, ">> $varenv{logdir}/newsletter_tink.log"); - print EMA "\n$today, start mailing\n"; - print EMA "'$today' '$basedir' '$wwwhost' '$todo' 'c_id:$c_id' 'invoice ct_name:$ct_name' 'emailpw:$emailpw' 'coopw:$coopw'\n"; -close EMA; - - -my $dbh = &dbconnect(); -sub dbconnect { - my $options =""; - my $dbh = DBI->connect("dbi:Pg:dbname=$varenv{dbname};host=$varenv{dbhost};port=5432;options='$options'", "$varenv{dbuser}", "$varenv{dbpassw}",{ RaiseError => 1, AutoCommit => 1 }) or die "Can't connect to $varenv{dbname}: $DBI::errstr"; - return $dbh; -} - -sub get_contentadr(){ - my ($c_id,$emailpw) = @_; - my $where="where ct.c_id=rel.content_id"; - $where .= " and ct.c_id=$c_id" if($c_id =~ /^\d+$/); - $where .= " and ct.txt08 ilike '$emailpw'" if($emailpw =~ /\w+/); - $where .= " and rel.template_id = 202";#tpl_id Adressen - my $sth = $dbh->prepare("SELECT * FROM contentadr ct, relation rel $where"); - my $rc = $sth->execute(); - my $ct = $sth->fetchrow_hashref(); - return $ct; -} - -sub get_content(){ - my ($table,$c_id,$tpl_id) = @_; - my $where="where ct.c_id=rel.content_id"; - $where .= " and ct.c_id=$c_id" if($c_id =~ /^\d+$/); - $where .= " and rel.template_id = $tpl_id" if($tpl_id =~ /^\d+$/); - my $sth = $dbh->prepare("SELECT * FROM $table ct, relation rel $where"); - my $rc = $sth->execute(); - my $ct = $sth->fetchrow_hashref(); - return $ct; -} - -#update trivial, matchs anything -sub updater(){ - my ($table,$w_col,$w_val,$column,$content,$owner,$w_col2,$w_op2,$w_val2,$set_time) = @_; - my $ct_set = "mtime='now()'"; - if($set_time eq "no_time"){ - $ct_set = ""; - }elsif($table !~ /content/){ - $ct_set = "change='now()'"; - } - - if("$content" eq "null" || (!$content && $content !~ /^0$/)){ - $ct_set .= ",$column=null"; - }elsif($content || $content == 0){ - $ct_set .= ",$column='$content'"; - } - $ct_set .= ",owner='$owner'" if($owner); - $ct_set =~ s/^,/ /; - my $where = "$w_col='$w_val'"; - $where .= " and $w_col2 $w_op2 ($w_val2)" if("$w_col2" && "$w_op2" && "$w_val2"); - my $sth = $dbh->prepare("UPDATE $table SET $ct_set where $where"); - my $rows = $sth->execute(); - return $rows; -} - - -my $ctadr = &get_contentadr($c_id,$emailpw) if($c_id =~ /^\d+$/ || $emailpw =~ /\w+\@\w+/); - - my $smtp = Net::SMTP->new($mailxconf{mailx_default}->{mail_gateway}, - Port => 465, - Hello => 'sharee.bike', - Timeout => 30, - Debug => 0, - SSL => 1, - ); - - - #$varenv{sasl_password} = Encode::encode('iso-8859-1', Encode::decode('utf-8', $varenv{sasl_password})); - $smtp->auth($mailxconf{mailx_default}->{sasl_username},$mailxconf{mailx_default}->{sasl_password}); - $smtp->mail($mailxconf{mailx_default}->{mail_from}); - -my $smtp_return = ""; -if($todo eq "emailack"){ - $smtp_return = &esender_success($smtp,$ctadr,$wwwhost); -}elsif($todo eq "send_password" && $ctadr->{txt08} =~ /\w+\@\w+/){ - $smtp_return = &esender_password($smtp,$ctadr,$coopw,$wwwhost); -}elsif($todo eq "send_invoice"){ - my $send_invoice; - $smtp_return = &esender_invoice($smtp,$todo,$ctadr,$ct_name,$wwwhost); - # if sendmail true then null. For us we need text - #if(!$smtp_return && $ct_name =~ /\d+/){ - if($ct_name =~ /\d+/){ - $today =~ s/:\d+$//; - $send_invoice = "$today, Rechnungsinfo per eMail versandt (debug: $smtp_return)"; - &updater("contenttrans","ct_name","$ct_name","txt30","$send_invoice","","","","","no_time"); - } -}elsif($todo eq "send_capture_fail"){ - $smtp_return = &esender_invoice($smtp,$todo,$ctadr,$ct_name,$wwwhost); -} -open(EMA, ">> $varenv{logdir}/newsletter_tink.log"); - print EMA "smtp_return: $smtp_return\n"; -close EMA; - - - -#Registration acknowledgement -sub esender_success { - my $smtp = shift; - my $ctadr = shift; - my $wwwhost = shift; - my %varenv = &Config::envonline("","$wwwhost"); - - my $ct = &get_content("contentuser",$globalconf{shareedms_conf}->{parent_node},"201"); - - - my $email = $q->unescapeHTML($ctadr->{txt08}); - my $anrede = $q->unescapeHTML($ctadr->{txt02}); - my $name = $q->unescapeHTML($ctadr->{txt01}); - $name = Encode::encode('iso-8859-1', Encode::decode('utf-8', $name)); - - my $strasse = $q->unescapeHTML($ctadr->{txt03}); - $strasse = Encode::encode('iso-8859-1', Encode::decode('utf-8', $strasse)); - - my $ort = $q->unescapeHTML($ctadr->{txt06}); - my $telefon = $q->unescapeHTML($ctadr->{txt07}); - - #Ack digest - my $ack_digest = $q->unescapeHTML($ctadr->{txt34}) || ""; - my $email_ack_digest = $1 if($ack_digest =~ /^(.{5})/); - my $sms_ack_digest = $1 if($ack_digest =~ /(.{5})$/); - - #disabled because of payone payment - #my $iban = $q->unescapeHTML($ctadr->{txt22}); - #$iban =~ s/.{3}$/XXX/; - #IBAN: $iban (letzte drei Ziffern maskiert) - - -#email html body--------------------------------------------------- -my $body = ""; -my $encoded_email = $uri_encode->encode($ctadr->{txt08}); -$body = <$email_ack_digest - -Viel Spaß beim Radeln. -
-$ct->{txt09} -$ct->{txt04} -$ct->{txt05} - -$ct->{txt08} -$ct->{txt11} - -Bei Fragen zum e-Mail Bestätigungscode können sie uns unter hotline\@sharee.bike erreichen. -
- - -EOF -; - - $body =~ s/\n/
/g; - my $html = "$varenv{title}\n"; - $html .= "
$body
"; - $html .= ""; - - -#----------------------------------------------------------------- - - - my $subject = "Mietrad Anmeldebestätigung"; - if($hostname ne "ginger"){ - $email = $mailxconf{mailx_default}->{mail_to}; - $subject .= "* offline Test *"; - } - - if ($smtp->to($email)) { - $smtp->data(); - $smtp->datasend("To: $email\n"); - $smtp->datasend("Subject: $subject\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n"); - $smtp->datasend($html); - $smtp->dataend(); - } else { - print "Error: ", $smtp->message(); - } - - return "1. okay"; -} - -#Password forgotten -sub esender_password { - my ($smtp,$ctadr,$coopw,$wwwhost) = @_; - - my %varenv = &Config::envonline("","$wwwhost"); - - my $ct = {}; - if($varenv{syshost} =~ /konrad|tink/i){ - $ct = &get_content("content","3435","1"); - $ct->{txt01} = $q->unescapeHTML($ct->{txt01}); - $ct->{txt01} =~ s/\r\n/
/g; - $ct->{txt01} = Encode::encode('iso-8859-1', Encode::decode('utf-8', $ct->{txt01})); - }else{ - $ct = &get_content("contentuser",$globalconf{shareedms_conf}->{parent_node},"201"); - } - - - my $email = $q->unescapeHTML($ctadr->{txt08}); - my $anrede = $q->unescapeHTML($ctadr->{txt02}); - my $name = $q->unescapeHTML($ctadr->{txt01}); - $name = Encode::encode('iso-8859-1', Encode::decode('utf-8', $name)); - - -#email html body--------------------------------------------------- -my $body; -if($varenv{syshost} =~ /konrad|tink/i){ -$body = <$coopw - -Nach Ihrem Login www.konrad-konstanz.de können Sie das Passwort in Ihrem Profil unter Kundendaten auch gerne wieder ändern. - -Viel Spaß beim Radeln. - -EOF -; - -}else{#sharee - -$body = <$coopw - -Nach Ihrem Login können Sie das Passwort in Ihrem NutzerInnen Konto unter 1.Kundendaten auch gerne wieder ändern. - -
-Freundliche Grüße, --- -$ct->{txt09} -$ct->{txt04} -$ct->{txt05} - -$ct->{txt08} -$ct->{txt11} -
- -sharee.bike ist ein Angebot der TeilRad GmbH - -EOF -; -} - - $body =~ s/\n/
/g; - my $html = "$varenv{title}\n"; - $html .= "
$body
"; - #if($mandant eq "TINK"){ - # $html .= "
"; - #} - if($varenv{syshost} =~ /konrad|tink/i){ - $html .= "
$ct->{txt01}
\n"; - } - $html .= ""; - - -#----------------------------------------------------------------- - - - my $subject = "$varenv{title} Passwort vergessen"; - if($hostname ne "ginger"){ - $email = $mailxconf{mailx_default}->{mail_to}; - $subject .= "* offline Test *"; - } - - if ($smtp->to($email)) { - $smtp->data(); - $smtp->datasend("To: $email\n"); - $smtp->datasend("Subject: $subject\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n"); - $smtp->datasend($html); - $smtp->dataend(); - } else { - print "Error: ", $smtp->message(); - } - - return "2. okay"; -} - -#Send Invoice and capture_fails -sub esender_invoice { - my ($smtp,$todo,$ctadr,$ct_name,$wwwhost) = @_; - - my %varenv = &Config::envonline("","$wwwhost"); - my $ct = {}; - $ct = &get_content("contentuser",$globalconf{shareedms_conf}->{parent_node},"201"); - - #generate html for email-body - my $email = $q->unescapeHTML($ctadr->{txt08}); - my $anrede = $q->unescapeHTML($ctadr->{txt02}); - my $name = $q->unescapeHTML($ctadr->{txt01}); - $name = Encode::encode('iso-8859-1', Encode::decode('utf-8', $name)); - - -#email html body--------------------------------------------------- -my $subject; -my $body; -my $signature; - -if($varenv{syshost} =~ /konrad|tink/i){ -$signature = <Für Hinweise auf herumstehende Räder (gerne mit Radnummer, genauer Position und Fotos) aber auch Personen, die unsere Räder unrechtmäßig fahren oder beschädigen sind wir sehr dankbar. Sie erreichen uns über E-Mail (konrad\@fahrradspezialitaeten.com) und telefonisch über unsere Hotline: +49 761 45370099 (7 Tage/ 24 Stunden erreichbar). -Wenn Sie beobachten, wie jemand eines unserer Räder beschädigt, rufen Sie bitte unmittelbar die Polizei (Tel.:07531 995 2222) hinzu! - -Vielen Dank für Ihre Unterstützung! - -EOF -; -$signature =~ s/\n/
/g; -} - -if($todo eq "send_invoice"){ - -#$subject = "TINK Rechnung"; -$subject = "Fahrradmietsystem Rechnung"; - -if($varenv{syshost} =~ /konrad|tink/i){ - -$body = <https://www.stadtwerke-konstanz.de/mobilitaet/rad-mietsystem für Sie bereit. -Nach dem Anmelden ist in Ihrem Nutzer Profil unter Verleihdaten die Rechnung als PDF hinterlegt. - -EOF -; -$body =~ s/\n/
/g; - -}else{#sharee - -$body = < -Freundliche Grüße, --- -$ct->{txt09} -$ct->{txt04} -$ct->{txt05} - -$ct->{txt08} -$ct->{txt11} - - -sharee.bike ist ein Angebot der TeilRad GmbH - -EOF -; -$body =~ s/\n/
/g; -} - -}elsif($todo eq "send_capture_fail"){ - - -$subject = "Fahrradmietsystem Account"; - -if($varenv{syshost} =~ /konrad|tink/i){ - -$body = <https://www.stadtwerke-konstanz.de/mobilitaet/rad-mietsystem ) haben Sie die Möglichkeit Ihre Daten zu überprüfen und ggf. zu erneuern. -Kontaktieren Sie uns bitte falls Ihr Account für den Verleih nicht automatisch freigeschaltet wurde. - -Für weitere Fragen wenden Sie sich bitte an unsere Buchhaltung unter: buchhaltung\@fahrradspezialitaeten.com oder telefonisch 0761/5158912 (Mo, Mi, Fr 9-12 Uhr) - -EOF -; -$body =~ s/\n/
/g; - -}else{#sharee - -$body = < -Freundliche Grüße, --- -$ct->{txt09} -$ct->{txt04} -$ct->{txt05} - -$ct->{txt08} -$ct->{txt11} - - -sharee.bike ist ein Angebot der TeilRad GmbH - -EOF -; -$body =~ s/\n/
/g; - -} - -} - - my $html = "\n"; - $html .= "
$body
\n"; - #$html .= "
"; - $html .= "
$signature
\n"; - $html .= ""; - - -#----------------------------------------------------------------- - - - if($hostname ne "ginger"){ - $email = $mailxconf{mailx_default}->{mail_to}; - $subject .= "* offline Test *"; - } - my $message; - - - if ($smtp->to($email)) { - $smtp->data(); - $smtp->datasend("To: $email\n"); - $smtp->datasend("Subject: $subject\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8 \n\n"); - $smtp->datasend($html); - $smtp->dataend(); - } else { - print "Error: ", $smtp->message(); - } - - return "3. okay"; -} - - - -open(EMA, ">> $varenv{logdir}/newsletter_tink.log"); - print EMA "\n$today, done mailing\n"; - print EMA "'$today' '$basedir' '$wwwhost' '$todo' '$ctadr->{txt08}'\n"; - print EMA "\n\n"; -close EMA; - -$smtp->quit; - -1; diff --git a/copri4/main/src/Tpl/BaseEdit.pm b/copri4/main/src/Tpl/BaseEdit.pm index 45dda83..2648754 100755 --- a/copri4/main/src/Tpl/BaseEdit.pm +++ b/copri4/main/src/Tpl/BaseEdit.pm @@ -386,7 +386,9 @@ EOF } print ""; - print $q->textarea(-class=>'etxt',-style=>"border: 1px solid silver;",-name=>"$key",-default=>"$cttpos->{$key}", -override=>'1',-rows=>"5",-cols=>50),"\n"; + my $class = "etxt"; + $class = "etxt2" if($key eq "txt23"); + print $q->textarea(-class=>"$class",-name=>"$key",-default=>"$cttpos->{$key}", -override=>'1',-rows=>"5",-cols=>50),"\n"; print "\n"; @@ -401,7 +403,7 @@ EOF }elsif($key eq "int04"){ print $q->Tr(),"\n"; print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; - print $q->td({-class=>'content1_cms'}, "$prefix", $q->textfield(-class=>'etxt',-name=>"int04",-default=>"$cttpos->{int04}",-size=>"15",-maxlength=>40)),"\n"; + print $q->td({-class=>'content1_cms'}, "$prefix", $q->textfield(-class=>'etxt2',-name=>"int04",-default=>"$cttpos->{int04}",-size=>"15",-maxlength=>40)),"\n"; #End GPS }elsif($key eq "txt06"){ print $q->Tr(),"\n"; @@ -417,27 +419,27 @@ EOF $q->textfield(-id=>'datepicker3',-class=>'etxt',-name=>"start_date",-default=>"$s_dd.$s_mo.$s_yy",-size=>"10",-maxlength=>10), $q->textfield(-class=>'etxt',-name=>"s_hh",-default=>"$s_hh",-size=>"2",-maxlength=>2),":", $q->textfield(-class=>'etxt',-name=>"s_mi",-default=>"$s_mi",-size=>"2",-maxlength=>2)," → ", - $q->textfield(-id=>'datepicker4',-class=>'etxt',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"10",-maxlength=>10), - $q->textfield(-class=>'etxt',-name=>"e_hh",-default=>"$e_hh",-size=>"2",-maxlength=>2),":", - $q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"2",-maxlength=>2)),"\n"; + $q->textfield(-id=>'datepicker4',-class=>'etxt2',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"10",-maxlength=>10), + $q->textfield(-class=>'etxt2',-name=>"e_hh",-default=>"$e_hh",-size=>"2",-maxlength=>2),":", + $q->textfield(-class=>'etxt2',-name=>"e_mi",-default=>"$e_mi",-size=>"2",-maxlength=>2)),"\n"; }elsif($key =~ /int10/ && "$size" eq "select"){#bike_state my @_lock_valxx = (); foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{bike_state} })) { - push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{bike_state}->{$s_key}"; + push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{bike_state}->{$s_key}" if($s_key =~ /1|2|3/); } print $q->Tr(); print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; - print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect","",$cttpos->{$key},@_lock_valxx)); + print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect2","",$cttpos->{$key},@_lock_valxx)); }elsif($key =~ /int20/ && "$size" eq "select"){#lock_state locked/unlocked my @_lock_valxx = (); foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{lock_state} })) { - push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{lock_state}->{$s_key}"; + push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{lock_state}->{$s_key}" if($s_key =~ /1|2/); } print $q->Tr(); print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; - print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect","",$cttpos->{$key},@_lock_valxx),"$postdes"); + print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect2","",$cttpos->{$key},@_lock_valxx),"$postdes"); }elsif($key eq "int26"){ if($cttpos->{int26}){ @@ -867,7 +869,7 @@ EOF }elsif($ctrel->{txt15} && $bonus_record->{ct_name} eq $ctrel->{txt15}){ my $sharing_type = "public-bonus"; $sharing_type = $dbt->{copri_conf}->{sharing_type}->{$tariff_all->{$bonus_record->{int22}}->{int18}} if($bonus_record->{int22}); - $postdes .= "Ok, $sharing_type *code vorhanden. Trotzdem Tarif Einstellung prüfen."; + $postdes .= "Ok, $sharing_type *code vorhanden."; } print $q->Tr(); print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; @@ -927,7 +929,7 @@ EOF print $q->end_table; #2.table ende - print $q->div($but->singlesubmit7("$edit","$save_key","$ib{$save_key}","margin:10px 5px;")),"\n"; + print $q->div($but->singlesubmit7("$edit","$save_key","$ib{$save_key}","margin:10px 5px;"), $q->span({-style=>'color:#FF5F1F;'},"•"),"Orange markierte Angaben bitte prüfen und ggf. korrigieren."),"\n"; my $debug = ""; $debug = "(ct_table: $node_meta->{ct_table} | main_id: $node_meta->{main_id} | c_id: $ctrel->{c_id} | tpl_id: $tpl->{tpl_id} | rel_id: $ctrel->{rel_id})"; print $q->div({-style=>'z-index:10;font-size:13px;'},"$debug"),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); diff --git a/copri4/main/src/Tpl/Calorin.pm b/copri4/main/src/Tpl/Calorin.pm index a233c67..6aadbfe 100755 --- a/copri4/main/src/Tpl/Calorin.pm +++ b/copri4/main/src/Tpl/Calorin.pm @@ -221,7 +221,7 @@ sub tpl(){ #7=get_event alarm #8=get_position after validate if(!$R::theft_details){ - $search->{int10} = "IN::(7,8)"; + $search->{int05} = "IN::(7,8)"; $search->{int03} = ">::$dbt->{copri_conf}->{theftalarm}->{move_count}";#move count $search->{int07} = ">::$dbt->{copri_conf}->{theftalarm}->{speed}";#speed $search->{int08} = ">::$dbt->{copri_conf}->{theftalarm}->{meter}";#meter @@ -496,7 +496,7 @@ sub tpl(){ my $event_type = ""; my $meter = $cttpos->{$pid}->{int08}; $meter =~ s/\./\,/; - if($cttpos->{$pid}->{int01} && $cttpos->{$pid}->{int10} == 7){ + if($cttpos->{$pid}->{int01} && $cttpos->{$pid}->{int05} == 7){ $event_type = "Alarm detected"; }elsif($cttpos->{$pid}->{int01} && $cttpos->{$pid}->{txt10}){ $event_type = "statusCode $cttpos->{$pid}->{txt10}"; @@ -504,10 +504,15 @@ sub tpl(){ my $gps2card = $q->a({-class=>"linknav3",-href=>"/DMS/Karte?man_gps=$cttpos->{$pid}->{txt06}\&owner=$users_dms->{owner}",-title=>"Karte öffnen"}, "$cttpos->{$pid}->{txt06}"); $event_type = "Alarm movement → GPS $gps2card → speed $speed km/h → distance $meter m "; } + my $bike_state = ""; + if($cttpos->{$pid}->{int10}){ + $bike_state = $dbt->{copri_conf}->{bike_state}->{$cttpos->{$pid}->{int10}}; + } if($cttpos->{$pid}->{int20}){ $lock_state = $dbt->{copri_conf}->{lock_state}->{$cttpos->{$pid}->{int20}}; } - print $q->div({-style=>"float:left;margin-left:$c_left"}, "$i) $pos_id → $end_time → Bike $bikenr $lock_state → $event_type → $u_name"),"\n"; + + print $q->div({-style=>"float:left;margin-left:$c_left"}, "$i) $pos_id → $end_time → Bike $bikenr $bike_state $lock_state → $event_type → $u_name"),"\n"; } diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm index f44bbb7..89a2c60 100755 --- a/copri4/main/src/Tpl/TransPositionen.pm +++ b/copri4/main/src/Tpl/TransPositionen.pm @@ -626,8 +626,10 @@ EOF print $q->div({-style=>"clear:both;height:0.1px;"},""),"\n"; if($ctt->{txt30}){ print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "$ctt->{txt30}"),"\n"; - }elsif( -f "$varenv{pdfinvoice}/$praefix-$ctt->{ct_name}.pdf" ){ + }elsif( -f "$dbt->{copri_conf}->{basedir}/$varenv{syshost}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" ){ print $q->start_form(),"\n"; + print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$ctt->{content_id}"),"\n"; + print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$ctt->{template_id}"),"\n"; print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset"),"\n" if($R::offset); print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit"),"\n" if($R::limit); print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! $ctt->{txt00} eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","send_invoice_again")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); diff --git a/copri4/main/src/scripts/Ilockit_cloud.pl b/copri4/main/src/scripts/Ilockit_cloud.pl index b80de71..3d7398d 100755 --- a/copri4/main/src/scripts/Ilockit_cloud.pl +++ b/copri4/main/src/scripts/Ilockit_cloud.pl @@ -285,10 +285,10 @@ sub get_events { print FILE "statusCode: $resp->{attributes}->{statusCode}\n"; print FILE "serverTime: $resp->{serverTime}\n\n"; - my $int10 = 0; + my $int05 = 0; my $txt10 = $resp->{attributes}->{statusCode}; if($resp->{attributes}->{statusCode} eq "alarm"){ - $int10 = 7; + $int05 = 7; } #insert theft alarm if no theft alarm with theft id if(!$theft_record->{c_id}){ @@ -303,9 +303,10 @@ sub get_events { txt18 => "$record_cc->{$id}->{txt18}", owner => $owner, mtime => "now()", - int10 => "$int10",#theft alarm + int05 => "$int05",#theft alarm int01 => "$resp->{id}",#keeps id for event_type int13 => "$resp->{deviceId}", + int10 => "$record_cc->{$id}->{int10}", int20 => "$record_cc->{$id}->{int20}", start_time => "$serverTime", end_time => "$serverTime", @@ -363,7 +364,7 @@ sub get_positions { $pref_th = { table => "contenttheftpos", fetch => "one", - int10 => 7, + int05 => 7, int13 => $record_cc->{$id}->{int13}, end_time => ">=::(now() - interval '$interval min')", }; @@ -412,8 +413,9 @@ sub get_positions { int07 => "$resp->{speed}", int08 => "$resp->{attributes}->{distance}", int09 => "$resp->{attributes}->{totalDistance}", - int10 => "8",#gps position marker + int05 => "8",#gps position marker int13 => "$resp->{deviceId}", + int10 => "$record_cc->{$id}->{int10}", int20 => "$record_cc->{$id}->{int20}", start_time => "$serverTime", end_time => "$serverTime", @@ -431,7 +433,8 @@ 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}){ + #only if not requested or occupied + if($op_name->{sms_alert} && $record_cc->{$id}->{int10} !~ /2|3/){ system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/sms_message.pl '$op_name->{syshost}' 'send_alarm2hotline' '' '$c_id'"); } } diff --git a/copri4/main/src/scripts/Ilockit_trackingcloud.pl b/copri4/main/src/scripts/Ilockit_trackingcloud.pl index 1e3e480..5ecfa3e 100755 --- a/copri4/main/src/scripts/Ilockit_trackingcloud.pl +++ b/copri4/main/src/scripts/Ilockit_trackingcloud.pl @@ -151,9 +151,7 @@ sub get_tripsum { my $end_time = $ctpos->{end_time}; $end_time =~ s/\s/T/; #add 5 minutes, 300sec for latency - #my $utc_end_time = utctime($end_time,"+300"); - #add 5 minutes + 2 hours end_time Ilockit workaround 2023-04-28 - my $utc_end_time = utctime($end_time,"+7500"); + my $utc_end_time = utctime($end_time,"+300"); $utc_end_time .= "Z"; my $rest = "deviceId=$ctpos->{int13}\&from=$utc_start_time\&to=$utc_end_time"; diff --git a/copri4/main/src/scripts/mailTransport.pl b/copri4/main/src/scripts/mailTransport.pl deleted file mode 120000 index ffa0b5c..0000000 --- a/copri4/main/src/scripts/mailTransport.pl +++ /dev/null @@ -1 +0,0 @@ -../../../../../sharee.bike/copri-bike/main/src/scripts/mailTransport.pl \ No newline at end of file diff --git a/copri4/main/src/scripts/mailTransportcms.pl b/copri4/main/src/scripts/mailTransportcms.pl index 7dc233d..794a2da 100755 --- a/copri4/main/src/scripts/mailTransportcms.pl +++ b/copri4/main/src/scripts/mailTransportcms.pl @@ -3,13 +3,10 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (c) Rainer Gümpelein, TeilRad GmbH # -#2023-01-02 -#adapted from mailTransport.pl without bulkmail -#NEW #managed text by operator cms # #Example -#./src/scripts/mailTransportcms.pl 'shareedms-operator' 'send_alarm2hotline' '[contentuser.c_id]' '[contenttheftpos.c_id]' +#./src/scripts/mailTransportcms.pl 'shareedms-operator' 'send_alarm2hotline' '[user.c_id]' '[contenttxxxx.c_id]' # # # @@ -36,23 +33,23 @@ my %varenv = $cf->envonline(); my $dbt = new DBtank; my $mailtrans = new MailTransport; -my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; +my $now_dt = strftime "%Y.%m.%d %H:%M:%S", localtime; #one contentadr.c_id OR email on command my $todo = $ARGV[1] || ""; -my $adr_id = $ARGV[2] || "";#takes ctt.c_id or ctadr.email +my $adr_id = $ARGV[2] || ""; my $ct_id = $ARGV[3] || ""; -my $attachment = $ARGV[4] || ""; +my $temppw = $ARGV[4] || ""; open(EMA, ">> $dbt->{copri_conf}->{logdir}/mailTransportcms.log"); -print EMA "\n$now_dt, start mailTransportcms.pl syshost: $syshost, todo:$todo, adr_id:$adr_id, ct_id:$ct_id, attachment:$attachment \n"; +print EMA "\n$now_dt, start mailTransportcms.pl syshost: $syshost, todo:$todo, adr_id:$adr_id, ct_id:$ct_id, temppw:$temppw\n"; #mailxcfg is shareeconf/mailx.cfg selection! #hash data to send my $sendref = { mailxcfg => "mailx_default", - #mailxcfg => "mailx_admin", + #mailxcfg => "mailx_admin",#just for tests syshost => "$syshost", mail_to => "", c_id => 0, @@ -62,27 +59,44 @@ my $sendref = { attachment => "", }; -#my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || die "project not defined"; my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix} || ""; my $sendmail = {}; -#send_emailack -if($todo eq "send_emailack" && looks_like_number($adr_id)){ - $sendmail = send_emailack($todo,$sendref,$adr_id); -} +#user-account must be exist to send user message +my $ctadr = { c_id => 0 }; +if(looks_like_number($adr_id)){ + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1"); + my $pref_adr = { + table => "contentadr", + fetch => "one", + c_id => "$adr_id", + }; + $ctadr = $dbt->fetch_tablerecord($dbh_primary,$pref_adr); -#send_password -if($todo eq "send_password" && looks_like_number($adr_id)){ - $sendmail = send_password($todo,$sendref,$adr_id); -} + #send_emailack + if($todo eq "send_invoice" && looks_like_number($ct_id)){ + $sendref->{mailxcfg} = "mailx_rechnung"; + $sendmail = send_invoice($todo,$sendref,$ctadr,$ct_id); + } -#send_cpdate_message, done by cronjob cpdate_check.pl -if(($todo eq "send_cpupdate_message" || $todo eq "send_proactive_cpupdate_message") && looks_like_number($adr_id)){ - $sendmail = send_cpupdate_message($todo,$sendref,$adr_id); -} + #send_emailack + if($todo eq "send_emailack"){ + $sendmail = send_emailack($todo,$sendref,$ctadr); + } + + #send_password + if($todo eq "send_password"){ + $sendmail = send_password($todo,$sendref,$ctadr,$temppw); + } + + #send_cpdate_message, done by cronjob cpdate_check.pl + if(($todo eq "send_cpupdate_message" || $todo eq "send_proactive_cpupdate_message")){ + $sendmail = send_cpupdate_message($todo,$sendref,$ctadr); + } +}#end user-account message #send_alarm2hotline, done by Ilockit_cloud.pl -if($todo eq "send_alarm2hotline" && looks_like_number($adr_id) && looks_like_number($ct_id)){ +if($todo eq "send_alarm2hotline" && looks_like_number($ct_id)){ $sendmail = send_alarm2hotline($sendref,$ct_id); } @@ -92,132 +106,143 @@ if($sendmail->{c_id}){ print EMA "Error, can not sendmailjob without c_id\n"; } +#send_invoice +sub send_invoice { + my $todo = shift; + my $sendref = shift; + my $ctadr = shift; + my $ct_id = shift; + + my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || ""; + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1"); + my $pref_ctu = { + table => "contentuser", + fetch => "one", + c_id => "1",#primary hotline + }; + my $uadr = { c_id => 0 }; + $uadr = $dbt->fetch_tablerecord($dbh_primary,$pref_ctu); + + $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} }); + my $cms_message_key = "email-invoice"; + + my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},"iso-8859-1"); + my $fetchctt = { + table => "contenttrans", + fetch => "one", + c_id => "=::$ct_id", + }; + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_tablerecord($dbh,$fetchctt); + + $sendref = prepare_content($sendref,$ctadr,$uadr,$ctt,$varenv{cms}->{$cms_message_key}->{txt}); + + my $updatectt = { + table => "contenttrans", + c_id => "$ct_id", + }; + $dbt->update_one($dbh,$updatectt,"txt30='$now_dt, $ctt->{txt00} per eMail versandt'"); + + return $sendref; +}#end send_invoice + #send_emailack sub send_emailack { my $todo = shift; my $sendref = shift; - my $adr_id = shift || ""; + my $ctadr = shift; - #TODO - return; -} + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1"); + my $pref_ctu = { + table => "contentuser", + fetch => "one", + c_id => "1",#primary hotline + }; + my $uadr = { c_id => 0 }; + $uadr = $dbt->fetch_tablerecord($dbh_primary,$pref_ctu); + + $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} }); + my $cms_message_key = "email-emailack"; + + #Ack digest + if($ctadr->{txt34} =~ /^(.{5})/){ + $ctadr->{txt34} = $1; + }else{ + $ctadr->{txt34} = ""; + } + + $sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); + + return $sendref; +}#end send_emailack #send_password sub send_password { my $todo = shift; my $sendref = shift; - my $adr_id = shift || ""; + my $ctadr = shift; + my $temppw = shift; - #TODO - return; -} + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1"); + my $pref_ctu = { + table => "contentuser", + fetch => "one", + c_id => "1",#primary hotline + }; + my $uadr = { c_id => 0 }; + $uadr = $dbt->fetch_tablerecord($dbh_primary,$pref_ctu); + + $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} }); + my $cms_message_key = "email-temppassword"; + + #temp pw + if($temppw){ + $ctadr->{txt04} = $temppw; + }else{ + $ctadr->{txt04} = ""; + } + + $sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); + + return $sendref; +}#end send_password #send_cpupdate_message sub send_cpupdate_message { my $todo = shift; my $sendref = shift; - my $adr_id = shift || ""; + my $ctadr = shift || {}; - my $client_encoding = "iso-8859-1"; - my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},$client_encoding); + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1"); - #TeilRad Kontakt my $pref_ctu = { table => "contentuser", fetch => "one", - c_id => "1",#Kontakt-hotline + c_id => "1",#primary hotline }; my $uadr = { c_id => 0 }; $uadr = $dbt->fetch_tablerecord($dbh_primary,$pref_ctu); - #CMS text + $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} }); my $cms_message_key = "email-cpupdate-message"; $cms_message_key = "email-proactive-cpupdate-message" if($todo eq "send_proactive_cpupdate_message"); - my $pref_cms = { - table => "contentuser", - fetch => "one", - ct_name => "$cms_message_key", - }; - my $cms_prim = { c_id => 0, txt01 => '' }; - $cms_prim = $dbt->fetch_tablerecord($dbh_primary,$pref_cms); - - #Kunde - my $pref_adr = { - table => "contentadr", - fetch => "one", - c_id => "$adr_id", - }; - my $cta = { c_id => 0 }; - $cta = $dbt->fetch_tablerecord($dbh_primary,$pref_adr); - - $sendref = prepare_content($sendref,$cta,$cms_prim,$uadr); + $sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); return $sendref; }#end send_cpupdate_message -#prepare email by cms markup -sub prepare_content { - my $sendref = shift; - my $cta = shift; - my $cms_prim = shift; - my $uadr = shift; - - my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg"; - my $conf = Config::General->new($globalconf_file); - my %globalconf = $conf->getall; - - my $app_name = "App"; - while (my ($key, $merchant) = each %{ $globalconf{merchant_ids} }) { - $app_name =~ s/$app_name/$merchant->{app_name}/ if($merchant->{app_name} && $cta->{int15} && $cta->{int15} == $merchant->{id}); - } - my $subject = "TeilRad Mietradsystem";#default - $subject = $1 if($cms_prim->{txt01} =~ /--subject--(.*)--subject--/); - $cms_prim->{txt01} =~ s/--subject--$subject--subject--//; - $cms_prim->{txt01} =~ s/\n//; - $cms_prim->{txt01} =~ s/\n//; - -my $signature = <{txt01} - $uadr->{txt03} - $uadr->{txt06} - $uadr->{txt07} - $uadr->{txt08} - - $uadr->{txt84} - -EOF -; - - $sendref->{mail_to} = $cta->{txt08}; - $sendref->{c_id} = $cta->{c_id}; - $sendref->{subject} = $subject; - $sendref->{subject} =~ s/::app_name::/$app_name/; - $sendref->{subject} =~ s/Mein // if($sendref->{subject} =~ /^Mein/); - - $sendref->{message} = $cms_prim->{txt01}; - $sendref->{message} =~ s/::user_name::/$cta->{txt01}/; - $sendref->{message} =~ s/::app_name::/$app_name/g; - $sendref->{message} =~ s/::signature::/$signature/; - $sendref->{message} =~ s/\n/\
/g; - - return $sendref; -}#end prepare_content - #send_alarm2hotline sub send_alarm2hotline { my $sendref = shift; my $ct_id = shift || ""; - my $client_encoding = "iso-8859-1"; - my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},$client_encoding); - + my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},"iso-8859-1"); my $pref_ctu = { table => "contentuser", fetch => "one", - c_id => "1",#Kontakt-hotline + c_id => "1",#primary hotline }; my $uadr = { c_id => 0 }; $uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu); @@ -263,11 +288,71 @@ EOF $sendref->{message} =~ s/\n/\
/g; return $sendref; -} +}#end send_alarm2hotline + +#prepare email by cms markup +sub prepare_content { + my $sendref = shift; + my $ctadr = shift; + my $uadr = shift; + my $ctt = shift || {}; + my $cms_prim = shift; + + my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg"; + my $conf = Config::General->new($globalconf_file); + my %globalconf = $conf->getall; + + my $app_name = "Mietrad App"; + #while (my ($key, $merchant) = each %{ $globalconf{merchant_ids} }) { + # $app_name =~ s/$app_name/$merchant->{app_name}/ if($merchant->{app_name} && $ctadr->{int15} && $ctadr->{int15} == $merchant->{id}); + #} + $app_name = $dbt->{operator}->{$varenv{dbname}}->{app_name}; + my $invoice_name = "$ctt->{txt00}-$varenv{dbname}-$ctt->{ct_name}.pdf"; + $sendref->{attachment} = "$invoice_name"; + + my $subject = "TeilRad Mietradsystem";#default + $subject = $1 if($cms_prim =~ /--subject--(.*)--subject--/); + $cms_prim =~ s/--subject--$subject--subject--//; + $cms_prim =~ s/\n//; + $cms_prim =~ s/\n//; + +my $signature = <{txt01} + $uadr->{txt03} + $uadr->{txt06} + $uadr->{txt07} + $uadr->{txt08} + + $uadr->{txt84} + +EOF +; + + $sendref->{mail_to} = $ctadr->{txt08}; + $sendref->{c_id} = $ctadr->{c_id}; + $sendref->{subject} = $subject; + $sendref->{subject} =~ s/::app_name::/$app_name/; + $sendref->{subject} =~ s/Mein // if($sendref->{subject} =~ /^Mein/); + + $sendref->{message} = $cms_prim; + $sendref->{message} =~ s/::user_name::/$ctadr->{txt01}/; + $sendref->{message} =~ s/::app_name::/$app_name/g; + $sendref->{message} =~ s/::invoice_name::/$invoice_name/; + $sendref->{message} =~ s/::txid::/$ctt->{txt16}/; + $sendref->{message} =~ s/::email_temppassword::/\$ctadr->{txt04}\<\/b\>/g; + $sendref->{message} =~ s/::email_ack_digest::/\$ctadr->{txt34}\<\/b\>/g; + $sendref->{message} =~ s/::signature::/$signature/; + $sendref->{message} =~ s/\n/\
/g; + + return $sendref; +}#end prepare_content + #sending mail job sub sendmailjob { my $sendref = shift || ""; + my $dbh = ""; #at first connect mailxchanger by mailx.cfg config my ($smtp,$mailxconf) = $mailtrans->mail_connect($sendref); @@ -278,8 +363,9 @@ sub sendmailjob { $ret = $mailtrans->mail_transport($smtp,$mailxconf,$sendref); print EMA "done mailing with state to $sendref->{mail_to}: $ret\n"; + print EMA Dumper($sendref); }else{ - print EMA "Error, no or false email address $sendref->{mail_to}, exit\n"; + print EMA "Error, no or false email:\n$sendref->{mail_to}\n$sendref->{subject}\n$sendref->{message}, exit\n"; } } diff --git a/copri4/main/src/scripts/sms_message.pl b/copri4/main/src/scripts/sms_message.pl index 246426f..e8c4df1 100755 --- a/copri4/main/src/scripts/sms_message.pl +++ b/copri4/main/src/scripts/sms_message.pl @@ -159,7 +159,16 @@ if($todo eq "send_alarm2hotline" && $pos_id){ my $ct = { c_id => 0 }; $ct = $dbt->fetch_tablerecord($dbh_operator,$pref_ct); - $smstrans->sms_message($todo,"",$phone,"$oprefix$ct->{barcode}"); + + if($dbt->{copri_conf}->{sms_to_alarm}){ + my @alarm_phone = ("$dbt->{copri_conf}->{sms_to_alarm}"); + @alarm_phone = split(/\|/,$dbt->{copri_conf}->{sms_to_alarm}) if($dbt->{copri_conf}->{sms_to_alarm} =~ /\|/); + foreach(@alarm_phone){ + $smstrans->sms_message($todo,"",$_,"$oprefix$ct->{barcode}"); + } + }else{ + $smstrans->sms_message($todo,"",$phone,"$oprefix$ct->{barcode}"); + } }#end