sig feedback counter

This commit is contained in:
ragu 2022-06-29 17:34:51 +02:00
parent 25a86e87e5
commit 8bcc46416c
5 changed files with 98 additions and 65 deletions

View file

@ -490,6 +490,24 @@ sub service_update(){
my $return={};
my $update = {};
my $bike = $q->escapeHTML($q->param('bike')) || "";
my $bike_id = $bike;
$bike_id =~ s/S[1-9]X/SX/;
$bike_id = $1 if($bike_id =~ /(\d+)/);
my $pref = {
table => "contenttrans",
table_pos => "contenttranspos",
fetch => "one",
template_id => "218",#Mietjournal tpl_id
barcode => $bike_id,
ca_id => "$auth->{c_id}",
"ct.close_time" => "is::null",
int10 => "1",
int28 => "3",
};
my $ctpos = { c_id => 0 };
if($q->param('request') eq "service_done"){
$c_id = $q->param('service_id') if($q->param('service_id'));
$update = {
@ -507,6 +525,16 @@ sub service_update(){
$update->{int01} = 1 if($q->param('bike_broken'));
$update->{txt02} = $q->escapeHTML($q->param('message')) if($q->param('message'));
#to update sig int28 counter
$ctpos = $dbt->collect_post($dbh,$pref) if($bike_id);
if($ctpos->{c_id} > 0){
my $update_pos = {
table => "contenttranspos",
mtime => "now()",
int28 => "2",
};
$dbt->update_record($dbh,$update_pos,$ctpos);
}
}elsif($q->param('request') eq "user_minianswer"){
$update = {
table => "contentadrpos",
@ -530,6 +558,29 @@ sub service_update(){
$update->{int02} = $post_record->{int26} if($post_record->{int26});
$update->{txt10} = $dbt->{operator}->{$last_used_operator}->{oprefix};
}
#to update sig int28 counter
$ctpos = $dbt->collect_post($dbh,$pref) if($bike_id);
if($ctpos->{c_id} > 0){
my $update_pos = {
table => "contenttranspos",
mtime => "now()",
int28 => "null",
};
$dbt->update_record($dbh,$update_pos,$ctpos);
#user_miniquest_count
my $user_miniquest_count = $auth->{int23} || 0;
if($user_miniquest_count <= 3){
$user_miniquest_count++;
my $update_op = {
table => "contentadr",
int23 => $user_miniquest_count,
atime => "now()",
};
my $rows = $dbt->update_record($dbh,$update_op,$auth);
}
}
}
my $record = { c_id => $c_id };
@ -1510,6 +1561,29 @@ sub booking_update(){
$booking_values->{lock_state} = "locking" if($booking->{int20} == 3);
$booking_values->{lock_state} = "unlocking" if($booking->{int20} == 4);
#keep in mind, it works on operator dependency
#only for project=Bayern and developer enabled
#redundant code in APIfunc sub rentals for sig user_miniquery
if($booking->{int10} == 1 && $dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4){
$bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},"");
$booking_values->{user_miniquery} = $dbt->evaluationsfragen($dbh);
#user_miniquest_count
my $user_miniquest_count = $auth->{int23} || 0;
if($user_miniquest_count <= 4){
$user_miniquest_count++;
my $update_op = {
table => "contentadr",
int23 => $user_miniquest_count,
atime => "now()",
};
$rows = $dbt->update_record($dbh,$update_op,$auth);
}
}#end mini_quest
#fetch tracking distance on Ilockit cloud by summary trip if(tracking && deviceId && available)
if($booking->{int25} == 1 && $booking->{int10} == 1){
$bw->log("get co2saving",$booking->{c_id},"");
@ -1657,7 +1731,7 @@ sub user_bikes_occupied(){
my $self = shift;
my $q = shift;
my $auth = shift;
my $station_lock_state = shift || "";
#my $station_lock_state = shift || "";
my $pref = {
table => "contenttrans",
@ -1674,7 +1748,7 @@ sub user_bikes_occupied(){
#station_lock_stat enables a OR condition to view available as requested/occupied
##selects also station_lock_state=locking bikes to view once miniquery
#true if not defined! it will only defined on booking_request, because there must be available
$pref->{station_lock_state} = "3" if(!$station_lock_state);
#$pref->{station_lock_state} = "3" if(!$station_lock_state);
my $record = $dbt->collect_post($dbh,$pref);
return $record;
}#end user_bikes_occupied
@ -1716,44 +1790,20 @@ sub rentals(){
}
#sig update station_lock_state=locked to cancel once miniquery
elsif($record->{$id}->{int11} && $record->{$id}->{int11} == 3){
#$return->{state} = "requested";#used once in App after sig rental-end push-notify
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
if($record->{$id}->{int28} && $record->{$id}->{int28} == 3){
if($record->{$id}->{int28}){
$return->{$id}->{state} = "returned";
#only for project=Bayern and developer enabled
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4){
$bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},"");
$return->{$id}->{user_miniquery} = $dbt->evaluationsfragen($dbh);
#user_miniquest_count
my $user_miniquest_count = $auth->{int23} || 0;
if($user_miniquest_count <= 4){
$user_miniquest_count++;
my $update_op = {
table => "contentadr",
int23 => $user_miniquest_count,
atime => "now()",
};
my $rows = $dbt->update_record($dbh,$update_op,$auth);
}
}#end mini_quest
$return->{$id}->{state} = "returned";#used once in App after sig rental-end push-notify
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
my $update_pos = {
table => "contenttranspos",
int28 => "1",
c_id => "$id",
};
$dbt->update_record($dbh,$update_pos,$update_pos);
$bw->log("sig update int28 station_lock_state=locked to cancel once miniquery",$update_pos,"");
}
}
}
}#end mini_quest
}
}
}
return $return;
}#end rentals