user message on longterm rental, based also on fleed operator. Bikeakku view config

This commit is contained in:
ragu 2024-02-26 20:30:45 +01:00
parent addf1ab6db
commit 030091de20
16 changed files with 364 additions and 248 deletions

View file

@ -999,6 +999,7 @@ sub booking_request(){
} }
#Rental is only permitted if sum_balance <= 1 (in primary prepaid context positive) #Rental is only permitted if sum_balance <= 1 (in primary prepaid context positive)
#Rental is only permitted if no invoice with payment_fault or opos #Rental is only permitted if no invoice with payment_fault or opos
$bw->log("Rental is only permitted if no invoice with payment_fault or opos: $sum_balance <= 1 && !$ctt_opos->{c_id}, userID: $auth->{c_id} ",$sum_balance,"");
if($sum_balance <= 1 && !$ctt_opos->{c_id}){ if($sum_balance <= 1 && !$ctt_opos->{c_id}){
#2 = "requested" #2 = "requested"
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$now_dt,$bike,"2",$owner,$sig_book); $pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$now_dt,$bike,"2",$owner,$sig_book);
@ -1990,11 +1991,10 @@ sub bikes_available(){
$return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy"; $return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy";
my $max_bars = 5; my $max_bars = 5;
my $current_bars = 0; my $current_bars = 0;
my $charge_view_hidden = 0;#1=hide charge view my $charge_view_hidden = 0;#0=view charge
#$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); $charge_view_hidden = 1 if($record->{$id}->{battery_hidden});#1=hide charge view
my $backend_accessible = 1; my $backend_accessible = 0;#0=user has edit load
$backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user $backend_accessible = 1 if($record->{$id}->{battery_accessible});#1=charge from backend
#$backend_accessible = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/);#for asking user
$return->{$id}->{bike_type}->{battery}->{charge_max_bars} = "$max_bars"; $return->{$id}->{bike_type}->{battery}->{charge_max_bars} = "$max_bars";
$return->{$id}->{bike_type}->{battery}->{charge_current_bars} = "$current_bars"; $return->{$id}->{bike_type}->{battery}->{charge_current_bars} = "$current_bars";
$return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0"; $return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0";
@ -2175,11 +2175,10 @@ sub bikes_all(){
$return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy"; $return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy";
my $max_bars = 5; my $max_bars = 5;
my $current_bars = 0; my $current_bars = 0;
my $charge_view_hidden = 0;#1=hide charge view my $charge_view_hidden = 0;
#$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); $charge_view_hidden = 1 if($record->{$id}->{battery_hidden});#1=hide charge view
my $backend_accessible = 1;#1=battery charge from backend, 0=asking user my $backend_accessible = 0;
$backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user $backend_accessible = 1 if($record->{$id}->{battery_accessible});#1=charge from backend
#$backend_accessible = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/);#for asking user
$return->{$id}->{bike_type}->{battery}->{charge_max_bars} = "$max_bars"; $return->{$id}->{bike_type}->{battery}->{charge_max_bars} = "$max_bars";
$return->{$id}->{bike_type}->{battery}->{charge_current_bars} = "$current_bars"; $return->{$id}->{bike_type}->{battery}->{charge_current_bars} = "$current_bars";
$return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0"; $return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0";
@ -2344,21 +2343,40 @@ sub stations_available(){
template_id => 197, template_id => 197,
c_id => "1", c_id => "1",
}; };
my $hotline_data = $dbt->fetch_record($dbh,$hotline_hash); my $hotline_data = {
txt01 => "",
txt84 => "",
txt07 => "",
txt08 => "",
};
$hotline_data = $dbt->fetch_record($dbh,$hotline_hash);
my $op_return = {}; my $op_return = {};
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){ foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
$record->{$id}->{txt06} =~ s/\s//g if($record->{$id}->{txt06}); $record->{$id}->{txt06} =~ s/\s//g if($record->{$id}->{txt06});
if($record->{$id}->{txt06} && $record->{$id}->{txt06} =~ /\d+\.\d+\,\d+\.\d+/){ if($record->{$id}->{txt06} && $record->{$id}->{txt06} =~ /\d+\.\d+\,\d+\.\d+/){
my $fleed = {
name => "",
hours => "",
phone => "",
email => "",
};
my $bike_count = 0; my $bike_count = 0;
my @bike_ids = (); my @bike_ids = ();
foreach my $b_id (keys (%$record_bikes)){ foreach my $b_id (keys (%$record_bikes)){
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){ if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
push @bike_ids,$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $record_bikes->{$b_id}->{barcode}; push @bike_ids,$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $record_bikes->{$b_id}->{barcode};
$bike_count++; $bike_count++;
$fleed = {
name => "$record_bikes->{$b_id}->{fleed_name}",
hours => "$record_bikes->{$b_id}->{fleed_hours}",
phone => "$record_bikes->{$b_id}->{fleed_phone}",
email => "$record_bikes->{$b_id}->{fleed_email}",
};
} }
} }
$return->{$id}->{bike_count} = "$bike_count"; $return->{$id}->{bike_count} = "$bike_count";
$return->{$id}->{bike_ids} = [@bike_ids]; $return->{$id}->{bike_ids} = [@bike_ids];
@ -2403,16 +2421,39 @@ sub stations_available(){
$return->{$id}->{station_group} = [@station_group]; $return->{$id}->{station_group} = [@station_group];
} }
$return->{$id}->{operator_data} = { if($fleed->{email} && $fleed->{phone}){
"operator_name" => "", $return->{$id}->{operator_data} = {
"operator_hours" => "", operator_name => $fleed->{name},
"operator_phone" => "", operator_hours => $fleed->{hours},
"operator_email" => "", operator_phone => $fleed->{phone},
}; operator_email => $fleed->{email},
$return->{$id}->{operator_data}->{operator_name} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt01})) if($hotline_data->{txt01}); };
$return->{$id}->{operator_data}->{operator_hours} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt84})) if($hotline_data->{txt84}); }else{
$return->{$id}->{operator_data}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07}); $return->{$id}->{operator_data} = {
$return->{$id}->{operator_data}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08}); operator_name => $hotline_data->{txt01},
operator_hours => $hotline_data->{txt84},
operator_phone => $hotline_data->{txt07},
operator_email => $hotline_data->{txt08},
};
}
#not desired 2024-02-15
if(1==2){
$return->{$id}->{contact_data} = {
software => {
company_name => "$hotline_data->{txt01}",
opening_hours => "$hotline_data->{txt84}",
phone => "$hotline_data->{txt07}",
email => "$hotline_data->{txt08}"
},
hardware => {
company_name => "$fleed->{name}",
opening_hours => "$fleed->{hours}",
phone => "$fleed->{phone}",
email => "$fleed->{email}"
}
};
}
$return->{$id}->{cached} = "0"; $return->{$id}->{cached} = "0";
$return->{$id}->{withpub} = "0"; $return->{$id}->{withpub} = "0";
@ -2425,11 +2466,11 @@ sub stations_available(){
$op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id}; $op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};
}
} }
}
#json caching #json caching
if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){ if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){
#order by sharing_type #order by sharing_type
foreach my $tarif_key (keys(%$adrtarif_hash)){ foreach my $tarif_key (keys(%$adrtarif_hash)){
@ -2452,7 +2493,7 @@ sub stations_available(){
} }
} }
} }
}#end caching }#end caching
return ($op_return, $record); return ($op_return, $record);
}#end stations_available }#end stations_available
@ -3142,7 +3183,7 @@ sub auth_verify(){
my $last_used_operator = $record->{txt19};#check if this is primary and/or useable my $last_used_operator = $record->{txt19};#check if this is primary and/or useable
#$bw->log("last_used_operator selected by txt19:",$last_used_operator,""); #$bw->log("last_used_operator selected by txt19:",$last_used_operator,"");
if($last_used_operator){ if($last_used_operator){
my $dbh_operator = $dbt->dbconnect_extern("$last_used_operator"); my $dbh_operator = $dbt->dbconnect_extern("$last_used_operator","iso-8859-1");
my $hotline_hash = { my $hotline_hash = {
table => "contentuser", table => "contentuser",
fetch => "one", fetch => "one",
@ -3157,8 +3198,8 @@ sub auth_verify(){
"operator_phone" => "", "operator_phone" => "",
"operator_email" => "", "operator_email" => "",
}; };
$return->{last_used_operator}->{operator_name} = $hotline_data->{txt01} if($hotline_data->{txt01}); $return->{last_used_operator}->{operator_name} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt01})) if($hotline_data->{txt01});
$return->{last_used_operator}->{operator_hours} = $hotline_data->{txt84} if($hotline_data->{txt84}); $return->{last_used_operator}->{operator_hours} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt84})) if($hotline_data->{txt84});
$return->{last_used_operator}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07}); $return->{last_used_operator}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07});
$return->{last_used_operator}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08}); $return->{last_used_operator}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08});
} }

View file

@ -71,7 +71,7 @@ my $response = {
apiserver => "$apiserver", apiserver => "$apiserver",
response => "$respreq", response => "$respreq",
uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}", uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}",
copri_version => "4.1.23.28", copri_version => "4.1.23.29",
user_id => "", user_id => "",
authcookie => "", authcookie => "",
new_authcoo => "0", new_authcoo => "0",

View file

@ -792,7 +792,7 @@ sub fetch_record(){
$where .= " and rel.$key $op $value" if($key =~ /^(parent_id|main_id|template_id|rel_id)$/ && $value); $where .= " and rel.$key $op $value" if($key =~ /^(parent_id|main_id|template_id|rel_id)$/ && $value);
if($key =~ /^(ct_name$|txt\d+|uri\d+|state)$/ && $value){ if($key =~ /^(ct_name$|txt\d+|uri\d+|state)$/ && $value){
if($key eq "state" && $value eq "payment_fault"){ if($key eq "state" && $value eq "payment_fault"){
$where .= " and (ct.int14 >= 1 OR ct.int14 = 7)";#OPOS or Zahlungsausfall $where .= " and (ct.int14 >= 1 OR ct.int04 = 7)";#OPOS or Zahlungsausfall
}elsif($value =~ /length/){ }elsif($value =~ /length/){
$where .= " and $value"; $where .= " and $value";
}elsif($value eq "null"){ }elsif($value eq "null"){
@ -832,7 +832,7 @@ sub fetch_record(){
my $sql = ""; my $sql = "";
if($fetch->{table} eq "content"){ if($fetch->{table} eq "content"){
$sql = "SELECT ct.*,rel.*,nd.node_name,nd.parent_id,nd.type_id,nd.energy_id,nd.archive,nd.fleed_name,nd.fleed_hours,nd.fleed_email,nd.fleed_phone FROM $fetch->{table} ct, relation rel, nodes nd $where $order"; $sql = "SELECT ct.*,rel.*,nd.node_name,nd.parent_id,nd.type_id,nd.energy_id,nd.battery_hidden,nd.battery_accessible,nd.archive,nd.fleed_name,nd.fleed_hours,nd.fleed_email,nd.fleed_phone FROM $fetch->{table} ct, relation rel, nodes nd $where $order";
}else{ }else{
$sql = "SELECT ct.*,rel.*,nd.node_name,nd.parent_id FROM $fetch->{table} ct, relation rel, nodes nd $where $order"; $sql = "SELECT ct.*,rel.*,nd.node_name,nd.parent_id FROM $fetch->{table} ct, relation rel, nodes nd $where $order";
} }
@ -1274,10 +1274,11 @@ sub collect_transpos {
$where .= " ORDER BY cp.c_id DESC LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit}); $where .= " ORDER BY cp.c_id DESC LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
my $sql = "SELECT cp.* from $search->{table} cp, contenttrans ct $where"; my $sql = "SELECT cp.* from $search->{table} cp, contenttrans ct $where";
#2024-02-22 not used anymore
#for system messaging #for system messaging
if($messaging){ #if($messaging){
$sql = "SELECT cp.*,ct.txt07 AS phone,ct.txt08 AS email,ct.txt11 AS lang from $search->{table} cp, contenttrans ct $where"; # $sql = "SELECT cp.*,ct.txt07 AS phone,ct.txt08 AS email,ct.txt11 AS lang from $search->{table} cp, contenttrans ct $where";
} #}
my $sth = $dbh->prepare($sql); my $sth = $dbh->prepare($sql);
my $rc = $sth->execute(); my $rc = $sth->execute();
my $ct = $sth->fetchall_hashref("c_id"); my $ct = $sth->fetchall_hashref("c_id");

View file

@ -10,6 +10,7 @@ use warnings;
use POSIX; use POSIX;
use CGI::Cookie (); use CGI::Cookie ();
use CGI ':standard'; use CGI ':standard';
use Time::Piece;
use DateTime; use DateTime;
use DateTime::Format::Pg; use DateTime::Format::Pg;
use DBI; use DBI;
@ -27,9 +28,7 @@ use Mod::APIfunc;
use Mod::Shareework; use Mod::Shareework;
use Mod::Prelib; use Mod::Prelib;
use Mod::Payment; use Mod::Payment;
use Mod::Modalbox; #use Data::Dumper;
use Mod::Modalbox3;
use Data::Dumper;
sub handler { sub handler {
my $re = shift; my $re = shift;
@ -101,8 +100,8 @@ sub handler {
} }
my $dyn_js = ""; my $dyn_js = "";
my $users_dms = {}; my $users_dms = { u_id => 0 };
my $users_sharee = {}; my $users_sharee = { c_id => 0 };
my $api_return = {}; my $api_return = {};
print $q->header(-charset=>"$html_charset"); print $q->header(-charset=>"$html_charset");
@ -157,10 +156,10 @@ sub handler {
if($users_dms->{u_id}){ if($users_dms->{u_id}){
my $update_users = { my $update_users = {
table => "users", table => "users",
owner => $aowner, change => "no_time",
u_id => $users_dms->{u_id} u_id => $users_dms->{u_id}
}; };
$dbt->update_one($dbh,$update_users,"cookie='$coo'"); $dbt->update_one($dbh,$update_users,"cookie='$coo',atime='now()'");
print redirect("$varenv{wwwhost}"); print redirect("$varenv{wwwhost}");
exit 0; exit 0;
@ -182,7 +181,26 @@ sub handler {
#DMS #DMS
if($users_sharee->{c_id} && $varenv{orga} eq "dms" && $coo && length($coo) > 20){ if($users_sharee->{c_id} && $varenv{orga} eq "dms" && $coo && length($coo) > 20){
$users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'"); $users_dms = { u_id => 0 };
$users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo' and u_id = $users_sharee->{c_id}");
my $update_users = {
table => "users",
change => "no_time",
u_id => $users_dms->{u_id}
};
my $dt1 = DateTime->now;
my $dt2 = DateTime->now;
$dt2 = DateTime::Format::Pg->parse_datetime($users_sharee->{atime}) if($users_sharee->{atime});
my $logout_hours = 2;
my $dt2_over = $dt2->add( hours => $logout_hours );
if($dt1 > $dt2_over){
$apif->authout($q,$coo);
$dbt->update_one($dbh,$update_users,"cookie=''");
print redirect("$varenv{wwwhost}?autologout=$logout_hours");
exit 0;
}
$dbt->update_one($dbh,$update_users,"atime='now()'");
} }
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($lang) }); $varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($lang) });
@ -218,7 +236,7 @@ sub handler {
#if user-pw authorized, then ignore conflict_ because it matches exist user-data #if user-pw authorized, then ignore conflict_ because it matches exist user-data
#should be result to Uhps page #should be result to Uhps page
if($shareec_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){ if($shareec_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){
$return = $shwo->delete_account($shareec_id,$users_dms->{u_id}); $return = $shwo->delete_account($shareec_id,$aowner);
$apif->authout($q,$coo) if($coo); $apif->authout($q,$coo) if($coo);
print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1"); print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1");
exit 0; exit 0;
@ -643,7 +661,7 @@ sub handler {
$dbt->update_operatorsloop($varenv{dbname},$users_sharee->{c_id},"update"); $dbt->update_operatorsloop($varenv{dbname},$users_sharee->{c_id},"update");
} }
print FILE Dumper($update_adr) . "\n" if($debug); #print FILE Dumper($update_adr) . "\n" if($debug);
close(FILE); close(FILE);
}#end payone response with pseudocardpan }#end payone response with pseudocardpan
} }

View file

@ -17,7 +17,7 @@ use Net::SMTP;
use MIME::Base64 qw( encode_base64 ); use MIME::Base64 qw( encode_base64 );
use Try::Tiny; use Try::Tiny;
use Config::General; use Config::General;
use Scalar::Util qw(looks_like_number);
use Mod::Basework; use Mod::Basework;
use Mod::DBtank; use Mod::DBtank;
use Data::Dumper; use Data::Dumper;
@ -178,6 +178,129 @@ sub mail_transport(){
return $ret; return $ret;
}#end mail_send }#end mail_send
#prepare email by cms markup
sub prepare_content {
my $self = shift;
my $varenv = shift;
my $sendref = shift;
my $ctadr = shift;
my $uadr = shift;
my $ctt = shift || {};
my $cms_prim = shift || "";
my $with_pdf = shift || "";
my $app_name = shift || "";
if(!$app_name && $dbt->{operator}->{$varenv->{dbname}}->{app_name}){
$app_name = $dbt->{operator}->{$varenv->{dbname}}->{app_name};
}else{
$app_name = "Mietrad App";
}
my $invoice_name = "";
my $invoice_nr = "";
my $total_sum = "";
my $total_price = "";
if($ctadr->{total_price}){
$total_price = $ctadr->{total_price};
$total_price =~ s/\./,/;
}
my $sharee_ticket = "";
my $fibu_user = "";
my $prepaid_id = "";
my $payone_link = "";
my $stagemode = $1 if($dbt->{copri_conf}->{stage} =~ /^(\w)/);
if(ref($ctt) eq "HASH" && $ctt->{ct_name}){
$invoice_name = "$ctt->{txt00}-$varenv->{dbname}-$ctt->{ct_name}.pdf";
$sendref->{attachment} = "$invoice_name" if($with_pdf);
$invoice_nr = "$varenv->{dbname}-$ctt->{ct_name}";
$total_sum = "$ctt->{int01}";#invoice sum
$total_sum =~ s/\./,/;
$sharee_ticket = "[$invoice_nr]";
$fibu_user = "\n$ctt->{fibu_user}\n" if($ctt->{fibu_user});
$prepaid_id = $stagemode . $ctt->{ct_id} . "-" . $ctt->{c_id};
$payone_link = $ctt->{txt30};
}
my $subject = "TeilRad Mietradsystem";#default
$subject = $1 if($cms_prim =~ /--subject--(.*)--subject--/);
$cms_prim =~ s/--subject--$subject--subject--//;
$subject .= " $sharee_ticket" if($sharee_ticket && !$payone_link);
$cms_prim =~ s/\n//;
my $signature = <<EOF
--$fibu_user
$uadr->{txt01}
$uadr->{txt03}
$uadr->{txt06}
$uadr->{txt07}
$uadr->{txt08}
$uadr->{txt09}
$uadr->{txt10}
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->{subject} =~ s/::bike::/$ctadr->{bike}/g if($ctadr->{bike});
$sendref->{message} = $cms_prim;
$sendref->{message} =~ s/::user_name::/$ctadr->{txt01}/g;
$sendref->{message} =~ s/::bike::/$ctadr->{bike}/g if($ctadr->{bike});
$sendref->{message} =~ s/::app_name::/$app_name/g;
$sendref->{message} =~ s/::invoice_nr::/\<b\>$invoice_nr\<\/b\>/g if($invoice_nr);
$sendref->{message} =~ s/::total_price::/\<b\>$total_price\<\/b\>/g if($total_price);
$sendref->{message} =~ s/::total_sum::/\<b\>$total_sum\<\/b\>/g if($total_sum);
$sendref->{message} =~ s/::invoice_name::/$invoice_name/g if($invoice_name);
$sendref->{message} =~ s/::txid::/$ctt->{txt16}/;
$sendref->{message} =~ s/::email_temppassword::/\<b\>$ctadr->{txt04}\<\/b\>/g;
$sendref->{message} =~ s/::email_ack_digest::/\<b\>$ctadr->{txt34}\<\/b\>/g;#send_emailack
$sendref->{message} =~ s/::prepaid_id::/\<b\>$prepaid_id\<\/b\>/g;
$sendref->{message} =~ s/::payone_link::/\<b\><a href='$payone_link'>$payone_link<\/a>\<\/b\>/g;
$sendref->{message} =~ s/::signature::/$signature/;
$sendref->{message} =~ s/\n/\<br \/\>/g;
return $sendref;
}#end prepare_content
#messanger_divers longterm_occupied
sub mail_hours_occupied {
my $self = shift;
my $varenv = shift;
my $hours = shift || 0;
my $uadr = shift;
my $contentpos = shift;
my $sendref = $self->sendrefhash();
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1");
my $ctadr = { c_id => 0 };
if(looks_like_number($contentpos->{ca_id})){
my $pref_adr = {
table => "contentadr",
fetch => "one",
c_id => $contentpos->{ca_id},
};
$ctadr = $dbt->fetch_tablerecord($dbh_primary,$pref_adr);
$ctadr->{bike} = $contentpos->{ct_name};
$ctadr->{total_price} = $contentpos->{total_price};
my $lang = $ctadr->{txt11} || $ctadr->{txt10};
$varenv->{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $lang });
}
my $cms_message_key = "";
$cms_message_key = $dbt->{copri_conf}->{message_rental}->{Email}->{$hours};
$sendref = $self->prepare_content($varenv,$sendref,$ctadr,$uadr,"",$varenv->{cms}->{$cms_message_key}->{txt},"");
my ($smtp,$mailxconf) = $self->mail_connect($sendref);
my $ret = $self->mail_transport($smtp,$mailxconf,$sendref);
return $ret;
}
#we use just db-selector hashes #we use just db-selector hashes
sub mail_feedback2garage { sub mail_feedback2garage {
@ -197,3 +320,4 @@ sub mail_feedback2garage {
} }
1; 1;

View file

@ -145,7 +145,7 @@ sub admin_tpl(){
push @s_valxx, "$s_key:$s_hash->{$s_key}"; push @s_valxx, "$s_key:$s_hash->{$s_key}";
} }
print $q->td({-class=>'content1_cms'},$but->selector_class("$key","","",$node_meta->{$key},@s_valxx)),"\n"; print $q->td({-class=>'content1_cms'},$but->selector_class("$key","","",$node_meta->{$key},@s_valxx)),"\n";
}elsif($key eq "energy_id" && $isize eq "checkbox"){ }elsif($key =~ /energy_id|battery_/ && $isize eq "checkbox"){
print $q->Tr(); print $q->Tr();
print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms', -colspan=>'1'}, $but->checkbox("1","$key","$node_meta->{$key}")),"\n"; print $q->td({-class=>'content1_cms', -colspan=>'1'}, $but->checkbox("1","$key","$node_meta->{$key}")),"\n";

View file

@ -1245,7 +1245,8 @@ sub prepaid_request {
$cttpos->{c_id} = $dbt->insert_pos($dbh,$ctt_prepaid->{c_id},$ct,"",$ctadr,"","","","0",$owner,""); $cttpos->{c_id} = $dbt->insert_pos($dbh,$ctt_prepaid->{c_id},$ct,"",$ctadr,"","","","0",$owner,"");
$dbt->update_one($dbh,{table => 'contenttranspos',c_id => $cttpos->{c_id}},"barcode = $cttpos->{c_id},ct_name = '$ctt_prepaid->{c_id}-$cttpos->{c_id}'"); $dbt->update_one($dbh,{table => 'contenttranspos',c_id => $cttpos->{c_id}},"barcode = $cttpos->{c_id},ct_name = '$ctt_prepaid->{c_id}-$cttpos->{c_id}'");
$feedb->{prepaid_id} = $ctt_prepaid->{c_id} . "-" . $cttpos->{c_id}; my $stagemode = $1 if($dbt->{copri_conf}->{stage} =~ /^(\w)/);#to get unique
$feedb->{prepaid_id} = $stagemode . $ctt_prepaid->{c_id} . "-" . $cttpos->{c_id};
} }
$feedb->{prepaid_account} = $ctt_prepaid->{c_id}; $feedb->{prepaid_account} = $ctt_prepaid->{c_id};
@ -1279,13 +1280,14 @@ sub collect_prepaid {
}; };
my $cttpos = { c_id => 0 }; my $cttpos = { c_id => 0 };
$cttpos = $dbt->collect_post($dbh,$posref); $cttpos = $dbt->collect_post($dbh,$posref);
my $stagemode = $1 if($dbt->{copri_conf}->{stage} =~ /^(\w)/);
foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){ foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){
#print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>"; #print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>";
if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} == 0){ if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} == 0){
$prepaidhash->{invoice_id} = $cttpos->{$id}->{ct_id}; $prepaidhash->{invoice_id} = $cttpos->{$id}->{ct_id};
$prepaidhash->{number} = $cttpos->{$id}->{c_id}; $prepaidhash->{number} = $cttpos->{$id}->{c_id};
$prepaidhash->{prepaid_id} = $cttpos->{$id}->{ct_id} . "-" . $cttpos->{$id}->{c_id};#payone reference $prepaidhash->{prepaid_id} = $stagemode . $cttpos->{$id}->{ct_id} . "-" . $cttpos->{$id}->{c_id};#payone reference
$prepaidhash->{description} = $cttpos->{$id}->{txt01}; $prepaidhash->{description} = $cttpos->{$id}->{txt01};
$prepaidhash->{response_log} = $cttpos->{$id}->{txt25}; $prepaidhash->{response_log} = $cttpos->{$id}->{txt25};
$prepaidhash->{payone_link} = $cttpos->{$id}->{txt30}; $prepaidhash->{payone_link} = $cttpos->{$id}->{txt30};
@ -1435,7 +1437,7 @@ sub generate_payonelink {
my $cms_message_key = "email-payonelink"; my $cms_message_key = "email-payonelink";
if($ctpos->{c_id}){ if($ctpos->{c_id}){
print FILE "$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'"; print FILE "$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name|$varenv->{merchant_id}'";
system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'"); system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_payonelink' '$ctadr->{c_id}' '$ctpos->{c_id}' '' '$cms_message_key' '' '$app_name'");
} }

View file

@ -22,6 +22,8 @@ use Mod::Basework;
use Mod::Pricing; use Mod::Pricing;
use Mod::Shareework; use Mod::Shareework;
use Mod::APIsigclient; use Mod::APIsigclient;
use Mod::SMSTransport;
use Mod::MailTransport;
use Data::Dumper; use Data::Dumper;
my $cf = new Config; my $cf = new Config;
@ -31,6 +33,8 @@ my $bw = new Basework;
my $pri = new Pricing; my $pri = new Pricing;
my $shwo = new Shareework; my $shwo = new Shareework;
my $si = new APIsigclient; my $si = new APIsigclient;
my $smstrans = new SMSTransport;
my $mailtrans = new MailTransport;
sub new { sub new {
my $class = shift; my $class = shift;
@ -53,60 +57,89 @@ sub longterm_occupied {
my $self = shift; my $self = shift;
my $varenv = shift; my $varenv = shift;
my $dbh = ""; my $dbh = "";
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $log_stamp = strftime "%d.%m.%Y %H:%M:%S", localtime;
open(FILE,">>$dbt->{copri_conf}->{logdir}/longterm_occupied.log");
print FILE "\n*** $now_dt $varenv->{dbname} \n";
#operator hotline contact
my $pref_cc = {
table => "contentuser",
fetch => "one",
template_id => "197",
c_id => 1,
};
my $uadr = { c_id => 0 };
$uadr = $dbt->fetch_record($dbh,$pref_cc);
$uadr->{txt07} =~ s/\s//g;
my $search = { my $search = {
table => "contenttranspos", table => "contenttranspos",
int10 => 3, int10 => 3,
int34 => "null",#if not staff #int34 => "null",#if not staff TODO
start_time_interval => "(now() - interval '1 day')", start_time_interval => "(now() - interval '12 hours')",
}; };
my $update_pos = { my $update_pos = {
table => "contenttranspos", table => "contenttranspos",
mtime => "no_time",
}; };
my $dt1 = DateTime->now(time_zone => "Europe/Berlin"); my $dt1 = DateTime->now(time_zone => "Europe/Berlin");
my $cttpos = { c_id => 0 }; my $cttpos = { c_id => 0 };
$cttpos = $dbt->collect_transpos($dbh,$search,1); $cttpos = $dbt->collect_transpos($dbh,$search,0);
my $longterm_ctadr = {};
my $posting = {
78 => 'email',
36 => 'sms',
24 => 'email',
12 => 'email',
};
my $posting_email = $dbt->{copri_conf}->{message_rental}->{Email};
my $posting_sms = $dbt->{copri_conf}->{message_rental}->{SMS};
foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){ foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){
if($cttpos->{$pid}->{int10} == 3){ if($cttpos->{$pid}->{int10} == 3){
my $dt2 = ""; if(1==1){
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time}); print FILE "Fetched > 12 hour occupied rental with messaged int33=$cttpos->{$pid}->{int33} - pos_id:" . $cttpos->{$pid}->{c_id} . "\n";
if($dt2){
#foreach $posting {#TODO tests #Email
foreach my $h_id (sort { $a <=> $b } keys(%$posting)){ foreach my $h_id (sort { $a <=> $b } keys(%$posting_email)){
print "--> hour:$h_id\n"; print FILE "--> hour:$h_id\n";
my $dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time});
if($dt1 >= $dt2->add( hours => $h_id )){ if($dt1 >= $dt2->add( hours => $h_id )){
if($cttpos->{$pid}->{int33} != $h_id){ print FILE $dt1 . ">=" . $dt2->add( hours => $h_id ) . "\n";
$longterm_ctadr = { if(!$cttpos->{$pid}->{int33} || $cttpos->{$pid}->{int33} < $h_id){
hours => $h_id, print FILE "if(!$cttpos->{$pid}->{int33} || $cttpos->{$pid}->{int33} < $h_id)\n";
posting => $posting->{$h_id},
c_id => $cttpos->{$pid}->{ca_id}, print FILE "Sent message for > $h_id hour rental by $posting_email->{$h_id}\n";
pos_id => $cttpos->{$pid}->{c_id}, my $pricing = { total_price => 0 };
bike => $cttpos->{$pid}->{ct_name}, ($pricing,my $counting) = $pri->counting_rental($varenv,$cttpos->{$pid}) if($h_id == 72);
txt01 => $cttpos->{$pid}->{txt08}, $cttpos->{$pid}->{total_price} = $pricing->{total_price} if($pricing->{total_price});
txt07 => $cttpos->{$pid}->{phone}, $mailtrans->mail_hours_occupied($varenv,$h_id,$uadr,$cttpos->{$pid});
txt08 => $cttpos->{$pid}->{email}, my $message_log = $cttpos->{$pid}->{txt20} . "\n- $log_stamp $posting_email->{$h_id}";
txt11 => $cttpos->{$pid}->{lang}, $dbt->update_one($dbh,$update_pos,"int33=$h_id,txt20='$message_log'",$cttpos->{$pid}->{c_id});
}; }
print $dt1 . ">=" . $dt2->add( hours => $h_id ) . "\n" . Dumper($longterm_ctadr) . "\n"; }
$dbt->update_one($dbh,$update_pos,"int33=78",$cttpos->{$pid}->{c_id}); }
#SMS
foreach my $h_id (sort { $a <=> $b } keys(%$posting_sms)){
print FILE "--> hour:$h_id\n";
my $dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time});
if($dt1 >= $dt2->add( hours => $h_id )){
print FILE $dt1 . ">=" . $dt2->add( hours => $h_id ) . "\n";
if(!$cttpos->{$pid}->{int33} || $cttpos->{$pid}->{int33} < $h_id){
print FILE "if(!$cttpos->{$pid}->{int33} || $cttpos->{$pid}->{int33} < $h_id)\n";
print FILE "Sent message for > $h_id hour rental by $posting_sms->{$h_id}\n";
my $contact_hotline = "Hotline $uadr->{txt01} $uadr->{txt08}, $uadr->{txt07}";
$smstrans->sms_message($h_id,$contact_hotline,$cttpos->{$pid}->{ca_id},"",$cttpos->{$pid}->{ct_name});
my $message_log = $cttpos->{$pid}->{txt20} . "\n- $log_stamp $posting_sms->{$h_id}";
$dbt->update_one($dbh,$update_pos,"int33=$h_id,txt20='$message_log'",$cttpos->{$pid}->{c_id});
} }
} }
} }
} }
} }
} }
return $longterm_ctadr; close(FILE);
} return;
}#end longterm_occupied
#insert/save/delete DMS users #insert/save/delete DMS users
sub manage_dmsusers { sub manage_dmsusers {
@ -1162,10 +1195,14 @@ sub new_relation {
my $n_sort = 1; my $n_sort = 1;
my $type_id = 300101; my $type_id = 300101;
my $energy_id = 0; my $energy_id = 0;
my $battery_hidden = 0;
my $battery_accessible = 0;
$template_id = $R::template_id if(looks_like_number($R::template_id)); $template_id = $R::template_id if(looks_like_number($R::template_id));
$n_sort = $R::n_sort if(looks_like_number($R::n_sort)); $n_sort = $R::n_sort if(looks_like_number($R::n_sort));
$type_id = $R::type_id if(looks_like_number($R::type_id)); $type_id = $R::type_id if(looks_like_number($R::type_id));
$energy_id = $R::energy_id if(looks_like_number($R::energy_id)); $energy_id = $R::energy_id if(looks_like_number($R::energy_id));
$energy_id = $R::battery_hidden if(looks_like_number($R::battery_hidden));
$battery_accessible = $R::battery_accessible if(looks_like_number($R::battery_accessible));
my $insert = { my $insert = {
main_id => $new_main_id, main_id => $new_main_id,
@ -1176,6 +1213,8 @@ sub new_relation {
n_sort => $n_sort, n_sort => $n_sort,
type_id => $type_id, type_id => $type_id,
energy_id => $energy_id, energy_id => $energy_id,
battery_hidden => $battery_hidden,
battery_accessible => $battery_accessible,
owner => $owner, owner => $owner,
change => "now()", change => "now()",
}; };
@ -1275,7 +1314,7 @@ sub save_relation {
$valxx = "null" if(!$valxx && $valxx ne "0");#for empty $valxx = "null" if(!$valxx && $valxx ne "0");#for empty
$valxx = "0" if($valxx eq "0"); $valxx = "0" if($valxx eq "0");
$u_rows = $dbt->update_one($dbh,$update_node,"$_=$valxx") if($valxx =~ /^\d+$|null|0/); $u_rows = $dbt->update_one($dbh,$update_node,"$_=$valxx") if($valxx =~ /^\d+$|null|0/);
}elsif($_ =~ /type_id|energy_id|archive/ && $valxx){ }elsif($_ =~ /archive|type_id|energy_id|battery_/ && $valxx){
$u_rows = $dbt->update_one($dbh,$update_node,"$_=$valxx"); $u_rows = $dbt->update_one($dbh,$update_node,"$_=$valxx");
$valxx = "null" if(!$valxx || $valxx eq "null"); $valxx = "null" if(!$valxx || $valxx eq "null");
}elsif($_ =~ /fleed_/){ }elsif($_ =~ /fleed_/){

View file

@ -123,7 +123,7 @@ sub sms_ack_digest {
#varenv will be slurpt by syshost client #varenv will be slurpt by syshost client
sub sms_message { sub sms_message {
my $self = shift; my $self = shift;
my $todo = shift; my $todo = shift || "";
my $contact_hotline = shift || ""; my $contact_hotline = shift || "";
my $adr_id = shift || "";#phone by adr.c_id my $adr_id = shift || "";#phone by adr.c_id
my $sms_to = shift || "";#direct phone (send_alarm2hotline) my $sms_to = shift || "";#direct phone (send_alarm2hotline)
@ -162,26 +162,18 @@ sub sms_message {
$sms_to = $sms_tosub; $sms_to = $sms_tosub;
} }
#todo locking_progress #messanger_divers longterm_occupied (delete cms sms-24h)
if($todo eq "locking_progress"){ if($todo eq "36"){
#$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"; my $cms_message_key = $dbt->{copri_conf}->{message_rental}->{SMS}->{$todo};
$varenv{cms}->{'sms-locking-progress'}->{txt} =~ s/::bike::/$bike/; $varenv{cms}->{$cms_message_key}->{txt} =~ s/::bike::/$bike/;
$sms_message .= "$varenv{cms}->{'sms-locking-progress'}->{txt} $contact_hotline"; $varenv{cms}->{$cms_message_key}->{txt} =~ s/::hour::/$todo/;
$sms_message .= "$varenv{cms}->{$cms_message_key}->{txt} $contact_hotline";
} }
$varenv{cms}->{'sms-24h'}->{txt} =~ s/::bike::/$bike/; #todo locking_progress
#todo if > 24h rental if($todo eq "locking_progress"){
if($todo eq "24h_occupied"){ $varenv{cms}->{'sms-locking-progress'}->{txt} =~ s/::bike::/$bike/;
$varenv{cms}->{'sms-24h'}->{txt} =~ s/::hour::/24/; $sms_message .= "$varenv{cms}->{'sms-locking-progress'}->{txt} $contact_hotline";
$sms_message .= "$varenv{cms}->{'sms-24h'}->{txt} $contact_hotline";
}
if($todo eq "48h_occupied"){
$varenv{cms}->{'sms-24h'}->{txt} =~ s/::hour::/48/;
$sms_message .= "$varenv{cms}->{'sms-24h'}->{txt} $contact_hotline";
}
if($todo eq "72h_occupied"){
$varenv{cms}->{'sms-24h'}->{txt} =~ s/::hour::/72/;
$sms_message .= "$varenv{cms}->{'sms-24h'}->{txt} $contact_hotline";
} }
#todo send_alarm2hotline #todo send_alarm2hotline

View file

@ -535,35 +535,17 @@ EOF
print $q->Tr(),"\n"; print $q->Tr(),"\n";
print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms',-nowrap=>"1"},"$gesamt €"); print $q->td({-class=>'content1_cms',-nowrap=>"1"},"$gesamt €");
}elsif($key eq "txt24"){ }elsif($key =~ /txt20|txt24|txt25|txt29/ && $size eq "readonly"){
if($cttpos->{$key} && $users_dms->{int03} >= 1){ if($cttpos->{$key} && $users_dms->{int03} >= 1){
$cttpos->{$key} = $q->unescapeHTML("$cttpos->{$key}"); $cttpos->{$key} = $q->unescapeHTML("$cttpos->{$key}");
$cttpos->{$key} = $lb->newline($cttpos->{$key},"",""); $cttpos->{$key} = $lb->newline($cttpos->{$key},"","");
print $q->Tr(),"\n"; print $q->Tr(),"\n";
print $q->td({-class=>'content1_cms',-colspan=>2},"appapi-log<br />$cttpos->{$key}"),"\n"; print $q->td({-class=>'content1_cms',-colspan=>2},"<span style='font-style:italic;'>$des</span> $cttpos->{$key}"),"\n";
}
}elsif($key eq "txt25"){
if($cttpos->{$key} && $users_dms->{int03} >= 1){
$cttpos->{$key} = $q->unescapeHTML("$cttpos->{$key}");
$cttpos->{$key} = $lb->newline($cttpos->{$key},"","");
print $q->Tr(),"\n";
print $q->td({-class=>'content1_cms',-colspan=>2},"sigapi-log<br />$cttpos->{$key}"),"\n";
}
}elsif($key eq "txt29"){
if($cttpos->{$key} && $users_dms->{int03} >= 1){
$cttpos->{$key} = $q->unescapeHTML("$cttpos->{$key}");
$cttpos->{$key} = $lb->newline($cttpos->{$key},"","");
print $q->Tr(),"\n";
print $q->td({-class=>'content1_cms',-colspan=>2},"response-log$cttpos->{$key}"),"\n";
} }
}elsif($key =~ /txt/){ }elsif($key =~ /txt/){
print $q->Tr(),"\n"; print $q->Tr(),"\n";
print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms'},$q->textfield(-class=>'etxt',-name=>"$key",-default=>"$cttpos->{$key}", -override=>'1',-size=>"$size",-maxlength=>100)),"\n"; print $q->td({-class=>'content1_cms'},$q->textfield(-class=>'etxt',-name=>"$key",-default=>"$cttpos->{$key}", -override=>'1',-size=>"$size",-maxlength=>100)),"\n";
}elsif($key =~ /int/){
print $q->Tr(),"\n";
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms',-nowrap=>"1"},"&nbsp;\n");
} }
#only if invoice isn't booked #only if invoice isn't booked
if($key eq "txt23" && $cttpos->{ca_id} && $cttpos->{ct_id} && !$cttpos->{state}){ if($key eq "txt23" && $cttpos->{ca_id} && $cttpos->{ct_id} && !$cttpos->{state}){

View file

@ -29,14 +29,12 @@ use DateTime::Format::Pg;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
use Lib::Config; use Lib::Config;
use Mod::DBtank; use Mod::DBtank;
use Mod::Prelib;
use Mod::MailTransport; use Mod::MailTransport;
use Data::Dumper; use Data::Dumper;
my $cf = new Config; my $cf = new Config;
my %varenv = $cf->envonline(); my %varenv = $cf->envonline();
my $dbt = new DBtank; my $dbt = new DBtank;
my $pl = new Prelib;
my $mailtrans = new MailTransport; 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;
@ -212,7 +210,7 @@ sub send_invoice {
} }
my $ctadr_invoice = $ctt;#take adr from invoice for account-less mailing my $ctadr_invoice = $ctt;#take adr from invoice for account-less mailing
$sendref = prepare_content($sendref,$ctadr_invoice,$uadr,$ctt,$varenv{cms}->{$cms_message_key}->{txt},$with_pdf); $sendref = $mailtrans->prepare_content(\%varenv,$sendref,$ctadr_invoice,$uadr,$ctt,$varenv{cms}->{$cms_message_key}->{txt},$with_pdf);
my $updatectt = { my $updatectt = {
table => "contenttrans", table => "contenttrans",
@ -256,7 +254,7 @@ sub send_payonelink {
my $record_pos = { c_id => 0 }; my $record_pos = { c_id => 0 };
$record_pos = $dbt->fetch_tablerecord($dbh_primary,$pref_pos) if($ctpos_id); $record_pos = $dbt->fetch_tablerecord($dbh_primary,$pref_pos) if($ctpos_id);
$sendref = prepare_content($sendref,$ctadr,$uadr,$record_pos,$varenv{cms}->{$cms_message_key}->{txt},'',$app_name); $sendref = $mailtrans->prepare_content(\%varenv,$sendref,$ctadr,$uadr,$record_pos,$varenv{cms}->{$cms_message_key}->{txt},'',$app_name);
my $update_pos = { my $update_pos = {
table => "contenttranspos", table => "contenttranspos",
@ -296,7 +294,7 @@ sub send_emailack {
$ctadr->{txt34} = ""; $ctadr->{txt34} = "";
} }
$sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); $sendref = $mailtrans->prepare_content(\%varenv,$sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt});
return $sendref; return $sendref;
}#end send_emailack }#end send_emailack
@ -328,7 +326,7 @@ sub send_password {
$ctadr->{txt04} = ""; $ctadr->{txt04} = "";
} }
$sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); $sendref = $mailtrans->prepare_content(\%varenv,$sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt});
return $sendref; return $sendref;
}#end send_password }#end send_password
@ -353,7 +351,7 @@ sub send_cpupdate_message {
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $lang }); $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $lang });
my $cms_message_key = "email-cpupdate-message"; my $cms_message_key = "email-cpupdate-message";
$cms_message_key = "email-proactive-cpupdate-message" if($todo eq "send_proactive_cpupdate_message"); $cms_message_key = "email-proactive-cpupdate-message" if($todo eq "send_proactive_cpupdate_message");
$sendref = prepare_content($sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt}); $sendref = $mailtrans->prepare_content(\%varenv,$sendref,$ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt});
return $sendref; return $sendref;
}#end send_cpupdate_message }#end send_cpupdate_message
@ -441,7 +439,7 @@ sub send_occupied2hotline {
}; };
my $cttpos = { c_id => 0 }; my $cttpos = { c_id => 0 };
$cttpos = $dbt->collect_transpos($dbh,$search,1); $cttpos = $dbt->collect_transpos($dbh,$search,0);
my $bike = ""; my $bike = "";
foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){ foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){
@ -535,116 +533,6 @@ EOF
return; return;
}#end send_invoice_onwork }#end send_invoice_onwork
#greater 12h_mailmessage
#TODO test ....
sub email_longterm_occupied {
my $dbh = shift;
my $oprefix = shift || "";
my $sendref = shift;
#operator contact
my $pref_ctu = {
table => "contentuser",
fetch => "one",
c_id => "1",
};
my $uadr = { c_id => 0 };
$uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
my $longterm_ctadr = {};
$longterm_ctadr = $pl->longterm_occupied(\%varenv);
my $lang = $longterm_ctadr->{txt11} || "de";
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $lang });
my $cms_message_key = "";
$cms_message_key = "email-" . $longterm_ctadr->{hours} . "h-occupied" if($longterm_ctadr->{hours});
if($longterm_ctadr->{posting} eq "email" && $varenv{cms}->{$cms_message_key}->{txt}){
$sendref = prepare_content($sendref,$longterm_ctadr,$uadr,"",$varenv{cms}->{$cms_message_key}->{txt});
}
return $sendref;
}#end email_longterm_occupied
#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 $with_pdf = shift || "";
my $app_name = shift || "";
if(!$app_name && $dbt->{operator}->{$varenv{dbname}}->{app_name}){
$app_name = $dbt->{operator}->{$varenv{dbname}}->{app_name};
}else{
$app_name = "Mietrad App";
}
my $invoice_name = "";
my $invoice_nr = "";
my $total_sum = "";
my $sharee_ticket = "";
my $fibu_user = "";
my $prepaid_id = "";
my $payone_link = "";
if(ref($ctt) eq "HASH" && $ctt->{ct_name}){
$invoice_name = "$ctt->{txt00}-$varenv{dbname}-$ctt->{ct_name}.pdf";
$sendref->{attachment} = "$invoice_name" if($with_pdf);
$invoice_nr = "$varenv{dbname}-$ctt->{ct_name}";
$total_sum = "$ctt->{int01}";
$total_sum =~ s/\./,/;
$sharee_ticket = "[$invoice_nr]";
$fibu_user = "\n$ctt->{fibu_user}\n" if($ctt->{fibu_user});
$prepaid_id = $ctt->{ct_id} . "-" . $ctt->{c_id};
$payone_link = $ctt->{txt30};
}
my $subject = "TeilRad Mietradsystem";#default
$subject = $1 if($cms_prim =~ /--subject--(.*)--subject--/);
$cms_prim =~ s/--subject--$subject--subject--//;
$subject .= " $sharee_ticket" if($sharee_ticket && !$payone_link);
$cms_prim =~ s/\n//;
my $signature = <<EOF
--$fibu_user
$uadr->{txt01}
$uadr->{txt03}
$uadr->{txt06}
$uadr->{txt07}
$uadr->{txt08}
$uadr->{txt09}
$uadr->{txt10}
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}/g;
$sendref->{message} =~ s/::bike::/$ctadr->{bike}/g if($ctadr->{bike});
$sendref->{message} =~ s/::app_name::/$app_name/g;
$sendref->{message} =~ s/::invoice_nr::/\<b\>$invoice_nr\<\/b\>/g if($invoice_nr);
$sendref->{message} =~ s/::total_sum::/\<b\>$total_sum €\<\/b\>/g if($total_sum);
$sendref->{message} =~ s/::invoice_name::/$invoice_name/g if($invoice_name);
$sendref->{message} =~ s/::txid::/$ctt->{txt16}/;
$sendref->{message} =~ s/::email_temppassword::/\<b\>$ctadr->{txt04}\<\/b\>/g;
$sendref->{message} =~ s/::email_ack_digest::/\<b\>$ctadr->{txt34}\<\/b\>/g;#send_emailack
$sendref->{message} =~ s/::prepaid_id::/\<b\>$prepaid_id\<\/b\>/g;
$sendref->{message} =~ s/::payone_link::/\<b\><a href='$payone_link'>$payone_link<\/a>\<\/b\>/g;
$sendref->{message} =~ s/::signature::/$signature/;
$sendref->{message} =~ s/\n/\<br \/\>/g;
return $sendref;
}#end prepare_content
#sending mail job #sending mail job
sub sendmailjob { sub sendmailjob {

View file

@ -0,0 +1,26 @@
#!/usr/bin/perl
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
#Examples
#./src/scripts/messanger_divers shareedms-operator
use vars qw($syshost);
BEGIN {
$syshost = $ARGV[0] || die 'syshost not defined';
}
use lib "/var/www/copri-bike/$syshost/src";
use strict;
use warnings;
use Lib::Config;
use Mod::Prelib;
my $cf = new Config;
my %varenv = $cf->envonline();
my $pl = new Prelib;
my $longterm_ctadr = $pl->longterm_occupied(\%varenv);

View file

@ -53,9 +53,10 @@ my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix} || "";
my $record_cc = { c_id => 0 }; my $record_cc = { c_id => 0 };
$record_cc = $dbt->fetch_record($dbh,$pref_cc); $record_cc = $dbt->fetch_record($dbh,$pref_cc);
my $contact_hotline = ""; my $contact_hotline = "";
$record_cc->{txt07} =~ s/\s//g; $record_cc->{txt07} =~ s/[\s\-\/]//g;
$contact_hotline = "Hotline $record_cc->{txt01} $record_cc->{txt08}, $record_cc->{txt07}"; $contact_hotline = "Hotline $record_cc->{txt01} $record_cc->{txt08}, $record_cc->{txt07}";
#2024-02-22 substitued by messanger_divers longterm_occupied
#SMS message if 24h,48h,72h occupied #SMS message if 24h,48h,72h occupied
if($todo eq "24h_occupied"){ if($todo eq "24h_occupied"){
#select booking pos if state=occupied and start_time > 24h #select booking pos if state=occupied and start_time > 24h

View file

@ -69,7 +69,7 @@ sub tpl(){
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total}); $prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
$prepaidhash->{prepaid_total} =~ s/\./,/; $prepaidhash->{prepaid_total} =~ s/\./,/;
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/\n/<br \/>/g; $varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/\n/<br \/>/g;
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::prepaid_total::/<b>$prepaidhash->{prepaid_total}<\/b>/g; $varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::prepaid_total::/<b>$prepaidhash->{prepaid_total}<\/b>/g;
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::app_name::/<b>$dbt->{merchant_ids}->{$varenv->{merchant_id}}->{app_name}<\/b>/g; $varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::app_name::/<b>$dbt->{merchant_ids}->{$varenv->{merchant_id}}->{app_name}<\/b>/g;
$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::prepaid_id::/<b>$prepaidhash->{prepaid_id}<\/b>/g; $varenv->{cms}->{'iframe-prepaid-prolog'}->{txt} =~ s/::prepaid_id::/<b>$prepaidhash->{prepaid_id}<\/b>/g;
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt}"),"\n"; print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-prepaid-prolog'}->{txt}"),"\n";
@ -92,7 +92,7 @@ sub tpl(){
}else{ }else{
my $label_des="$varenv->{cms}->{'iframe-prepaid-input'}->{txt}"; my $label_des="$varenv->{cms}->{'iframe-prepaid-input'}->{txt}";
print $q->label({-for=>"prepaid_amount", -style=>'padding-top:1.5em;'},"$label_des"),"\n"; print $q->label({-for=>"prepaid_amount", -style=>'padding-top:1.5em;'},"$label_des"),"\n";
print "<input id='prepaid_amount' type='text' class='form-control' name='prepaid_amount' override=1 value='0 ' $required />\n"; print "<input id='prepaid_amount' type='text' class='form-control' name='prepaid_amount' override=1 value='0 EUR' $required />\n";
print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='generate_payonelink' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next-prepaid'}->{txt}</button>"),"\n"; print $q->div({-style=>'margin-top:1em;text-align:center;'},"<button type='submit' name='sharee_edit' value='generate_payonelink' class='btn btn-primary btn-lg btn-block' style='border:1px solid #$bgcolor1;background-color:#$bgcolor1;'>$varenv->{cms}->{'iframe-next-prepaid'}->{txt}</button>"),"\n";
} }

View file

@ -202,7 +202,7 @@ sub tpl {
$prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total}); $prepaidhash->{prepaid_total} = sprintf('%.2f',$prepaidhash->{prepaid_total});
$prepaidhash->{prepaid_total} =~ s/\./,/; $prepaidhash->{prepaid_total} =~ s/\./,/;
$varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/\n/<br \/>/g; $varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/\n/<br \/>/g;
$varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/::prepaid_total::/<b>$prepaidhash->{prepaid_total}<\/b>/g; $varenv->{cms}->{'iframe-prepaid-sum'}->{txt} =~ s/::prepaid_total::/<b>$prepaidhash->{prepaid_total}<\/b>/g;
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-prepaid-sum'}->{txt}"),"\n"; print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-prepaid-sum'}->{txt}"),"\n";
} }
print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-invoice-note'}->{txt}"),"\n"; print $q->div({-class=>'content2'}, "$varenv->{cms}->{'iframe-invoice-note'}->{txt}"),"\n";

View file

@ -6,6 +6,7 @@ package Mlogic;
# #
use strict; use strict;
use warnings; use warnings;
use POSIX;
use CGI::Carp qw(fatalsToBrowser); use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard'; use CGI ':standard';
use Config::General; use Config::General;
@ -14,7 +15,8 @@ use Mod::Basework;
use Mod::Shareework; use Mod::Shareework;
use Mod::Libenz; use Mod::Libenz;
use Mod::DBtank; use Mod::DBtank;
use POSIX; use Mod::Modalbox;
use Mod::Modalbox3;
use Data::Dumper; use Data::Dumper;
my $bw = new Basework; my $bw = new Basework;