grouping flots

This commit is contained in:
ragu 2022-07-15 07:11:01 +02:00
parent b9af62e5fc
commit 036d4dcf50
10 changed files with 83 additions and 59 deletions

View file

@ -579,7 +579,7 @@ sub service_update(){
my $auth_op = $dbt->fetch_record($dbh_operator,$adref);
my $user_miniquest_count = $auth_op->{int23} || 0;
#if($user_miniquest_count <= 3){
if($user_miniquest_count <= 3){
$user_miniquest_count++;
my $update_op = {
table => "contentadr",
@ -587,7 +587,7 @@ sub service_update(){
atime => "now()",
};
my $rows = $dbt->update_record($dbh_operator,$update_op,$auth_op);
#}
}
}
}
@ -1972,7 +1972,7 @@ sub bikes_available(){
$return->{$id}->{rental_description}->{reserve_timerange} = "15";
$return->{$id}->{rental_description}->{reserve_timerange} = "30" if($record->{$id}->{int11} == 3);#sig timeout time
$return->{$id}->{rental_description}->{rental_info}->{1} = ["Tracking","Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"] if($record->{$id}->{int25});
$return->{$id}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 1843 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 38883));
#$return->{$id}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 1843 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 38883));
my $i = 0;
foreach my $td (sort keys (%$td_template)){
@ -2108,14 +2108,17 @@ sub stations_available(){
my $auth = shift || "";
my $record_pos = shift || {};
#2022-07-12, int12 changed to bike type_id
my $station_group = "";
$station_group = $record_pos->{int29} if(ref($record_pos) eq "HASH" && $record_pos->{int29});
my $aa_station = "";
#take start station from pos
$aa_station = $record_pos->{int06} if(ref($record_pos) eq "HASH" && $record_pos->{int06} && $record_pos->{int42});
#station_group and bike_group alias bike nodes.type_id
#my $station_group = "";
#$station_group = $record_pos->{int29} if(ref($record_pos) eq "HASH" && $record_pos->{int29});
#$bw->log("stations_available by station_group: $station_group",$record_pos,"");
#station_bike_node and bike_node alias bike nodes.main_id
my $station_bike_node = "";
$station_bike_node = $record_pos->{int21} if(ref($record_pos) eq "HASH" && $record_pos->{int21});
#take start station from pos
my $aa_station = "";
$aa_station = $record_pos->{int06} if(ref($record_pos) eq "HASH" && $record_pos->{int06} && $record_pos->{int42});
my $authed = 0;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
@ -2133,24 +2136,24 @@ sub stations_available(){
#group_id must have 6 numbers like 300103
my $pref_sql = "";
$pref_sql .= " and (";
foreach(@{$bike_group}){
foreach(@{$bike_node}){
#on rental end select only stations which are defined
#A-A rental
if($station_group && $_ =~ /(\d+)/ && $aa_station){
my $group_id = $1;
if($group_id == $station_group){
if($station_bike_node && $_ =~ /(\d+)/ && $aa_station){
my $node_id = $1;
if($node_id == $station_bike_node){
$pref_sql .= " ct.int04 = $aa_station OR";
}
#A-B rental
}elsif($station_group && $_ =~ /(\d+)/){
my $group_id = $1;
if($group_id == $station_group){
$pref_sql .= " ct.txt24 like '%$group_id%' OR";
}elsif($station_bike_node && $_ =~ /(\d+)/){
my $node_id = $1;
if($node_id == $station_bike_node){
$pref_sql .= " ct.txt24 like '%$node_id%' OR";
}
#without a rental
}elsif($_ =~ /(\d+)/){
my $group_id = $1;
$pref_sql .= " ct.txt24 like '%$group_id%' OR";
my $node_id = $1;
$pref_sql .= " ct.txt24 like '%$node_id%' OR";
}
}
$pref_sql =~ s/OR$//;
@ -2158,7 +2161,7 @@ sub stations_available(){
$pref_sql = "" if($pref_sql !~ /\d/);
my $record = {};
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
my $op_return = {};
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
@ -2171,11 +2174,11 @@ sub stations_available(){
#$return->{$id}->{description} = "$record->{$id}->{txt01}";
$return->{$id}->{description} = Encode::encode('utf-8', Encode::decode('iso-8859-1', $record->{$id}->{txt01}));
$return->{$id}->{state} = "$dbt->{copri_conf}->{bike_state}->{$record->{$id}->{int10}}";
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
$return->{$id}->{station_group} = "";
if($record->{$id}->{txt24}){
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
$record->{$id}->{txt24} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
my @station_group = split(/\s/,$record->{$id}->{txt24});
if($record->{$id}->{txt25}){
$record->{$id}->{txt25} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
my @station_group = split(/\s/,$record->{$id}->{txt25});
$return->{$id}->{station_group} = [@station_group];
}
@ -2242,7 +2245,7 @@ sub stations_all(){
my $pref_sql = "";
$pref_sql .= " and (";
foreach(@{$bike_group}){
foreach(@{$bike_node}){
if($_ =~ /(\d+)/){
$pref_sql .= " ct.txt24 like '%$1%' OR";
}
@ -2271,7 +2274,7 @@ sub stations_all(){
}
$pref_sql =~ s/OR$//;
$pref_sql .= ")";
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
}
}
@ -2319,10 +2322,10 @@ sub stations_all(){
$return->{$id}->{bike_soll} = "$bike_soll" || "0";
$return->{$id}->{bike_ist} = "$bikes_on_station->{$id}->{bike_ist}" || "0";
$return->{$id}->{station_group} = "";
if($record->{$id}->{txt24}){
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
$record->{$id}->{txt24} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
my @station_group = split(/\s/,$record->{$id}->{txt24});
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
if($record->{$id}->{txt25}){
$record->{$id}->{txt25} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
my @station_group = split(/\s/,$record->{$id}->{txt25});
$return->{$id}->{station_group} = [@station_group];
}
$op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};

View file

@ -149,7 +149,8 @@ sub sig_available {
$return2copri->{$station}->{int06} = $1 if($response_out->{$station}->{gps_radius} =~ /(\d+)/);
$return2copri->{$station}->{txt01} = "$response_out->{$station}->{description}";
$return2copri->{$station}->{txt06} = "$response_out->{$station}->{gps}->{latitude},$response_out->{$station}->{gps}->{longitude}";
$return2copri->{$station}->{txt24} = "300101";#type_id
$return2copri->{$station}->{txt24} = "300102";#node.main_id
$return2copri->{$station}->{txt25} = "300101";#node_type_id
while (my ($key, $value) = each %{ $dbt->{copri_conf}->{station_state} }) {
if($response_out->{$station}->{state} eq $value){
$return2copri->{$station}->{int10} = $key;
@ -217,7 +218,7 @@ sub sig_available {
$response_out->{$bike}->{rental_description}->{id} = "$tariff_content->{$tid}->{barcode}";
$response_out->{$bike}->{rental_description}->{reserve_timerange} = "30";
$response_out->{$bike}->{rental_description}->{rental_info}->{1} = ["Tracking","Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"];#TODO if($resp->{gps_tracker_id});
$response_out->{$bike}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($ctadr->{c_id} && ($ctadr->{c_id} == 1842 || $ctadr->{c_id} == 1843 || $ctadr->{c_id} == 5781 || $ctadr->{c_id} == 11765 || $ctadr->{c_id} == 38883));
#$response_out->{$bike}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($ctadr->{c_id} && ($ctadr->{c_id} == 1842 || $ctadr->{c_id} == 1843 || $ctadr->{c_id} == 5781 || $ctadr->{c_id} == 11765 || $ctadr->{c_id} == 38883));
my $i = 0;
foreach my $td (sort keys (%$td_template)){

View file

@ -67,7 +67,6 @@ eval {
#- int28=station_lock_state (station lock velofactur)
#- int30=velofactur station ID
#- int31=velofactur slot ID
#- txt25=velofactur last station message (error or success)
my $jrout = $json->pretty->encode({ fakturjson => $response_in });
print FILE "<=== JSON POST from velofactur:\n$jrout\n" if($debug);
@ -105,7 +104,6 @@ eval {
$update_cc->{int27} = $1 if($response_in->{Fahrzeug}->{Id} && $response_in->{Fahrzeug}->{Id} =~ /(\d+)/);
$update_cc->{int30} = $1 if($response_in->{Station} && $response_in->{Station} =~ /(\d+)/);
$update_cc->{int31} = $1 if($response_in->{Slot} && $response_in->{Slot} =~ /(\d+)/);
$update_cc->{txt25} = $response_in->{Status} if($response_in->{Status});
#velofactur false|true boeelan
#set bike_state to maintanance

View file

@ -172,6 +172,7 @@ sub save_contenttranspos {
fetch => "one",
template_id => "218",#Mietjournal tpl_id
start_time => ">::$end_time",
barcode => $ctpos->{barcode},
"ct.close_time" => "is::null",
};

View file

@ -539,9 +539,32 @@ print ATTR "next: $next\n" if($debug);
$valxx = $q->escapeHTML("@val");
$u_rows += $db->updater("$table","c_id",$c_id,$_,$valxx,$users_dms->{u_id});
}
#txt24 bike_group/station_group multiple select
#txt24 bike_node/station_group and txt25 bike_group multiple select
elsif($tpl->{tpl_id} == 225 && $_ eq "txt24"){
my @val = $q->param($_);
my %station_filter_hash = ();
my @_valxx_filter = ();
my $node = { template_id => 205,#Leihrad_liste
parent_id => 200013,#Waren
fetch => "all",
keyfield => "main_id",
};
my $bike_nodes = {};
$bike_nodes = $dbt->fetch_rel4tpl4nd($dbh,$node);
foreach my $bike_node (@val){
foreach my $rid ( keys (%$bike_nodes)){
if($bike_node == $bike_nodes->{$rid}->{main_id} && $bike_nodes->{$rid}->{type_id}){
$station_filter_hash{$bike_nodes->{$rid}->{type_id}} = 1;
}
}
}
foreach my $type_id (keys (%station_filter_hash)){
push (@_valxx_filter, "$type_id");
}
$db->updater("$table","c_id",$c_id,"txt25","@_valxx_filter",$users_dms->{u_id});
$valxx = $q->escapeHTML("@val");
$u_rows += $db->updater("$table","c_id",$c_id,$_,$valxx,$users_dms->{u_id});
}

View file

@ -251,6 +251,7 @@ sub save_account(){
#txt15=Bonus- oder Antragsnummer (falls vorhanden)=15
#only check bonusnr and add operators dbname.
#bonustarif will be set after operator insert
#TODO, check bonusnr insert on sharee_kn Operator (Giese)
elsif($_ eq "txt15"){
#only done by App web iframe Anmelde-Registration formular
print FILE "Bonusnr request $_: $valxx\n" if($debug);

View file

@ -684,15 +684,18 @@ EOF
print $q->td({-class=>'content1_cms',-colspan=>'1'},$but->selector2("$key","50px;","$height",$ctrel->{$key},@_service_valxx));
}
elsif($key =~ /txt24/ && $node_meta->{tpl_id} == 225){ #Station on station_group (bikenode.main_ids)
my %station_filter_hash = ();
#my %station_filter_hash = ();
#my @_valxx_filter = ("");
my @_valxx = ("");
foreach my $rid (sort { $bike_nodes->{$a}->{node_name} cmp $bike_nodes->{$b}->{node_name} } keys (%$bike_nodes)){
#push (@_valxx, "$bike_nodes->{$rid}->{main_id}:$bike_nodes->{$rid}->{node_name} - $bike_nodes->{$rid}->{main_id}");
$station_filter_hash{$bike_nodes->{$rid}->{type_id}} = 1;
push (@_valxx, "$bike_nodes->{$rid}->{main_id}:$bike_nodes->{$rid}->{node_name} - $bike_nodes->{$rid}->{main_id}");
#$station_filter_hash{$bike_nodes->{$rid}->{type_id}} = 1;
}
foreach my $type_id (keys (%station_filter_hash)){
push (@_valxx, "$type_id:$dbt->{copri_conf}->{type_id}->{$type_id} - $type_id");
}
#foreach my $type_id (keys (%station_filter_hash)){
# push (@_valxx_filter, "$type_id");
#}
#type_id will be set on submit by selected values
#print $q->hidden(-name=>"txt25",-override=>1,-value=>"@_valxx_filter");
my $height = scalar(@_valxx);
print $q->Tr();
@ -720,7 +723,6 @@ EOF
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector("$key","$selsize",$ctrel->{$key},@_valxx));
}
#print $q->hidden(-name=>"$key",-override=>1,-value=>"null");#2021-06-02 select works without empty null
}
elsif($key =~ /txt/ && $size =~ /area$/){
my $h= 1;# if($size =~ /area(\d+)/);

View file

@ -589,16 +589,16 @@ sub tpl(){
}
print $q->td({-class=>'search_line'},$but->selector_class("s_$key","","",$s_val,@s_valxx)),"\n";
}elsif($size =~ /select/ && $key =~ /txt24/ && $tpl_id =~ /225/){#txt24=bike_group (for station filter)
my %station_filter_hash = ();
#my %station_filter_hash = ();
my @s_valxx = ("");
foreach my $rid (sort { $bike_nodes->{$a}->{node_name} cmp $bike_nodes->{$b}->{node_name} } keys (%$bike_nodes)){
#push (@s_valxx, "$bike_nodes->{$rid}->{main_id}:$bike_nodes->{$rid}->{node_name} - $bike_nodes->{$rid}->{main_id}");
$station_filter_hash{$bike_nodes->{$rid}->{type_id}} = 1;
push (@s_valxx, "$bike_nodes->{$rid}->{main_id}:$bike_nodes->{$rid}->{node_name} - $bike_nodes->{$rid}->{main_id}");
#$station_filter_hash{$bike_nodes->{$rid}->{type_id}} = 1;
}
foreach my $type_id (keys (%station_filter_hash)){
push (@s_valxx, "$type_id:$dbt->{copri_conf}->{type_id}->{$type_id} - $type_id");
}
#foreach my $type_id (keys (%station_filter_hash)){
# push (@s_valxx, "$type_id:$dbt->{copri_conf}->{type_id}->{$type_id} - $type_id");
#}
print $q->td({-class=>'search_line'},$but->selector_class("s_$key","","",$s_val,@s_valxx)),"\n";
}elsif($size =~ /select/ && $key =~ /int21|int22/ && $tpl_id == 228){#Bonusnummern
@ -1033,14 +1033,11 @@ sub tpl(){
}
print $q->td({-class=>'tdtxt',-style=>"$txtstyle $set_style"},"$flotten"),"\n";
}elsif($ct4rel->{$id}->{template_id} == 225 && $key eq "txt24"){
my @station_filter = ($ct4rel->{$id}->{$key});
@station_filter = split(/\s+/,$ct4rel->{$id}->{$key}) if($ct4rel->{$id}->{$key} =~ /\d\s+\d/);
my $group_type = "";
foreach (@station_filter){
$group_type .= "$dbt->{copri_conf}->{type_id}->{$_} - $_<br />";
my $flotten = "";
foreach my $rid (sort { $bike_nodes->{$a}->{node_name} cmp $bike_nodes->{$b}->{node_name} } keys (%$bike_nodes)){
$flotten .= "$bike_nodes->{$rid}->{node_name} - $bike_nodes->{$rid}->{main_id}<br />" if($ct4rel->{$id}->{$key} =~ /$bike_nodes->{$rid}->{main_id}/);
}
print $q->td({-class=>'tdtxt',-style=>"$txtstyle $set_style"},"$group_type"),"\n";
print $q->td({-class=>'tdtxt',-style=>"$txtstyle $set_style"},"$flotten"),"\n";
}elsif($ct4rel->{$id}->{template_id} == 228 && $key =~ /int21|int22/){
my $bonustarif = "";
foreach my $rid (sort { $tariff_all->{$a}->{barcode} <=> $tariff_all->{$b}->{barcode} } keys (%$tariff_all)){

View file

@ -154,7 +154,6 @@ sub post_velo {
mtime => "now()",
owner => "$owner",
};
$update_cc->{txt25} = $response_in->{status} if($response_in->{status});
$dbt->update_record($dbh,$update_cc,$record_cc) if($record_cc->{c_id});
$bw->log("update content velofactur response Status for bike $velo_id $record_cc->{barcode} $response_in->{status}",$update_cc,"");
}
@ -177,7 +176,6 @@ sub post_velo {
$update_pos->{int27} = $velo_id if($velo_id);
$update_pos->{30} = $Station if($Station);
$update_pos->{31} = $Slot if($Slot);
$update_pos->{txt25} = $response_in->{status} if($response_in->{status});
$dbt->update_record($dbh,$update_pos,$record_pos) if($record_pos->{c_id});
$bw->log("update contenttranspos velofactur response Status for bike $velo_id $record_pos->{barcode} $response_in->{status}",$update_pos,"");
}

View file

@ -42,9 +42,9 @@ sub tpl(){
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test" || $users_sharee->{txt08} eq "sigo\@sharee.bike")){
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
my $api_test = "sharee_fr01"; my $bike="FR1538";
#my $api_test = "sharee_fr01"; my $bike="FR1538";
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
#my $api_test = "sharee_kn"; my $bike="KN205";
my $api_test = "sharee_kn"; my $bike="KN205";
#my $api_test = "sharee_wue"; my $bike="WUE5525";
#my $api_test = "sharee_sx"; my $bike="S3X1001";
#my $api_test = "sharee_ren"; my $bike="REN2";