mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
stations_available bike_count
This commit is contained in:
parent
882f848355
commit
cf476a2154
2 changed files with 48 additions and 21 deletions
|
@ -2259,6 +2259,21 @@ sub stations_available(){
|
|||
my $record = {};
|
||||
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
|
||||
|
||||
#bike_count
|
||||
my $bpref = {
|
||||
table => "content",
|
||||
fetch => "all",
|
||||
keyfield => "barcode",
|
||||
template_id => "205",
|
||||
int10 => "1",
|
||||
};
|
||||
my $record_bikes = {};
|
||||
$record_bikes = $dbt->fetch_record($dbh,$bpref,"");
|
||||
|
||||
#user_rental_count
|
||||
my $record_rentals = {};
|
||||
$record_rentals = $self->user_bikes_occupied($q,$auth,"") if($auth->{c_id});
|
||||
|
||||
my $hotline_hash = {
|
||||
table => "contentuser",
|
||||
fetch => "one",
|
||||
|
@ -2270,25 +2285,40 @@ sub stations_available(){
|
|||
|
||||
my $op_return = {};
|
||||
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
|
||||
$return->{$id}->{authed} = "$authed";
|
||||
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
||||
my $bike_count = 0;
|
||||
foreach my $b_id (keys (%$record_bikes)){
|
||||
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
|
||||
$bike_count++;
|
||||
}
|
||||
}
|
||||
$return->{$id}->{bike_count} = "$bike_count";
|
||||
|
||||
my $user_rental_count = 0;
|
||||
foreach my $r_id (keys (%$record_rentals)){
|
||||
if($record->{$id}->{int04} == $record_rentals->{$r_id}->{int06}){
|
||||
$user_rental_count++;
|
||||
}
|
||||
}
|
||||
$return->{$id}->{user_rental_count} = "$user_rental_count";
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
|
||||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$record->{$id}->{txt06} =~ s/\s//g;
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
||||
$return->{$id}->{description} = "$description";
|
||||
#$return->{$id}->{description} = Encode::encode('utf-8', Encode::decode('iso-8859-1', $description));
|
||||
$return->{$id}->{authed} = "$authed";
|
||||
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
||||
|
||||
$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}->{txt25}){
|
||||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$record->{$id}->{txt06} =~ s/\s//g;
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
||||
$return->{$id}->{description} = "$description";
|
||||
$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}->{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];
|
||||
}
|
||||
}
|
||||
|
||||
$return->{$id}->{operator_data} = {
|
||||
"operator_name" => "",
|
||||
|
|
|
@ -662,16 +662,12 @@ sub collect_post(){
|
|||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||
$cp_where .= " and cp.$key $op $value";
|
||||
}
|
||||
#}
|
||||
#selects also push event=RENTAL_END station_lock_state bikes to view feedback and miniquery
|
||||
#elsif($key eq "int10" && $value eq "('3','2')" && $fetch->{show_dialog}){
|
||||
# $cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";#select only if no dialog saved
|
||||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||
$cp_where .= " and cp.$key $op $value";
|
||||
}elsif($fetch->{catch} && $key eq "template_id" && $value){
|
||||
$cp_where .= " and cp.$key $op $value";
|
||||
}elsif(!$fetch->{catch} && $key =~ /main_id|template_id/ && $value){
|
||||
$ct_where .= " and rel.$key $op $value";
|
||||
#}elsif(!$fetch->{catch} && $key =~ /main_id|template_id/ && $value){
|
||||
#$ct_where .= " and rel.$key $op $value";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,7 +681,8 @@ sub collect_post(){
|
|||
$sth = $dbh->prepare($sql);
|
||||
}else{
|
||||
#rental pos with capture booking ct.state
|
||||
$sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $poscid IN (SELECT ct.c_id FROM relation rel, $fetch->{table} ct WHERE rel.content_id=ct.c_id and $ct_where) order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry
|
||||
#$sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $poscid IN (SELECT ct.c_id FROM relation rel, $fetch->{table} ct WHERE rel.content_id=ct.c_id and $ct_where) order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry
|
||||
$sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $ct_where order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry
|
||||
$sth = $dbh->prepare($sql);
|
||||
}
|
||||
#$bw->log("DBtank collect_post ",$sql,"") if($debug);
|
||||
|
|
Loading…
Add table
Reference in a new issue