App merchant-message

This commit is contained in:
ragu 2023-05-15 11:39:26 +02:00
parent 9da4bd0cb0
commit 75a23dc3f4
5 changed files with 40 additions and 30 deletions

View file

@ -381,7 +381,7 @@ sub service_select {
$pos_record->{1}->{template_id} = $node_template->{template_id};
}
$bw->log("service_select with node_template: $node_template->{template_id} and pos_record:",$pos_record,"");
$bw->log("service_select with node_template: $node_template->{template_id} and pos_record:","","");
}
return ($return,$pos_record,$node_template,$crecord);
@ -1123,8 +1123,6 @@ sub booking_update(){
my $record_cc = { c_id => 0 };
$record_cc = $dbt->fetch_record($dbh,$pref_cc) if($q->param('bike'));
$bw->log("booking_update bike to state $bike | $state | $lock_state, auth:$auth->{c_id}",$auth->{c_id},"");
my $update_cc = {
table => "content",
mtime => "now()",
@ -1156,6 +1154,8 @@ sub booking_update(){
$gps_data->{gps} = "$gps_data->{latitude},$gps_data->{longitude}" if($gps_data->{latitude} && $gps_data->{longitude});
}
$bw->log("booking_update bike to state $bike | $state | $lock_state, auth:$auth->{c_id}, gps:$gps_data->{gps}",$auth->{c_id},"");
my $Ilockit_GUID = "";
$Ilockit_GUID = $q->escapeHTML($q->param('Ilockit_GUID')) if($q->param('Ilockit_GUID') && $q->param('Ilockit_GUID') =~ /\w+-\w+-\w+-\w+$/);
#$update_pos->{txt17} = $Ilockit_GUID if($Ilockit_GUID);
@ -2540,7 +2540,7 @@ sub fetch_tariff(){
if($cachme eq "public"){
$tariff->{int18} = 2;
$tariff_all = $dbt->fetch_record($dbh,$tariff);
$bw->log("$dbname $cachme Tariff type for No operator registered user by int18:$tariff->{int18} select 1:",$tariff_all,"");
$bw->log("$dbname $cachme Tariff type for No operator registered user by int18:$tariff->{int18} select 1:",$tariff->{barcode},"");
}
elsif(looks_like_number($cachme) && $cachme > 0){
$tariff->{barcode} = $cachme;
@ -2552,13 +2552,13 @@ sub fetch_tariff(){
}else{
$auth_operator = { txt30 => "$cachme" };
}
$bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} OR int18: $tariff->{int18} select 2:",$tariff_all,"");
$bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} OR int18: $tariff->{int18} select 2:",$tariff->{barcode},"");
}
#if no primary address then only 2=public
elsif((ref($adr) ne "HASH" || !$adr->{c_id}) && ($dbname ne "sharee_lv")){
$tariff->{int18} = 2;
$tariff_all = $dbt->fetch_record($dbh,$tariff);
$bw->log("$dbname Tariff type for No operator registered user by int18:$tariff->{int18} select 3:",$tariff_all,"");
$bw->log("$dbname Tariff type for No operator registered user by int18:$tariff->{int18} select 3:",$tariff->{barcode},"");
}
#select operators address to get users tarifnr array in txt30
elsif(ref($adr) eq "HASH" && $adr->{c_id}){

View file

@ -45,7 +45,8 @@ sub handler {
my %varenv = $cf->envonline();
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix};
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $lang="de";
my $lang="en";
$lang = lc($R::lang) if($R::lang);
my @keywords = $q->param;
my $debug=1;
my $user_agent = $q->user_agent();
@ -81,7 +82,7 @@ my $response = {
impress_html => "$dbt->{project_conf}->{Freiburg}->{impress_html}",
tariff_info_html => "$dbt->{project_conf}->{Freiburg}->{tariff_info_html}",
bike_info_html => "$dbt->{project_conf}->{Freiburg}->{bike_info_html}",
lang => "de",
lang => "$lang",
last_used_operator => {
operator_name => "sharee.bike | TeilRad GmbH",
operator_email => "hotline\@sharee.bike",
@ -95,10 +96,10 @@ my $response = {
};
if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($R::lang) });
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($lang) });
}else{
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($R::lang) });
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($lang) });
}
my $aowner = 0;
@ -675,27 +676,34 @@ elsif($q->param('request') eq "stations_available"){
my ($auth,$authraw) = $apif->auth_verify($q);
my $user_agent_subversion = 1000;
#$user_agent = "3.0.348";#test
#$user_agent = "Meinkonrad/3.0.363";#test
$user_agent_subversion = $1 if($user_agent =~ /3\.0\.(\d+)/);
#merchant_message timerange
my $lnow = strftime("%Y-%m-%d %H:%M:%S", localtime(time));
my $localtime = Time::Piece->strptime($lnow, "%Y-%m-%d %H:%M:%S");
my $epoch_now = $localtime->epoch;
my $maintanance_start = Time::Piece->strptime("2023-03-06 00:00:00", "%Y-%m-%d %H:%M:%S");
my $maintanance_end = Time::Piece->strptime("2023-04-01 01:00:00", "%Y-%m-%d %H:%M:%S");
my $epoch_start = $maintanance_start->epoch;
my $epoch_end = $maintanance_end->epoch;
my $merchant_message_start = Time::Piece->strptime("2023-05-15 00:00:00", "%Y-%m-%d %H:%M:%S");
my $merchant_message_end = Time::Piece->strptime("2023-05-21 23:00:00", "%Y-%m-%d %H:%M:%S");
my $epoch_start = $merchant_message_start->epoch;
my $epoch_end = $merchant_message_end->epoch;
#App update message
if($user_agent_subversion <= 348){
if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
$response->{merchant_message} = $varenv{cms}->{'App-update-message'}->{txt};
}else{
#if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
#$response->{merchant_message} = $varenv{cms}->{'App-update-message'}->{txt};
#}else{
$response->{merchant_message} = $varenv{cms}->{'App-update-message-expired'}->{txt};
$apif->authout($q,$coo);
$dbt->update_operatorsloop($varenv{dbname},$authraw->{c_id},"update");
}
#}
}
#App merchant message
if($user_agent =~ /konrad/i){
if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
$response->{merchant_message} = $varenv{cms}->{'App-merchant-message'}->{txt};
}
}
$response = { %$response, %$auth };

View file

@ -686,15 +686,15 @@ sub collect_post(){
#fetch CMS
#coalesce works only on null values
sub fetch_cms(){
sub fetch_cms {
my $self = shift;
my $dbh = shift || $dbh_intern;
my $fetch = shift;
my $langfield = "txt01";
$langfield = "txt02" if($fetch->{lang} eq "en");
my $langfield = "txt02";#default to en
$langfield = "txt01" if($fetch->{lang} eq "de");
$langfield = "txt03" if($fetch->{lang} eq "fr");
my $sql = "SELECT ct_name, coalesce($langfield, txt01) AS txt FROM contentuser, relation where template_id=194 and c_id=content_id";
my $sql = "SELECT ct_name, coalesce($langfield, txt02) AS txt FROM contentuser, relation where template_id=194 and c_id=content_id";
my $sth = $dbh->prepare($sql);
my $rc = $sth->execute();
@ -1463,6 +1463,7 @@ sub insert_pos(){
my $from_main_id = $ct->{main_id} || 0;
my $from_template_id = $ct->{template_id} || 0;
my $station = $ct->{int04} || 0;
my $fibumark = $ct->{int16} || 0;
my $rabatt = 0;
my $unit_price = $ct->{int02} || 0;#article price
@ -1499,7 +1500,7 @@ sub insert_pos(){
if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int01,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,template_id,int13,owner,int07,txt04,int09,int17,int15,int11,int18,int19,txt17,txt18,int20,int25,int29,int34,txt22,txt11,int35,int36,int37,int42,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','1','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$from_template_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','1','$trackon','$bike_type_id','$staff','$sig_book->{bikeId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$aa_station','$unit_time','$free_time') RETURNING c_id");
}else{
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int01,int02,int03,txt01,txt06,txt07,int10,int12,int16,template_id,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$user_name','$ctadr->{txt09}',now(),'1','$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$ct->{int16}','$from_template_id','$owner') RETURNING c_id");
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int01,int02,int03,txt01,txt06,txt07,int10,int12,int16,template_id,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$user_name','$ctadr->{txt09}',now(),'1','$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$fibumark','$from_template_id','$owner') RETURNING c_id");
}
my $rows = $sth->execute();
my $last_id;

View file

@ -99,7 +99,8 @@ sub handler {
exit 0;
}
my $lang = "de";
my $lang = "en";
$lang = lc($R::lang) if($R::lang);
my $dyn_js = "";
my $users_dms = {};
my $users_sharee = {};
@ -175,10 +176,10 @@ sub handler {
}
if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($R::lang) });
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($lang) });
}else{
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($R::lang) });
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($lang) });
}
#Save anyway on create ... and hopefully delete it later
@ -792,7 +793,7 @@ sub handler {
$title .= " devel" if($dbt->{copri_conf}->{stage} eq "test");
my $html5 = $q->start_html(-title=>"$title",
-lang=>'de',
-lang=>"$lang",
-onload=>"$onload",
-oncontextmenu=>"$oncontextmenu",
-encoding=>"$html_charset",
@ -837,7 +838,7 @@ sub handler {
);
# CGI.pm doesn't support HTML5 DTD; replace the one it puts in.
$html5 =~ s{<!DOCTYPE.*?>}{<!DOCTYPE html>}s;
$html5 =~ s{<html.*?>}{<html lang='de'>}s;
$html5 =~ s{<html.*?>}{<html lang='$lang'>}s;
print $html5;
print $q->div({-style=>'background-color:black;color:white;'},"<noscript>JavaScript is off. Please enable to view full site.</noscript>"),"\n";

View file

@ -265,7 +265,7 @@ sub tpl(){
if($key =~ /time/){
$size="10px";
print $q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_$key",-override=>'1', -default=>"$start_date_time",-size=>"$size",-maxlength=>20), "-", $q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_$key",-override=>'1',-default=>"$end_date_time",-size=>"$size",-maxlength=>20),"\n";
print $q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_$key",-override=>'1', -default=>"$start_date_time",-size=>"$size",-maxlength=>20), " < ", $q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_$key",-override=>'1',-default=>"$end_date_time",-size=>"$size",-maxlength=>20),"\n";
}
elsif($key =~ /owner/){
print $but->selector_class("$key","eselect","width:80px;",$valxx,@_users),"\n";