Extend operator dms-account management

This commit is contained in:
ragu 2024-02-12 16:43:31 +01:00
parent b2dce25de8
commit 6212b1aefb
18 changed files with 840 additions and 552 deletions

View file

@ -27,7 +27,7 @@ use Mod::DBtank;
use Mod::Callib;
use Mod::Basework;
use Mod::Pricing;
#use Mod::APIsigclient;#no!
use Mod::MailTransport;
use Data::Dumper;
use Sys::Hostname;
my $json = JSON->new->allow_nonref;
@ -37,7 +37,7 @@ my $dbt = new DBtank;
my $cal = new Callib;
my $bw = new Basework;
my $pri = new Pricing;
#my $si = new APIsigclient;
my $mailtrans = new MailTransport;
sub new {
my $class = shift;
@ -454,16 +454,18 @@ sub service_insert(){
my $insert_contentpos = {
table => "contentpos",
cc_id => $crecord_content->{c_id},
#int03 => $c_id, #yes, c_id from contentadrpos to make backlink
ct_name => $bike,
barcode => $crecord_content->{barcode},
int04 => $crecord_content->{int04},
owner => $owner,
template_id => $node_template_contentpos->{template_id},
mtime => "now()",
};
#$update->{int01} = 1 if($q->param('bike_broken'));#TODO. what should else be done if bike_broken
$insert_contentpos->{txt01} = $q->escapeHTML($q->param('message')) if($q->param('message'));
my $c_id_contentpos = $dbt->insert_contentoid($dbh,$insert_contentpos,"");
if($crecord_content->{fleed_email} && $crecord_content->{fleed_email} =~ /\w\@\w/){
$mailtrans->mail_feedback2garage($crecord_content,$insert_contentpos);
}
}
}
}
@ -727,11 +729,7 @@ sub service_work {
my $dt1 = DateTime->now;
my $return={};
my $mapref = {
int09 => 1,
};
#my $users_map = $dbt->users_map($dbh,$mapref);#get serviceAPP users
my $users_map = $dbt->users_map($dbh,"");#get all serviceAPP users (also without service key)
my $users_map = $dbt->users_map($dbh,{ int09 => 1 });
my $channel_map = $dbt->channel_map();
my @tpl_order = ();
@ -1577,7 +1575,7 @@ sub smartlock {
#only by system=Ilockit
if($record_pos->{int11} eq "2" && $q->param('voltage') && $q->param('voltage') =~ /(\d+)/){
$update_cc->{int14} = $1;
$self->service_automatic($q,"") if($1 <= 60);
$self->service_automatic($q,$varenv,"") if($1 <= 60);
}
my $update_pos = {
@ -1647,6 +1645,7 @@ sub smartlock {
sub service_automatic {
my $self = shift;
my $q = shift || "";
my $varenv = shift;
my $current_percent = shift || 0;
my $station_id = "";
@ -2681,10 +2680,10 @@ sub fetch_tariff(){
#shareetool user_tour
if($auth_operator->{c_id} && $merchant_id && $dbt->{merchant_ids}->{$merchant_id}->{id} && $dbt->{merchant_ids}->{$merchant_id}->{id} == 187){
my $users_serviceapp = $dbt->select_users($dbh,$auth_operator->{c_id},"and int09=1");
if($users_serviceapp->{int09} && $users_serviceapp->{txt07}){
$users_serviceapp->{txt07} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
@user_tour = ($users_serviceapp->{txt07});
@user_tour = split(/\s/,$users_serviceapp->{txt07}) if($users_serviceapp->{txt07} =~ /\s/);
if($users_serviceapp->{int09} && $users_serviceapp->{txt12}){
$users_serviceapp->{txt12} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
@user_tour = ($users_serviceapp->{txt12});
@user_tour = split(/\s/,$users_serviceapp->{txt12}) if($users_serviceapp->{txt12} =~ /\s/);
}
}#end user_tour
@ -2831,6 +2830,10 @@ sub fetch_bike_tariff {
elsif($tariff_content->{$id}->{int18} && $tariff_content->{$id}->{int18} == 2 && $tariff_content->{$id}->{int12} && $tariff_content->{$id}->{barcode}){
push(@txt30, "$tariff_content->{$id}->{barcode}");
}
#add private tarif for dmsuser
elsif($tariff_content->{$id}->{int18} && $tariff_content->{$id}->{int18} == 3 && $tariff_content->{$id}->{int12} && $tariff_content->{$id}->{barcode} && $auth->{int09}){
push(@txt30, "$tariff_content->{$id}->{barcode}");
}
}
}
$bw->log("booking_request NO user tariff defined, update user account to fallback default public or private or hidden",\@txt30,"");
@ -2982,7 +2985,7 @@ sub auth_verify(){
}elsif($auth_primary->{txt17}){
$operator_hash{$auth_primary->{txt17}} = 1;
}
$operator_hash{$varenv{dbname}} = 1 if($varenv{dbname} ne "sharee_lv");#LastenVelo dbname will be only set by xml
$operator_hash{$varenv{dbname}} = 1;
my @operator_array = keys %operator_hash;
#$bw->log("auth_verified update operator keys by array: @operator_array",\%operator_hash,"");
@ -3126,7 +3129,6 @@ sub auth_verify(){
$return->{user_tour} = $user_tour;
$return->{debuglevel} = "$record->{int11}" if($record->{int11});
$return->{Ilockit_admin} = "$record->{int19}" if($record->{int19});
$return->{response_text} = "Danke, die Anmeldebestätigung war erfolgreich.";
}
}else{
#$bw->log("auth_verified on operator anchor FAILS by dbname $varenv{dbname}, no authcookie, dump \$q",$q,"");