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 $station_next = 0;
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)){
my $latitude_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
my $geo_distance_next = $geo_distance;
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)){
my $latitude_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 $varenv = 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;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
@ -1949,12 +1956,19 @@ sub stations_available(){
int10 => "1",#1 = "available"
};
#group_id must have 6 numbers like 300103
my $pref_sql = "";
$pref_sql .= " and (";
foreach(@{$bike_group}){
if($_ =~ /(\d+)/){
$pref_sql .= " ct.txt24 like '%$1%' OR";
if($station_group && $_ =~ /(\d+)/){
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 .= ")";

View file

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

View file

@ -638,14 +638,6 @@ sub save_transact(){
};
my $ctadr = $dbt->fetch_record($dbh,$authref);
my $update_primary = {
table => "contentadr",
mtime => "now()",
owner => "$owner",
c_id => "$c_id",
};
my $pos_id="";
my $ret;
my $fkeys;
@ -688,6 +680,28 @@ sub save_transact(){
$ctadr_operator = $dbt->fetch_record($dbh_operator,$authref);
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";
my $insert_op = {
%$ctadr,