mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-11 22:37:27 +02:00
Adding station_type, category and text-cms
This commit is contained in:
parent
47bf368903
commit
cc82e0856a
8 changed files with 136 additions and 40 deletions
|
@ -1486,7 +1486,7 @@ sub smartlock {
|
|||
#only by system=Ilockit
|
||||
if($record_pos->{int11} eq "2" && $q->param('voltage') && $q->param('voltage') =~ /(\d+)/){
|
||||
$update_cc->{int14} = $1;
|
||||
$self->service_automatic($q,"") if($1 <= 50);
|
||||
$self->service_automatic($q,"") if($1 <= 60);
|
||||
}
|
||||
|
||||
my $update_pos = {
|
||||
|
@ -1813,6 +1813,7 @@ sub bikes_available(){
|
|||
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
|
||||
(my $bike_group,my $bike_node,my $user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
|
||||
|
||||
$bw->log("$varenv->{dbname} bikes_available bike_group:",$bike_group,"");
|
||||
#print Dumper($bike_group);
|
||||
#print Dumper($bike_node);
|
||||
my $main_ids = join(",",@{$bike_node});
|
||||
|
@ -2120,7 +2121,7 @@ sub stations_available(){
|
|||
my $authcookie = $q->param('authcookie') || $q->cookie('domcookie');
|
||||
my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$authcookie,$cachme);
|
||||
|
||||
$bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");
|
||||
#$bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");
|
||||
|
||||
#station_group and bike_group alias bike nodes.type_id
|
||||
my $station_group = "";
|
||||
|
@ -2228,6 +2229,30 @@ sub stations_available(){
|
|||
$return->{$id}->{description} = "$description";
|
||||
$return->{$id}->{state} = "$dbt->{copri_conf}->{bike_state}->{$record->{$id}->{int10}}";
|
||||
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
|
||||
|
||||
#new station category
|
||||
#defaults
|
||||
$return->{$id}->{station_type} = {};
|
||||
my @station_group = ();
|
||||
if($record->{$id}->{txt25} && $record->{$id}->{txt25} =~ /\d\s\d/){
|
||||
@station_group = split(/\s/,$record->{$id}->{txt25});
|
||||
}elsif($record->{$id}->{txt25}){
|
||||
@station_group = ("$record->{$id}->{txt25}");
|
||||
}
|
||||
foreach(@station_group){
|
||||
if($_ && $dbt->{copri_conf}->{type_id}->{$_}){
|
||||
$return->{$id}->{station_type}->{$dbt->{copri_conf}->{type_id}->{$_}}->{bike_group} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$_";
|
||||
my $bike_count2 = 0;
|
||||
foreach my $b_id (keys (%$record_bikes)){
|
||||
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
|
||||
$bike_count2++ if($_ == $record_bikes->{$b_id}->{type_id});
|
||||
}
|
||||
}
|
||||
$return->{$id}->{station_type}->{$dbt->{copri_conf}->{type_id}->{$_}}->{bike_count} = "$bike_count2";
|
||||
}
|
||||
}
|
||||
|
||||
#deprecated
|
||||
$return->{$id}->{station_group} = "";
|
||||
if($record->{$id}->{txt25}){
|
||||
$record->{$id}->{txt25} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
|
||||
|
@ -2527,7 +2552,7 @@ sub fetch_tariff(){
|
|||
}
|
||||
#else select all available user tarif entries
|
||||
$tariff_all = $dbt->fetch_record($dbh,$tariff);
|
||||
$bw->log("$dbname Tariff type for operator registered user by int18:$tariff->{int18} select 4:",$tariff_all,"");
|
||||
$bw->log("$dbname Tariff type for operator registered user with Tarif $auth_operator->{txt30} by int18:$tariff->{int18} select 4:",$tariff_all,"");
|
||||
}
|
||||
#end operators address
|
||||
else{
|
||||
|
@ -2546,12 +2571,14 @@ sub fetch_tariff(){
|
|||
|
||||
if($auth_operator->{txt30} && $auth_operator->{txt30} =~ /\d\s\d/){
|
||||
%tarif_hash = map { $_ => 1 } split(/\s+/,$auth_operator->{txt30});
|
||||
}elsif($auth_operator->{txt30}){
|
||||
$tarif_hash{$auth_operator->{txt30}} = 1;
|
||||
}elsif($auth_operator->{txt30} && $auth_operator->{txt30} =~ /(\d+)/){
|
||||
$tarif_hash{$1} = 1;
|
||||
}
|
||||
|
||||
|
||||
if(ref($tariff_all) eq "HASH"){
|
||||
foreach my $rid (keys (%$tariff_all)){
|
||||
#$bw->log("$dbname Tariff hash $auth_operator->{txt30}|$tariff_all->{$rid}->{barcode} --> $tarif_hash{$tariff_all->{$rid}->{barcode}}",\%tarif_hash,"");
|
||||
if(ref(\%tarif_hash) eq "HASH" && $tarif_hash{$tariff_all->{$rid}->{barcode}}){
|
||||
foreach my $tk (keys(%tarif_hash)){
|
||||
$bw->log("Tarif FOUND condition: $tk && $rid && $tariff_all->{$rid}->{barcode} == $tk","","");
|
||||
|
|
|
@ -96,8 +96,8 @@ sub loop_sharees {
|
|||
my %prim_tarif_hash = ();
|
||||
if($authraw->{txt30} =~ /\w\s\w/){
|
||||
%prim_tarif_hash = map { $_ => 1 } split(/\s+/,$authraw->{txt30});
|
||||
}elsif($authraw->{txt30}){
|
||||
$prim_tarif_hash{$authraw->{txt30}} = 1;
|
||||
}elsif($authraw->{txt30} && $authraw->{txt30} =~ /(\w+)/){
|
||||
$prim_tarif_hash{$1} = 1;
|
||||
}
|
||||
foreach my $optarif (keys(%prim_tarif_hash)){
|
||||
my $op_key = "";
|
||||
|
|
|
@ -94,6 +94,13 @@ my $response = {
|
|||
}
|
||||
};
|
||||
|
||||
if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){
|
||||
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($R::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) });
|
||||
}
|
||||
|
||||
my $aowner = 0;
|
||||
my $coo = $q->param('authcookie') || $q->param('sessionid') || "";
|
||||
if(!$coo && !$q->param('merchant_id')){
|
||||
|
@ -478,7 +485,7 @@ elsif($q->param('request') eq "bikes_available"){
|
|||
my $authraw = {};
|
||||
($auth,$authraw) = $apif->auth_verify($q,"","",1);
|
||||
$response = { %$response, %$auth };
|
||||
#$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
|
||||
#$bw->log("Y bikes_available $varenv{dbname} by c_id $authraw->{c_id}, Tarif: $authraw->{txt30}",$authraw->{txt30},"");
|
||||
|
||||
if($varenv{syshost} eq "shareeapp-sx"){
|
||||
($response->{bikes},my $return2copri->{bikes}) = $si->sig_available($q,\%varenv,$authraw);
|
||||
|
@ -683,17 +690,11 @@ elsif($q->param('request') eq "stations_available"){
|
|||
#App update message
|
||||
if($user_agent_subversion <= 348){
|
||||
if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
|
||||
my $pref_ctu = {
|
||||
table => "contentuser",
|
||||
fetch => "one",
|
||||
ct_name => "App-update-message",
|
||||
};
|
||||
my $uadr = { c_id => 0 };
|
||||
$uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
|
||||
$response->{merchant_message} = $uadr->{txt01};
|
||||
$response->{merchant_message} = $uadr->{txt02} if($q->param('lang') eq "en");
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,6 +921,8 @@ elsif($q->param('request') eq "service_done"){
|
|||
|
||||
($response_work, $node) = $apif->service_work($pos_record,$stations_allraw,"",$node_template);
|
||||
}
|
||||
#should not be mandatory here, maybe only for bike_count
|
||||
#$apif->stations_caching($q,\%varenv,$authraw);
|
||||
|
||||
#inject oprefix
|
||||
my $op_response_work = {};
|
||||
|
|
|
@ -684,6 +684,24 @@ sub collect_post(){
|
|||
return $record;
|
||||
}
|
||||
|
||||
#fetch CMS
|
||||
#coalesce works only on null values
|
||||
sub fetch_cms(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $fetch = shift;
|
||||
|
||||
my $langfield = "txt01";
|
||||
$langfield = "txt02" if($fetch->{lang} eq "en");
|
||||
$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 $sth = $dbh->prepare($sql);
|
||||
my $rc = $sth->execute();
|
||||
|
||||
my $record = $sth->fetchall_hashref('ct_name');
|
||||
return $record;
|
||||
}#end fetch_cms
|
||||
|
||||
#fetch all|one content + relation + nodes
|
||||
sub fetch_record(){
|
||||
my $self = shift;
|
||||
|
@ -803,7 +821,7 @@ sub fetch_tablerecord(){
|
|||
$where .= " and $key $op $value";
|
||||
}elsif($key =~ /time$/ && $value){
|
||||
$where .= " and $key $op '$value'";
|
||||
}elsif($key =~ /^(c_id|u_id|ct_id|ca_id|barcode|int\d+|owner|template_id)$/ && (looks_like_number($value) || $value eq "null")){
|
||||
}elsif($key =~ /^(c_id|u_id|cc_id|ct_id|ca_id|barcode|int\d+|owner|template_id)$/ && (looks_like_number($value) || $value eq "null")){
|
||||
if($value eq "null"){
|
||||
$where .= " and ($key is null OR $key = 0)";
|
||||
}elsif($value eq "nullOR1"){
|
||||
|
|
|
@ -16,18 +16,14 @@ use DBI;
|
|||
use Apache2::RequestUtil ();
|
||||
use Apache2::RequestIO ();
|
||||
use Apache2::Const -compile => qw(OK);
|
||||
use LWP::UserAgent;
|
||||
use Digest::MD5 qw(md5 md5_hex);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
#use Encode;
|
||||
#use URI::Encode qw(uri_encode uri_decode);
|
||||
|
||||
use Lib::Config;
|
||||
use Mod::Buttons;
|
||||
use Mod::Prelogic;
|
||||
use Lib::Mlogic;
|
||||
use Mod::Basework;
|
||||
#use Mod::Premain;
|
||||
use Mod::DBtank;
|
||||
use Mod::Libenzdb;
|
||||
use Mod::APIfunc;
|
||||
|
@ -46,7 +42,6 @@ sub handler {
|
|||
my $ml = new Mlogic;
|
||||
my $bw = new Basework;
|
||||
my $pre = new Prelogic;
|
||||
#my $pm = new Premain;
|
||||
my $tk = new Shareework;
|
||||
my $dbt = new DBtank;
|
||||
my $db = new Libenzdb;
|
||||
|
@ -77,6 +72,7 @@ sub handler {
|
|||
d_rows => 0,
|
||||
};
|
||||
|
||||
|
||||
#$mode is used to set GUI features like "maintainer" contextmenue
|
||||
my $modes = $dbt->{shareedms_conf}->{modes};
|
||||
my $mode = "";
|
||||
|
@ -173,6 +169,12 @@ sub handler {
|
|||
$users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'");
|
||||
}
|
||||
|
||||
if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){
|
||||
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($R::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) });
|
||||
}
|
||||
|
||||
#Save anyway on create ... and hopefully delete it later
|
||||
if($R::sharee_edit && $R::sharee_edit =~ /create_account/ && $R::txt04 && $R::txt04 =~ /\w+/ && $R::txt08 && $R::txt08 =~ /\w+\@\w+/){
|
||||
|
|
|
@ -183,6 +183,8 @@ sub save_content {
|
|||
}else{
|
||||
$feedb->{message} = "failure::Eingabefehler \"$valxx\", hier sind nur numerische Werte erlaubt";
|
||||
}
|
||||
}elsif($node_meta->{template_id} == 194 && $_ =~ /txt/ && !$valxx){
|
||||
$update_ct->{$_} = "null";#important for coalesce select alias lang fallback
|
||||
}elsif($_ =~ /ct_name|txt|state|time/){
|
||||
$update_ct->{$_} = "$valxx";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue