bike_group rental end and maps

This commit is contained in:
ragu 2022-05-17 06:13:53 +02:00
parent 50b695117a
commit f09361320e
8 changed files with 131 additions and 55 deletions

View file

@ -1186,7 +1186,8 @@ sub booking_update(){
my $geo_distance_next = 100000; my $geo_distance_next = 100000;
my $station_next = 0; my $station_next = 0;
my $geo_debug=""; my $geo_debug="";
my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth); my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth,$record_pos);
foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){ foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){
my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/); my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/); my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/);
@ -1376,7 +1377,7 @@ sub booking_update(){
#geofencing for Ilockit #geofencing for Ilockit
my $geo_distance_next = $geo_distance; my $geo_distance_next = $geo_distance;
my $geo_debug=""; my $geo_debug="";
my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth); my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth,$record_pos);
foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){ foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){
my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/); my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/); my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/);
@ -1935,6 +1936,12 @@ sub stations_available(){
my $q = shift || ""; my $q = shift || "";
my $varenv = shift; my $varenv = shift;
my $auth = shift || ""; my $auth = shift || "";
my $record_pos = shift || {};
my $station_group = "";
$station_group = $record_pos->{int12} if(ref($record_pos) eq "HASH" && $record_pos->{int12});
$bw->log("stations_available by station_group: $station_group",$record_pos,"");
my $authed = 0; my $authed = 0;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id}); $authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
@ -1949,12 +1956,19 @@ sub stations_available(){
int10 => "1",#1 = "available" int10 => "1",#1 = "available"
}; };
#group_id must have 6 numbers like 300103
my $pref_sql = ""; my $pref_sql = "";
$pref_sql .= " and ("; $pref_sql .= " and (";
foreach(@{$bike_group}){ foreach(@{$bike_group}){
if($_ =~ /(\d+)/){ if($station_group && $_ =~ /(\d+)/){
$pref_sql .= " ct.txt24 like '%$1%' OR"; my $group_id = $1;
if($group_id == $station_group){
$pref_sql .= " ct.txt24 like '%$group_id%' OR";
} }
}elsif($_ =~ /(\d+)/){
my $group_id = $1;
$pref_sql .= " ct.txt24 like '%$group_id%' OR";
}
} }
$pref_sql =~ s/OR$//; $pref_sql =~ s/OR$//;
$pref_sql .= ")"; $pref_sql .= ")";

View file

@ -715,7 +715,7 @@ elsif($q->param('request') eq "stations_available"){
($response->{stations},my $return2copri->{stations}) = $si->sig_available($q,\%varenv,$authraw); ($response->{stations},my $return2copri->{stations}) = $si->sig_available($q,\%varenv,$authraw);
$tk->sigstation_cupdate($return2copri->{stations}); $tk->sigstation_cupdate($return2copri->{stations});
}else{ }else{
($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw); ($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw,"");
} }
} }
} }

View file

@ -1111,7 +1111,7 @@ sub collect_transpos {
$where .= " and cp.$key = $search->{$key}" if($key eq "int20" && looks_like_number($search->{$key}));#lock_state $where .= " and cp.$key = $search->{$key}" if($key eq "int20" && looks_like_number($search->{$key}));#lock_state
$where .= " and cp.$key = $search->{$key}" if($key eq "barcode" && looks_like_number($search->{$key})); $where .= " and cp.$key = $search->{$key}" if($key eq "barcode" && looks_like_number($search->{$key}));
$where .= " and cp.$key = $search->{$key}" if($key eq "int12" && looks_like_number($search->{$key}));#bike_group $where .= " and cp.$key = $search->{$key}" if($key eq "int12" && looks_like_number($search->{$key}));#bike_group
$where .= " and cp.$key = $search->{$key}" if($key eq "owner" && looks_like_number($search->{$key})); $where .= " and (cp.$key = $search->{$key} OR cp.owner_end = $search->{$key})" if($key eq "owner" && looks_like_number($search->{$key}));
$where .= " and (cp.$key is $search->{$key} OR cp.$key = 0)" if($key eq "int34" && $search->{$key} eq "null"); $where .= " and (cp.$key is $search->{$key} OR cp.$key = 0)" if($key eq "int34" && $search->{$key} eq "null");
} }

View file

@ -638,14 +638,6 @@ sub save_transact(){
}; };
my $ctadr = $dbt->fetch_record($dbh,$authref); my $ctadr = $dbt->fetch_record($dbh,$authref);
my $update_primary = {
table => "contentadr",
mtime => "now()",
owner => "$owner",
c_id => "$c_id",
};
my $pos_id=""; my $pos_id="";
my $ret; my $ret;
my $fkeys; my $fkeys;
@ -688,6 +680,28 @@ sub save_transact(){
$ctadr_operator = $dbt->fetch_record($dbh_operator,$authref); $ctadr_operator = $dbt->fetch_record($dbh_operator,$authref);
if(!$ctadr_operator->{c_id}){ if(!$ctadr_operator->{c_id}){
my %operator_hash = ();
if($ctadr->{txt17} && $ctadr->{txt17} =~ /\w\s\w/){#append DB's
%operator_hash = map { $_ => 1 } split(/\s+/,$ctadr->{txt17});
}elsif($ctadr->{txt17}){
$operator_hash{$ctadr->{txt17}} = 1;
}
$operator_hash{$operator_conf->{database}->{dbname}} = 1;
my @operator_array = keys %operator_hash;
$bw->log("save_transact update operator keys by array: @operator_array",\%operator_hash,"");
print FILE "save_transact update operator keys by array: @operator_array | pri $ctadr->{c_id}\n" if($debug);
my $update_primary = {
table => "contentadr",
txt17 => "@operator_array",#operator ids
txt19 => "$operator_conf->{database}->{dbname}",
atime => "now()",
owner => "198",#update initiated by primary
};
my $rows = $dbt->update_record($dbh,$update_primary,$ctadr);
print FILE "Gutschein oprefix address INSERT adr from record_primary to operator $operator_conf->{database}->{dbname} , c_id:$ctadr->{c_id}\n"; print FILE "Gutschein oprefix address INSERT adr from record_primary to operator $operator_conf->{database}->{dbname} , c_id:$ctadr->{c_id}\n";
my $insert_op = { my $insert_op = {
%$ctadr, %$ctadr,

View file

@ -386,7 +386,7 @@ sub tpl(){
$pos_id = $q->div({-class=>"popup",-onclick=>"toggle_box('$pid')"},"$cttpos->{$pid}->{c_id}", $q->span({-class=>"popuptext",-id=>"$pid"},"$pos_details")); $pos_id = $q->div({-class=>"popup",-onclick=>"toggle_box('$pid')"},"$cttpos->{$pid}->{c_id}", $q->span({-class=>"popuptext",-id=>"$pid"},"$pos_details"));
my $txt26 = $cttpos->{$pid}->{txt26}; my $txt26 = $cttpos->{$pid}->{txt26};
my $txt21 = $cttpos->{$pid}->{txt21}; my $txt21 = $cttpos->{$pid}->{txt21};
$txt26 = substr($cttpos->{$pid}->{txt26},0,20) . " ..." if(length($cttpos->{$pid}->{txt26}) > 20); $txt26 = substr($cttpos->{$pid}->{txt26},0,25) . " ..." if(length($cttpos->{$pid}->{txt26}) > 20);
$txt21 = substr($cttpos->{$pid}->{txt21},0,50) . " ..." if(length($cttpos->{$pid}->{txt21}) > 50); $txt21 = substr($cttpos->{$pid}->{txt21},0,50) . " ..." if(length($cttpos->{$pid}->{txt21}) > 50);
$user_device = ""; $user_device = "";
$user_device .= " &rarr; lock charge $cttpos->{$pid}->{int14} %" if($cttpos->{$pid}->{int14}); $user_device .= " &rarr; lock charge $cttpos->{$pid}->{int14} %" if($cttpos->{$pid}->{int14});

View file

@ -38,20 +38,21 @@ my %varenv = $cf->envonline();
#$bike = "FR1002"; #$bike = "FR1002";
my $lang = "de"; my $lang = "de";
my $dyn_js = " my $dyn_js = "";
function onLoad() { #my $dyn_js = "
console.log('hallo'); #function onLoad() {
# console.log('hallo');
if ('geolocation' in navigator) { #
console.log('geon'); # if ('geolocation' in navigator) {
/* geolocation funktioniert */ # console.log('geon');
} else { # /* geolocation funktioniert */
console.log('geoff'); # } else {
/* geolocation funktioniert NICHT */ # console.log('geoff');
} # /* geolocation funktioniert NICHT */
\$( '#no_javascript' ).hide(); # }
} # \$( '#no_javascript' ).hide();
\n"; # }
# \n";
my $dyn_css = ""; my $dyn_css = "";
my $local_style = "$varenv{metahost}/$dbt->{shareeapp_conf}->{local_style}"; my $local_style = "$varenv{metahost}/$dbt->{shareeapp_conf}->{local_style}";
@ -69,7 +70,7 @@ my %varenv = $cf->envonline();
my $html5 = $q->start_html( my $html5 = $q->start_html(
-title => "shareetest", -title => "shareetest",
-lang => '', -lang => '',
-onload => "onLoad();", #-onload => "onLoad();",
-encoding => "utf-8", -encoding => "utf-8",
-base => 'true', -base => 'true',
-head => Link( -head => Link(
@ -86,25 +87,28 @@ my %varenv = $cf->envonline();
'copyright' => "", 'copyright' => "",
}, },
-script=>[ -script=>[
{-language=>'JAVASCRIPT', #{-language=>'JAVASCRIPT',
-src=>"$jquery"}, #-src=>"$jquery"},
{-language=>'JAVASCRIPT', #{-language=>'JAVASCRIPT',
-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jquery_ui}"}, #-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jquery_ui}"},
{-language=>'JAVASCRIPT', #{-language=>'JAVASCRIPT',
-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jquery_resize}"}, #-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jquery_resize}"},
{-language=>'JAVASCRIPT', #{-language=>'JAVASCRIPT',
-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jsscript}"}, #-src=>"$varenv{metahost}/$dbt->{copri_conf}->{jsscript}"},
#{-language=>'JAVASCRIPT',
#-src=>"https://unpkg.com/leaflet\@1.8.0/dist/leaflet.js"},
{-language=>'JAVASCRIPT', {-language=>'JAVASCRIPT',
-code=>"$dyn_js"} -code=>"$dyn_js"}
], ],
-STYLE=>{ -STYLE=>{
-code=>"$dyn_css", -code=>"$dyn_css",
-src=>[ #-src=>[
"$local_style", #"$local_style",
"$style_bootstrap", #"$style_bootstrap",
"$varenv{metahost}/$dbt->{copri_conf}->{style_bootstrap_icons}", #"$varenv{metahost}/$dbt->{copri_conf}->{style_bootstrap_icons}",
"$varenv{metahost}/$dbt->{copri_conf}->{style_jquery_ui}" #"$varenv{metahost}/$dbt->{copri_conf}->{style_jquery_ui}"
], #"https://unpkg.com/leaflet\@1.8.0/dist/leaflet.css"
#],
-verbatim=>"\@import url(\"$local_style\");", -verbatim=>"\@import url(\"$local_style\");",
-media=>'screen' -media=>'screen'
} }
@ -120,6 +124,49 @@ my $uri = "$dbt->{primary}->{sharee_primary}->{primaryApp}/APIjsonserver";
#print $q->div({-style=>'margin:15px;'},$q->a({-href=>"/src/scripts/tests/index.pl"},"[ index ]")),"\n"; #print $q->div({-style=>'margin:15px;'},$q->a({-href=>"/src/scripts/tests/index.pl"},"[ index ]")),"\n";
print $q->div({-style=>'margin:15px;'},"sharee API tests", $q->b("operator_key: $operator_key | bike: $bike")),"\n"; print $q->div({-style=>'margin:15px;'},"sharee API tests", $q->b("operator_key: $operator_key | bike: $bike")),"\n";
print<<EOF
<link rel="stylesheet" href="https://unpkg.com/leaflet\@1.8.0/dist/leaflet.css"
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet\@1.8.0/dist/leaflet.js"
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
crossorigin=""></script>
<style>
#map {
height: 500px;
width: 750px;
}
</style>
EOF
;
print "<div id='map'></div>\n";
print<<EOF
<script>
var map = L.map('map').setView([47.976634, 7.825490], 13);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoic2hhcmVlYmlrZSIsImEiOiJjbDM3bXdreHIwMnZxM2NtbjVkc2pwNWp4In0.QAwnPXx4yZsbPSm2DvP62w', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'your.mapbox.access.token'
}).addTo(map);
</script>
EOF
;
print $q->div({-style=>'margin:15px;'},"-------------- $uri --------------------"),"\n"; print $q->div({-style=>'margin:15px;'},"-------------- $uri --------------------"),"\n";
my $authorization = "$uri?request=authorization&user_id=ragu\@sharee.bike&user_pw=xxxxxx&merchant_id=oiF2kahH&hw_id=g89g8o7goguzuzug"; my $authorization = "$uri?request=authorization&user_id=ragu\@sharee.bike&user_pw=xxxxxx&merchant_id=oiF2kahH&hw_id=g89g8o7goguzuzug";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$authorization"},"[ authorization ]---> $authorization")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$authorization"},"[ authorization ]---> $authorization")),"\n";
@ -218,9 +265,9 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$bookin
my $user_feedback = "$uriop?request=user_feedback&bike=$bike&bike_broken=1&message=testnachricht äöü&authcookie=$coo"; my $user_feedback = "$uriop?request=user_feedback&bike=$bike&bike_broken=1&message=testnachricht äöü&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n";
print "<div style='text-align:center;'>"; #print "<div style='text-align:center;'>";
print "<iframe width='750' height='500' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://www.openstreetmap.org/export/embed.html?bbox=7.604942321777345%2C47.923934784536236%2C7.979164123535157%2C48.07005002188767&amp;layer=mapnik' style='border: 1px solid black'></iframe><br/><small><a href='https://www.openstreetmap.org/#map=12/47.9970/7.7921'>Größere Karte anzeigen</a></small>\n"; #print "<iframe width='750' height='500' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://www.openstreetmap.org/export/embed.html?bbox=7.604942321777345%2C47.923934784536236%2C7.979164123535157%2C48.07005002188767&amp;layer=mapnik' style='border: 1px solid black'></iframe><br/><small><a href='https://www.openstreetmap.org/#map=12/47.9970/7.7921'>Größere Karte anzeigen</a></small>\n";
print "</div>\n"; #print "</div>\n";
print $q->end_html; print $q->end_html;
1; 1;

View file

@ -42,10 +42,10 @@ 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")){ 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")){
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || ""; my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
#my $api_test = "sharee_kn"; #my $api_test = "sharee_kn"; my $bike="KN205";
#my $api_test = "sharee_fr01"; my $bike="FR1538"; my $api_test = "sharee_fr01"; my $bike="FR1538";
#my $api_test = "sharee_wue"; #my $api_test = "sharee_wue";
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";
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n"; print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";

View file

@ -403,12 +403,13 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
} }
print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$co2saving"); print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$co2saving");
}elsif($key eq "int02"){ }elsif($key eq "int02"){
if($pricing->{total_price}){ if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
my $gesamt = 0;
$sum += $pricing->{total_price}; $sum += $pricing->{total_price};
$pricing->{total_price} = $lb->round($pricing->{total_price}); $gesamt = $lb->round($pricing->{total_price});
$pricing->{total_price} = sprintf('%.2f', $pricing->{total_price}); $gesamt = sprintf('%.2f', $gesamt);
$pricing->{total_price} =~ s/\./,/; $gesamt =~ s/\./,/;
print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$pricing->{total_price} €"),"\n"; print $q->td({-class=>'tdint', -style=>"$occupied_style", -nowrap=>1},"$gesamt €"),"\n";
}else{ }else{
my $gesamt = 0; my $gesamt = 0;
my $rabatt = ""; my $rabatt = "";