mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-23 04:06:27 +01:00
booking calendar adding pos.reserv_time and some fixes
This commit is contained in:
parent
d5a98d0c54
commit
1112b2c2b5
5 changed files with 63 additions and 44 deletions
|
@ -49,10 +49,8 @@ sub new {
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
|
||||||
my $now_date = strftime "%Y-%m-%d", localtime;
|
|
||||||
my $strp = DateTime::Format::Strptime->new(
|
my $strp = DateTime::Format::Strptime->new(
|
||||||
pattern => '%Y-%m-%dT%H:%M:%S',
|
pattern => '%Y-%m-%dT%H:%M',
|
||||||
locale => 'de_DE',
|
locale => 'de_DE',
|
||||||
time_zone => 'Europe/Berlin',
|
time_zone => 'Europe/Berlin',
|
||||||
on_error => 'croak',
|
on_error => 'croak',
|
||||||
|
@ -909,13 +907,13 @@ sub booking_request(){
|
||||||
my $lock_state = $q->escapeHTML($q->param('lock_state')) || "";
|
my $lock_state = $q->escapeHTML($q->param('lock_state')) || "";
|
||||||
|
|
||||||
my $now_dt = DateTime->now( time_zone => "Europe/Berlin" );
|
my $now_dt = DateTime->now( time_zone => "Europe/Berlin" );
|
||||||
my $reserv_starttime = $q->escapeHTML($q->param('reserv_starttime')) || $now_dt;
|
my $reserv_starttime = $q->escapeHTML($q->param('reserv_starttime')) || "";
|
||||||
my $reserv_endtime = $q->escapeHTML($q->param('reserv_endtime')) || $now_dt;
|
my $reserv_endtime = $q->escapeHTML($q->param('reserv_endtime')) || "";
|
||||||
my $calreserv = $q->escapeHTML($q->param('calreserv')) || 0;
|
my $calreserv = $q->escapeHTML($q->param('calreserv')) || 0;
|
||||||
|
|
||||||
my $request_para = {
|
my $request_para = {
|
||||||
start_time => $reserv_starttime,
|
start_time => "now()",
|
||||||
end_time => $reserv_endtime,
|
end_time => "now()",
|
||||||
|
calreserv => "$calreserv",
|
||||||
};
|
};
|
||||||
|
|
||||||
my $dbh = "";
|
my $dbh = "";
|
||||||
|
@ -1020,6 +1018,8 @@ sub booking_request(){
|
||||||
if($sum_balance <= 1 && !$ctt_opos->{c_id}){
|
if($sum_balance <= 1 && !$ctt_opos->{c_id}){
|
||||||
my $booking_state = 2;
|
my $booking_state = 2;
|
||||||
$booking_state = 7 if($calreserv);
|
$booking_state = 7 if($calreserv);
|
||||||
|
|
||||||
|
if($reserv_starttime && $reserv_endtime){
|
||||||
my $timestamp = DateTime->now( time_zone => "Europe/Berlin" );
|
my $timestamp = DateTime->now( time_zone => "Europe/Berlin" );
|
||||||
my $now_time = $strp->parse_datetime($timestamp);
|
my $now_time = $strp->parse_datetime($timestamp);
|
||||||
|
|
||||||
|
@ -1036,13 +1036,24 @@ sub booking_request(){
|
||||||
$response_state = "Failure 4261, 4 weeks reserv timerange";
|
$response_state = "Failure 4261, 4 weeks reserv timerange";
|
||||||
$response_text = "Abbruch, Reservierungen sind maximal 4 Wochen im voraus erlaubt";
|
$response_text = "Abbruch, Reservierungen sind maximal 4 Wochen im voraus erlaubt";
|
||||||
}else{
|
}else{
|
||||||
|
$request_para = {
|
||||||
|
start_time => "$reserv_starttime",
|
||||||
|
end_time => "$reserv_endtime",
|
||||||
|
calreserv => "$calreserv",
|
||||||
|
};
|
||||||
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$request_para,$bike,$booking_state,$owner,$sig_book);
|
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$request_para,$bike,$booking_state,$owner,$sig_book);
|
||||||
$bw->log("booking_request insert_pos:",$pos_id,"");
|
$bw->log("booking_request reserved insert_pos:",$pos_id,"");
|
||||||
|
$response_state = "OK, bike " . $bike . " succesfully reserved";
|
||||||
|
$response_text = "Erfolgreiche Buchung: $start_loc - $end_loc.";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$response_state = "Failure 4260, reserv timerange";
|
$response_state = "Failure 4260, reserv timerange";
|
||||||
$response_text = "Abbruch, die Mietzeit liegt in der Vergangenheit";
|
$response_text = "Abbruch, die Mietzeit liegt in der Vergangenheit";
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_bike,$ct_station,$auth,$ct_tariff,$request_para,$bike,$booking_state,$owner,$sig_book);
|
||||||
|
$bw->log("booking_request insert_pos:",$pos_id,"");
|
||||||
|
}
|
||||||
|
|
||||||
if($pos_id){
|
if($pos_id){
|
||||||
$bw->log("booking_request insert contenttranspos pos_id: $pos_id\n","","");
|
$bw->log("booking_request insert contenttranspos pos_id: $pos_id\n","","");
|
||||||
|
@ -1055,19 +1066,15 @@ sub booking_request(){
|
||||||
};
|
};
|
||||||
$dbt->update_one($dbh,$update_ctt,"start_time='$now_dt'");
|
$dbt->update_one($dbh,$update_ctt,"start_time='$now_dt'");
|
||||||
|
|
||||||
# state=7 meens reserved, prevents auto available after 15min
|
|
||||||
if($calreserv){
|
|
||||||
$response_state = "OK, bike " . $bike . " succesfully reserved";
|
|
||||||
$response_text = "Erfolgreiche Buchung: $start_loc - $end_loc.";
|
|
||||||
}
|
|
||||||
#update waren bike state only if adhock booking
|
#update waren bike state only if adhock booking
|
||||||
elsif(!$calreserv){
|
if(!$calreserv){
|
||||||
my $update_ct = {
|
my $update_ct = {
|
||||||
table => "content",
|
table => "content",
|
||||||
c_id => $ct_bike->{c_id},
|
c_id => $ct_bike->{c_id},
|
||||||
mtime => "now()",
|
mtime => "now()",
|
||||||
owner => $owner,
|
owner => $owner,
|
||||||
};
|
};
|
||||||
|
$dbt->update_one($dbh,$update_ct,"int10='2'");
|
||||||
$response_state = "OK, bike " . $bike . " succesfully adhock requested";
|
$response_state = "OK, bike " . $bike . " succesfully adhock requested";
|
||||||
$response_text = "Rad $bike wurde erfolgreich für 15 Min. adhock reserviert";
|
$response_text = "Rad $bike wurde erfolgreich für 15 Min. adhock reserviert";
|
||||||
}
|
}
|
||||||
|
@ -1142,8 +1149,24 @@ sub booking_request(){
|
||||||
};
|
};
|
||||||
$bw->log("booking_request response_state:",$return,"");
|
$bw->log("booking_request response_state:",$return,"");
|
||||||
|
|
||||||
|
#final booking request update
|
||||||
|
if($pos_id){
|
||||||
|
my $update_pos = {
|
||||||
|
table => "contenttranspos",
|
||||||
|
mtime => "now()",
|
||||||
|
};
|
||||||
|
if($calreserv && $reserv_starttime && $reserv_endtime && $reserv_starttime =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/ && $reserv_endtime =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/){
|
||||||
|
$update_pos->{reserv_starttime} = $reserv_starttime;
|
||||||
|
$update_pos->{reserv_endtime} = "$reserv_endtime";
|
||||||
|
}
|
||||||
|
my $logvalues = "pos_id=$pos_id, state=$state, start_time=$request_para->{start_time}, end_time=$request_para->{end_time}, calreserv=$request_para->{calreserv}, response_state=$response_state";
|
||||||
|
my $log_stamp = strftime "%d.%m.%Y %H:%M:%S", localtime;
|
||||||
|
$update_pos->{txt24} = "\n- $log_stamp $logvalues";
|
||||||
|
$dbt->update_record($dbh,$update_pos,{ c_id => $pos_id });
|
||||||
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}#end booking_request
|
||||||
|
|
||||||
#booking_cancel changed to booking_update
|
#booking_cancel changed to booking_update
|
||||||
sub booking_update {
|
sub booking_update {
|
||||||
|
@ -1356,7 +1379,7 @@ sub booking_update {
|
||||||
if(($state_key == 3 && ($record_pos->{int10} == 2 || $record_pos->{int10} == 7)) || ($state_key == 3 && $record_pos->{int10} == 3 && $q->param('genkey') eq "1")){
|
if(($state_key == 3 && ($record_pos->{int10} == 2 || $record_pos->{int10} == 7)) || ($state_key == 3 && $record_pos->{int10} == 3 && $q->param('genkey') eq "1")){
|
||||||
|
|
||||||
$update_pos->{start_time} = "now()";
|
$update_pos->{start_time} = "now()";
|
||||||
#$update_pos->{end_time} = "now()";#don't set anymore because of revserv time
|
$update_pos->{end_time} = "now()" if(!$record_pos->{reserv_endtime});
|
||||||
$update_pos->{txt05} = "$record_cc->{txt06}";#pos start GPS from content end GPS
|
$update_pos->{txt05} = "$record_cc->{txt06}";#pos start GPS from content end GPS
|
||||||
$update_pos->{int06} = "$record_cc->{int04}";#pos start station from content station
|
$update_pos->{int06} = "$record_cc->{int04}";#pos start station from content station
|
||||||
$update_pos->{txt12} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}";#pos start station prefix
|
$update_pos->{txt12} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}";#pos start station prefix
|
||||||
|
@ -1970,11 +1993,6 @@ sub user_bikes_occupied {
|
||||||
$pref->{end_time} = ">=::now()";
|
$pref->{end_time} = ">=::now()";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($q->param('request') eq "booking_request"){
|
|
||||||
$pref->{int10} = "IN::('2','3','7')";
|
|
||||||
$pref->{start_time} = ">=::now()";
|
|
||||||
}
|
|
||||||
|
|
||||||
$pref->{int06} = $station if($station);#pos start-station
|
$pref->{int06} = $station if($station);#pos start-station
|
||||||
|
|
||||||
my $record = {};
|
my $record = {};
|
||||||
|
|
|
@ -323,6 +323,7 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
$apif->stations_caching($q,\%varenv,$authraw);
|
$apif->stations_caching($q,\%varenv,$authraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bw->log("booking_request response_book:",$response_book,"");
|
||||||
#just in time booking
|
#just in time booking
|
||||||
if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){
|
if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){
|
||||||
my $booking_values = {};
|
my $booking_values = {};
|
||||||
|
|
|
@ -704,6 +704,8 @@ sub collect_post(){
|
||||||
}else{
|
}else{
|
||||||
$cp_where .= " and cp.$key $op '$value'";
|
$cp_where .= " and cp.$key $op '$value'";
|
||||||
}
|
}
|
||||||
|
}elsif($key eq "int10" && $value){
|
||||||
|
$cp_where .= " and (cp.$key $op $value OR (cp.int10 = 7 and now() BETWEEN cp.start_time and cp.end_time))";
|
||||||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||||
if($value eq "null"){
|
if($value eq "null"){
|
||||||
$cp_where .= " and (cp.$key is null OR cp.$key = 0)";
|
$cp_where .= " and (cp.$key is null OR cp.$key = 0)";
|
||||||
|
@ -712,8 +714,6 @@ sub collect_post(){
|
||||||
}
|
}
|
||||||
}elsif($fetch->{catch} && $key eq "template_id" && $value){
|
}elsif($fetch->{catch} && $key eq "template_id" && $value){
|
||||||
$cp_where .= " and cp.$key $op $value";
|
$cp_where .= " and cp.$key $op $value";
|
||||||
#}elsif(!$fetch->{catch} && $key =~ /main_id|template_id/ && $value){
|
|
||||||
#$ct_where .= " and rel.$key $op $value";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1025,7 @@ sub update_record(){
|
||||||
$update->{$key} =~ s/\s$//g if($update->{$key});
|
$update->{$key} =~ s/\s$//g if($update->{$key});
|
||||||
my $value = $update->{$key} || "";
|
my $value = $update->{$key} || "";
|
||||||
$value = "$update->{$key}" if(looks_like_number($update->{$key}));
|
$value = "$update->{$key}" if(looks_like_number($update->{$key}));
|
||||||
if($key =~ /^(ct_name$|txt\d+|state|start_time|end_time|byte)/){
|
if($key =~ /^(ct_name$|txt\d+|state|start_time|end_time|reserv_starttime|reserv_endtime|byte)/){
|
||||||
if($value && $value eq "null"){
|
if($value && $value eq "null"){
|
||||||
$set .= " $key=$value,";
|
$set .= " $key=$value,";
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -477,7 +477,7 @@ EOF
|
||||||
}elsif($key =~ /int10/ && "$size" eq "select"){#bike_state
|
}elsif($key =~ /int10/ && "$size" eq "select"){#bike_state
|
||||||
my @_lock_valxx = ();
|
my @_lock_valxx = ();
|
||||||
foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{bike_state} })) {
|
foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{bike_state} })) {
|
||||||
push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{bike_state}->{$s_key}" if($s_key =~ /1|2|3/);
|
push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{bike_state}->{$s_key}" if($s_key =~ /1|2|3|7/);
|
||||||
}
|
}
|
||||||
print $q->Tr();
|
print $q->Tr();
|
||||||
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
|
||||||
|
|
|
@ -354,7 +354,7 @@ sub tpl(){
|
||||||
($year_st,$mon_st,$day_st,$hh_st,$mm_st) = $lb->split_date($cttpos->{$pid}->{itime});
|
($year_st,$mon_st,$day_st,$hh_st,$mm_st) = $lb->split_date($cttpos->{$pid}->{itime});
|
||||||
}
|
}
|
||||||
if($cttpos->{$pid}->{end_time}){
|
if($cttpos->{$pid}->{end_time}){
|
||||||
$cttpos->{$pid}->{end_time} = $now_dt if($node_meta->{ct_table} eq "contenttranspos" && $cttpos->{$pid}->{start_time} eq $cttpos->{$pid}->{end_time} );
|
$cttpos->{$pid}->{end_time} = $now_dt if($node_meta->{ct_table} eq "contenttranspos" && $cttpos->{$pid}->{int10} == 3 && !$cttpos->{$pid}->{reserv_endtime});
|
||||||
($year_en,$mon_en,$day_en,$hh_en,$mm_en) = $lb->split_date($cttpos->{$pid}->{end_time});
|
($year_en,$mon_en,$day_en,$hh_en,$mm_en) = $lb->split_date($cttpos->{$pid}->{end_time});
|
||||||
}else{
|
}else{
|
||||||
($year_en,$mon_en,$day_en,$hh_en,$mm_en) = $lb->split_date($cttpos->{$pid}->{itime});
|
($year_en,$mon_en,$day_en,$hh_en,$mm_en) = $lb->split_date($cttpos->{$pid}->{itime});
|
||||||
|
|
Loading…
Add table
Reference in a new issue