From 5cfcdb82f73040d377bb16b126f28f7c2efef524 Mon Sep 17 00:00:00 2001 From: ragu Date: Fri, 30 Dec 2022 19:51:45 +0100 Subject: [PATCH] mulitple task and battery management --- copri4/main/src/Mod/APIfunc.pm | 83 +++++++++++++------ copri4/main/src/Tpl/Liste3.pm | 11 +-- copri4/main/src/Tpl/SubListe.pm | 2 +- copri4/shareeapp-operator/src/Lib/Mlogic.pm | 4 +- .../src/Tpl/PayoneCCclient.pm | 2 +- 5 files changed, 69 insertions(+), 33 deletions(-) diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index c8c2204..30306da 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -312,9 +312,9 @@ sub service_select { $pref->{template_id} = "$node_template->{template_id}"; } - if(looks_like_number($q->param('service_id'))){ + if(looks_like_number($q->param('service_id')) && $q->param('request') ne "service_done"){ $pref->{c_id} = "=::" . $q->escapeHTML($q->param('service_id')); - }elsif(looks_like_number($service_id)){ + }elsif(looks_like_number($service_id) && $q->param('request') ne "service_done"){ $pref->{c_id} = "=::" . $service_id; }elsif(looks_like_number($bike)){ $pref->{barcode} = "=::" . $q->escapeHTML($bike); @@ -743,12 +743,10 @@ sub service_work { my $op_return = {}; foreach my $cid (sort { $article_all->{$a}->{barcode} <=> $article_all->{$b}->{barcode} } keys(%$article_all)){ my $i=0; + my $j=0; my $article = $article_all->{$cid}->{barcode}; my $tpl_keyseen = ""; - #breaks JSON hash. don't do it - #$return->{$bike}->{uri_operator} = "$varenv{wwwhost}"; - foreach my $id (sort { $pos_record->{$a}->{mtime} cmp $pos_record->{$b}->{mtime} } keys (%$pos_record)){ $i++; @@ -756,8 +754,6 @@ sub service_work { $article = $article_all->{$cid}->{barcode} if($article_all->{$cid}->{template_id} && $article_all->{$cid}->{template_id} == 205);# bike template_id $article = $article_all->{$cid}->{int04} if($article_all->{$cid}->{template_id} && $article_all->{$cid}->{template_id} == 225);# station template_id - #breaks JSON hash. don't do it - #$return->{$article}->{template_id} = "$pos_record->{$id}->{template_id}"; if(1==1){ if($pos_record->{$id}->{template_id} && $template_group->{$pos_record->{$id}->{template_id}}){ #$bw->log("$article --> service_work template on id: $id used:",$template_group->{$pos_record->{$id}->{template_id}}->{tpl_id},""); @@ -776,16 +772,16 @@ sub service_work { my $erledigt = 0; $erledigt = 1 if(!$history && $pos_record->{$id}->{txt01} && $pos_record->{$id}->{txt01} !~ /::erledigt::/); $erledigt = 1 if($history && $pos_record->{$id}->{txt01} && $pos_record->{$id}->{txt01} =~ /::erledigt::/); - if((($key =~ /int/ && looks_like_number($pos_record->{$id}->{$key})) || ($key eq "txt01" && $pos_record->{$id}->{$key} && $pos_record->{$id}->{$key} ne "NaN" && $erledigt))){ + + #service integer collect + if($key =~ /int/ && looks_like_number($pos_record->{$id}->{$key})){ $tpl_keyseen .= "$key|"; - #$bw->log("$pos_record->{$id}->{barcode} --> if((($key =~ /int/ && looks_like_number($pos_record->{$id}->{$key})) || ($key eq \"txt01\" && $pos_record->{$id}->{$key} && $pos_record->{$id}->{$key} ne \"NaN\"))){",$tpl_keyseen,""); my $u_name = $users_map->{$pos_record->{$id}->{owner}}->{txt01} || $channel_map->{$pos_record->{$id}->{owner}} || $pos_record->{$id}->{owner}; my $dt2 = DateTime::Format::Pg->parse_datetime($pos_record->{$id}->{mtime}); my $time_over = "0"; if(looks_like_number($interval) && $interval > 0){ my $dt2_over = $dt2->add( days => $interval ); - #$bw->log("service-interval: $interval | $dt1 > $dt2_over (mtime: $pos_record->{$id}->{mtime})",$key,""); $time_over = "1" if($dt1 > $dt2_over); } @@ -802,13 +798,45 @@ sub service_work { $return->{$article}->{$key_change}->{interval} = "$interval"; $return->{$article}->{$key_change}->{time_over} = "$time_over"; $return->{$article}->{$key_change}->{service_type} = "$service_type"; - $return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}" if($key =~ /int/); - #multiple entries breaks Aufgaben management and saving - #$return->{$article}->{$key_change}->{work_val} .= "$pos_record->{$id}->{$key}\n" if($key =~ /txt/); - $return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}\n" if($key =~ /txt/); + $return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}"; $return->{$article}->{$key_change}->{mtime} = "$pos_record->{$id}->{mtime}"; $return->{$article}->{$key_change}->{user_name} = "$u_name"; $return->{$article}->{$key_change}->{owner} = "$pos_record->{$id}->{owner}"; + + #servive multi todo collect + }elsif($key eq "txt01" && $pos_record->{$id}->{$key} && $pos_record->{$id}->{$key} ne "NaN" && $erledigt){ + $j++; + $tpl_keyseen .= "$key|"; + + my $u_name = $users_map->{$pos_record->{$id}->{owner}}->{txt01} || $channel_map->{$pos_record->{$id}->{owner}} || $pos_record->{$id}->{owner}; + my $dt2 = DateTime::Format::Pg->parse_datetime($pos_record->{$id}->{mtime}); + my $time_over = "0"; + if(looks_like_number($interval) && $interval > 0){ + my $dt2_over = $dt2->add( days => $interval ); + $time_over = "1" if($dt1 > $dt2_over); + } + + my $key_change = $key; + if($history && $history > 0){ + my $dtstamp = $pos_record->{$id}->{mtime}; + $dtstamp = $dt2->epoch(); + $key_change .= "_" . $dtstamp; + }elsif($j > 1){ + #appending counter on multiple todos + $key_change .= "_" . $j; + } + + $return->{$article}->{$key_change}->{service_id} = "$pos_record->{$id}->{c_id}"; + $return->{$article}->{$key_change}->{work_id} = "$key"; + $return->{$article}->{$key_change}->{work_name} = "$val"; + $return->{$article}->{$key_change}->{interval} = "$interval"; + $return->{$article}->{$key_change}->{time_over} = "$time_over"; + $return->{$article}->{$key_change}->{service_type} = "$service_type"; + $return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}"; + $return->{$article}->{$key_change}->{mtime} = "$pos_record->{$id}->{mtime}"; + $return->{$article}->{$key_change}->{user_name} = "$u_name"; + $return->{$article}->{$key_change}->{owner} = "$pos_record->{$id}->{owner}"; + } } } @@ -1905,15 +1933,15 @@ sub bikes_available(){ $return->{$id}->{bike_type}->{category} = "cargo"; $return->{$id}->{bike_type}->{wheels} = "2"; $return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i); - if($record->{$id}->{txt01} =~ /E-/i){ + if($record->{$id}->{energy_id} || $record->{$id}->{txt01} =~ /E-/i){ $return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy"; my $max_bars = 5; my $current_bars = 0; - my $charge_view_hidden = 1;#1=hide charge view - $charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); + my $charge_view_hidden = 0;#1=hide charge view + #$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); my $backend_accessible = 1; - #$backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user - $backend_accessible = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/);#for asking user + $backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user + #$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_current_bars} = "$current_bars"; $return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0"; @@ -1940,6 +1968,9 @@ sub bikes_available(){ }elsif($record->{$id}->{int11} eq "3"){ $return->{$id}->{system} = "sigo"; } + #2022-12-29 smartlock_type + $return->{$id}->{smartlock_type}->{engine}->{manufacturer} = "$dbt->{copri_conf}->{lock_system}->{$record->{$id}->{int11}}"; + $return->{$id}->{smartlock_type}->{battery}->{charge_current_percent} = "$record->{$id}->{int14}"; if(ref($tariff_content) eq "HASH"){ foreach my $tid (sort { $tariff_content->{$a}->{barcode} <=> $tariff_content->{$b}->{barcode} } keys (%$tariff_content)){ @@ -2082,15 +2113,15 @@ sub bikes_all(){ $return->{$id}->{bike_type}->{category} = "cargo"; $return->{$id}->{bike_type}->{wheels} = "2"; $return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i); - if($record->{$id}->{txt01} =~ /E-/i){ + if($record->{$id}->{energy_id} || $record->{$id}->{txt01} =~ /E-/i){ $return->{$id}->{bike_type}->{engine}->{manufacturer} = "dummy"; my $max_bars = 5; my $current_bars = 0; - my $charge_view_hidden = 1;#1=hide charge view - $charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); + my $charge_view_hidden = 0;#1=hide charge view + #$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); my $backend_accessible = 1;#1=battery charge from backend, 0=asking user - #$backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user - $backend_accessible = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/);#for asking user + $backend_accessible = 0 if($record->{$id}->{int11} eq "2");#for asking user + #$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_current_bars} = "$current_bars"; $return->{$id}->{bike_type}->{battery}->{charge_current_percent} = "0"; @@ -2117,6 +2148,10 @@ sub bikes_all(){ }elsif($record->{$id}->{int11} eq "3"){ $return->{$id}->{system} = "sigo"; } + #2022-12-29 smartlock_type + $return->{$id}->{smartlock_type}->{engine}->{manufacturer} = "$dbt->{copri_conf}->{lock_system}->{$record->{$id}->{int11}}"; + $return->{$id}->{smartlock_type}->{battery}->{charge_current_percent} = "$record->{$id}->{int14}"; + $op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id}; } } diff --git a/copri4/main/src/Tpl/Liste3.pm b/copri4/main/src/Tpl/Liste3.pm index 8fb0845..5fc6248 100755 --- a/copri4/main/src/Tpl/Liste3.pm +++ b/copri4/main/src/Tpl/Liste3.pm @@ -130,13 +130,14 @@ sub tpl(){ foreach my $key (keys %$cttpos1){ $cttpos_trans->{"trans_" . $key} = $cttpos1->{$key}; } - my $cttpos2 = $db->collect_postime("contenttheftpos","$search_startdt","$search_enddt","$start_date_time","$end_date_time"); - foreach my $key (keys %$cttpos2){ - $cttpos_theft->{"theft_" . $key} = $cttpos2->{$key}; - } + #my $cttpos2 = $db->collect_postime("contenttheftpos","$search_startdt","$search_enddt","$start_date_time","$end_date_time"); + #foreach my $key (keys %$cttpos2){ + # $cttpos_theft->{"theft_" . $key} = $cttpos2->{$key}; + #} } - $cttpos = { %$cttpos_trans, %$cttpos_theft }; + #$cttpos = { %$cttpos_trans, %$cttpos_theft }; + $cttpos = { %$cttpos_trans }; my $table = $node_meta->{ct_table} || ""; diff --git a/copri4/main/src/Tpl/SubListe.pm b/copri4/main/src/Tpl/SubListe.pm index 14444a9..f99a526 100755 --- a/copri4/main/src/Tpl/SubListe.pm +++ b/copri4/main/src/Tpl/SubListe.pm @@ -134,7 +134,7 @@ sub tpl(){ $searchref->{template_id_pos} = "$node_meta->{tpl_id}"; $tpl_ids = "205"; $tpl_ids = "225" if($node_meta->{tpl_id} == 499); - $node_meta->{tpl_order} .= ",txt10=Redistribution" if($node_meta->{tpl_id} != 499); + $node_meta->{tpl_order} .= ",int04=Station on insert,txt10=Redistribution" if($node_meta->{tpl_id} != 499); } elsif($node_meta->{tpl_id} > 600 && $node_meta->{tpl_id} < 700){ $table = "contentadr"; diff --git a/copri4/shareeapp-operator/src/Lib/Mlogic.pm b/copri4/shareeapp-operator/src/Lib/Mlogic.pm index 0fca484..8994e37 100755 --- a/copri4/shareeapp-operator/src/Lib/Mlogic.pm +++ b/copri4/shareeapp-operator/src/Lib/Mlogic.pm @@ -44,8 +44,8 @@ sub tpl(){ #my $api_test = "sharee_fr01"; my $bike="FR1538"; #my $api_test = "sharee_fr01"; my $bike="FR1005";#E-Lastenrad (bike_group=300101, bike_node=300102) - #my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test - my $api_test = "sharee_kn"; my $bike="KN1011"; + my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test + #my $api_test = "sharee_kn"; my $bike="KN1011"; #my $api_test = "sharee_wue"; my $bike="WUE5525"; #my $api_test = "sharee_sx"; my $bike="S3X1001"; #my $api_test = "sharee_ren"; my $bike="REN2"; diff --git a/copri4/shareeapp-operator/src/Tpl/PayoneCCclient.pm b/copri4/shareeapp-operator/src/Tpl/PayoneCCclient.pm index 8954467..1bcbec2 100755 --- a/copri4/shareeapp-operator/src/Tpl/PayoneCCclient.pm +++ b/copri4/shareeapp-operator/src/Tpl/PayoneCCclient.pm @@ -49,7 +49,7 @@ sub tpl(){ print $q->div({-class=>'content2'},"Kreditkartendaten werden von uns nicht gespeichert sondern direkt an unseren Zahlungsdienstleister Payone übermittelt. Deshalb sehen Sie hier nur leere Eingabefelder."),"\n"; #print $q->div({-class=>'content2'}, "Zur Validierung Ihrer Zahlungsdaten wird eine 1,- € Testbuchung vorgenommen. Wir werden nach erfolgreicher Abbuchung den Betrag als Mietgutschrift in Ihrem Account hinterlegen."),"\n"; if($users_sharee->{int03} && $users_sharee->{int03} == 2 && $users_sharee->{txt28} && $users_sharee->{txt28} =~ /\w/){ - print $q->div({-class=>'content2', -style=>'color:#c83434;'},"Ihre Zahlungsdaten konnten nicht erfolgreich validiert werden. Bitte überprüfen Sie Ihre Eingaben."),"\n"; + #print $q->div({-class=>'content2', -style=>'color:#c83434;'},"Ihre Zahlungsdaten konnten nicht erfolgreich validiert werden. Bitte überprüfen Sie Ihre Eingaben."),"\n"; } my $ccerror="";