mulitple task and battery management

This commit is contained in:
ragu 2022-12-30 19:51:45 +01:00
parent 6b576460b2
commit 5cfcdb82f7
5 changed files with 69 additions and 33 deletions

View file

@ -312,9 +312,9 @@ sub service_select {
$pref->{template_id} = "$node_template->{template_id}"; $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')); $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; $pref->{c_id} = "=::" . $service_id;
}elsif(looks_like_number($bike)){ }elsif(looks_like_number($bike)){
$pref->{barcode} = "=::" . $q->escapeHTML($bike); $pref->{barcode} = "=::" . $q->escapeHTML($bike);
@ -743,12 +743,10 @@ sub service_work {
my $op_return = {}; my $op_return = {};
foreach my $cid (sort { $article_all->{$a}->{barcode} <=> $article_all->{$b}->{barcode} } keys(%$article_all)){ foreach my $cid (sort { $article_all->{$a}->{barcode} <=> $article_all->{$b}->{barcode} } keys(%$article_all)){
my $i=0; my $i=0;
my $j=0;
my $article = $article_all->{$cid}->{barcode}; my $article = $article_all->{$cid}->{barcode};
my $tpl_keyseen = ""; 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)){ foreach my $id (sort { $pos_record->{$a}->{mtime} cmp $pos_record->{$b}->{mtime} } keys (%$pos_record)){
$i++; $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}->{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 $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(1==1){
if($pos_record->{$id}->{template_id} && $template_group->{$pos_record->{$id}->{template_id}}){ 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},""); #$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; 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::/);
$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|"; $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 $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 $dt2 = DateTime::Format::Pg->parse_datetime($pos_record->{$id}->{mtime});
my $time_over = "0"; my $time_over = "0";
if(looks_like_number($interval) && $interval > 0){ if(looks_like_number($interval) && $interval > 0){
my $dt2_over = $dt2->add( days => $interval ); 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); $time_over = "1" if($dt1 > $dt2_over);
} }
@ -802,13 +798,45 @@ sub service_work {
$return->{$article}->{$key_change}->{interval} = "$interval"; $return->{$article}->{$key_change}->{interval} = "$interval";
$return->{$article}->{$key_change}->{time_over} = "$time_over"; $return->{$article}->{$key_change}->{time_over} = "$time_over";
$return->{$article}->{$key_change}->{service_type} = "$service_type"; $return->{$article}->{$key_change}->{service_type} = "$service_type";
$return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}" if($key =~ /int/); $return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}";
#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}->{mtime} = "$pos_record->{$id}->{mtime}"; $return->{$article}->{$key_change}->{mtime} = "$pos_record->{$id}->{mtime}";
$return->{$article}->{$key_change}->{user_name} = "$u_name"; $return->{$article}->{$key_change}->{user_name} = "$u_name";
$return->{$article}->{$key_change}->{owner} = "$pos_record->{$id}->{owner}"; $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}->{category} = "cargo";
$return->{$id}->{bike_type}->{wheels} = "2"; $return->{$id}->{bike_type}->{wheels} = "2";
$return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i); $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"; $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 = 1;#1=hide charge view my $charge_view_hidden = 0;#1=hide charge view
$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); #$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/);
my $backend_accessible = 1; my $backend_accessible = 1;
#$backend_accessible = 0 if($record->{$id}->{int11} eq "2");#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 #$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";
@ -1940,6 +1968,9 @@ sub bikes_available(){
}elsif($record->{$id}->{int11} eq "3"){ }elsif($record->{$id}->{int11} eq "3"){
$return->{$id}->{system} = "sigo"; $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"){ if(ref($tariff_content) eq "HASH"){
foreach my $tid (sort { $tariff_content->{$a}->{barcode} <=> $tariff_content->{$b}->{barcode} } keys (%$tariff_content)){ 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}->{category} = "cargo";
$return->{$id}->{bike_type}->{wheels} = "2"; $return->{$id}->{bike_type}->{wheels} = "2";
$return->{$id}->{bike_type}->{wheels} = "3" if($record->{$id}->{txt01} =~ /drei|trike/i); $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"; $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 = 1;#1=hide charge view my $charge_view_hidden = 0;#1=hide charge view
$charge_view_hidden = 0 if($dbt->{operator}->{$varenv->{dbname}}->{oprefix} =~ /BVB|FR|KN/); #$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 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($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($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";
@ -2117,6 +2148,10 @@ sub bikes_all(){
}elsif($record->{$id}->{int11} eq "3"){ }elsif($record->{$id}->{int11} eq "3"){
$return->{$id}->{system} = "sigo"; $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}; $op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};
} }
} }

View file

@ -130,13 +130,14 @@ sub tpl(){
foreach my $key (keys %$cttpos1){ foreach my $key (keys %$cttpos1){
$cttpos_trans->{"trans_" . $key} = $cttpos1->{$key}; $cttpos_trans->{"trans_" . $key} = $cttpos1->{$key};
} }
my $cttpos2 = $db->collect_postime("contenttheftpos","$search_startdt","$search_enddt","$start_date_time","$end_date_time"); #my $cttpos2 = $db->collect_postime("contenttheftpos","$search_startdt","$search_enddt","$start_date_time","$end_date_time");
foreach my $key (keys %$cttpos2){ #foreach my $key (keys %$cttpos2){
$cttpos_theft->{"theft_" . $key} = $cttpos2->{$key}; # $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} || ""; my $table = $node_meta->{ct_table} || "";

View file

@ -134,7 +134,7 @@ sub tpl(){
$searchref->{template_id_pos} = "$node_meta->{tpl_id}"; $searchref->{template_id_pos} = "$node_meta->{tpl_id}";
$tpl_ids = "205"; $tpl_ids = "205";
$tpl_ids = "225" if($node_meta->{tpl_id} == 499); $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){ elsif($node_meta->{tpl_id} > 600 && $node_meta->{tpl_id} < 700){
$table = "contentadr"; $table = "contentadr";

View file

@ -44,8 +44,8 @@ sub tpl(){
#my $api_test = "sharee_fr01"; my $bike="FR1538"; #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="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_fr01"; my $bike="FR4781";#Tracking and BVB test
my $api_test = "sharee_kn"; my $bike="KN1011"; #my $api_test = "sharee_kn"; my $bike="KN1011";
#my $api_test = "sharee_wue"; my $bike="WUE5525"; #my $api_test = "sharee_wue"; my $bike="WUE5525";
#my $api_test = "sharee_sx"; my $bike="S3X1001"; #my $api_test = "sharee_sx"; my $bike="S3X1001";
#my $api_test = "sharee_ren"; my $bike="REN2"; #my $api_test = "sharee_ren"; my $bike="REN2";

View file

@ -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'},"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"; #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/){ 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=""; my $ccerror="";