Service-Config refactoring

This commit is contained in:
ragu 2022-05-09 12:45:01 +02:00
parent 0f89b9e836
commit 0163c06893
15 changed files with 149 additions and 107 deletions

View file

@ -876,15 +876,12 @@ sub booking_request(){
my $sig_book = shift || {};
my $dbh = "";
my $bike_id = "";
$bike_id = $1 if($bike_id =~ /(\d+)$/);
my $pos_id="";
my $now_dt = strftime "%Y-%m-%d %H:%M", localtime;
my $response_state = "OK";
my $response_text = "";
$bw->log("booking_request ct_bike $ct_bike->{barcode}, auth $auth->{c_id}, tarif $ct_tariff->{barcode}, requested bike:",$bike,"");
$bw->log("booking_request bike $bike, auth $auth->{c_id}, tarif $ct_tariff->{barcode}, requested bike:",$bike,"");
my $update_adr = {
table => "contentadr",
@ -904,14 +901,6 @@ sub booking_request(){
close_time => "is::null",
};
my $booking_pos = {
table => "contenttranspos",
fetch => "one",
barcode => "$bike_id",
int10 => "IN::('2','3')",
ca_id => "$auth->{c_id}",
};
#if bike and tariff
if($ct_bike->{barcode} && $ct_tariff->{barcode}){
@ -1020,6 +1009,7 @@ sub booking_update(){
$bike_id =~ s/S[1-9]X/SX/;
$bike_id = $1 if($bike_id =~ /(\d+)/);
my $state_key = 0;
my $state_text = "";
while (my ($key, $value) = each %{ $dbt->{copri_conf}->{bike_state} }) {
@ -1064,6 +1054,7 @@ sub booking_update(){
my $record_cc = $dbt->fetch_record($dbh,$pref_cc) if($q->param('bike'));
$bw->log("booking_update bike to state $bike $state ($state_key) $lock_state, auth $auth->{c_id}, bike:",$bike,"");
my $update_cc = {
table => "content",
@ -1108,7 +1099,8 @@ sub booking_update(){
#2020-09-24 requested will be all done by net_booking
#6 = "canceled"|3 = "occupied"|1 = "available"
if($state && $state =~ /$dbt->{copri_conf}->{bike_state}->{6}|$dbt->{copri_conf}->{bike_state}->{3}|$dbt->{copri_conf}->{bike_state}->{1}/ && $record_pos->{cc_id} && $record_pos->{cc_id} > 0){
#if($state && $state =~ /$dbt->{copri_conf}->{bike_state}->{6}|$dbt->{copri_conf}->{bike_state}->{3}|$dbt->{copri_conf}->{bike_state}->{1}/ && $record_pos->{cc_id} && $record_pos->{cc_id} > 0){
if($state_key && ($state_key == 6 || $state_key == 3 || $state_key == 1) && $record_pos->{cc_id} && $record_pos->{cc_id} > 0){
#set rent state if lock_system 2=Ilockit || 3=sigo
if($record_pos->{int11} && ($record_pos->{int11} == 2 || $record_pos->{int11} == 3)){

View file

@ -65,6 +65,12 @@ sub handler {
$bw->log("APIxmlserver request:\n--> user-agent '$user_agent'",$q,"");
print $q->header(-type => "application/xml", -charset => "utf-8", -'Access-Control-Allow-Origin' => "*");
open(FILE,">>$varenv{logdir}/APIxmlserver.log") if($debug);
print FILE "\n*** $now_dt user-agent: '$user_agent' to syshost: $varenv{syshost}\n" if($debug);
print FILE "<=== q dump\n " . Dumper($q) . "\n" if($debug);
print FILE "<=== DUMP postdata:\n " . Dumper($q->param('POSTDATA')) . "\n" if($debug);
#print "Content-type: text/xml\n\n";
if($q->param('POSTDATA')){
my $xmlref = {};
@ -111,6 +117,8 @@ sub handler {
my $c_id = "";
$bw->log("$xmlref->{todo}",$xmlref,"");
print FILE "xmlref\n " . Dumper($xmlref) . "\n" if($debug);
if($xmlref->{userID} && $xmlref->{emailID} && $xmlref->{pwID}){
if($xmlref->{todo} =~ /add_LVuser|update_LVuser/ && !$record->{c_id} && !$record_e->{c_id}){
@ -152,7 +160,7 @@ sub handler {
table => "contentadr",
mtime => 'now()',
owner => "$owner",
int01 => "$xmlref->{userID}"
int01 => $q->escapeHTML($xmlref->{userID}),
};
my $rows = $dbt->update_record($dbh,$update,$record);
@ -208,6 +216,7 @@ sub handler {
};
$bw->log("APIxmlserver update to available",$update_cc,"");
print FILE "update_cc\n " . Dumper($update_cc) . "\n" if($debug);
$dbt->update_record($dbh,$update_cc,$record_cc) if($record_cc->{c_id});
}elsif(ref($xmlref) eq "HASH" && $xmlref->{todo} && $xmlref->{todo} eq "requested" && $xmlref->{bikeID} =~ /\d+/){
@ -229,6 +238,7 @@ sub handler {
print "<text>NO DATA</text>";
}
close(FILE) if($debug);
return Apache2::Const::OK;
}
1;

View file

@ -43,7 +43,7 @@ sub ibuttons(){
'new_relation' => 'NEUES Menue anlegen',
'new_relation4sub' => 'NEUES Sub-Menue anlegen',
'save_content' => 'Speichern',
'save_tver' => 'Kurs speichern',
'save_ctuser' => 'Save',
'save_nel' => 'Nachricht speichern',
'context_copy_content' => 'Kopie im Kontext der internen Barcode Nummer',
'copy_content' => 'Kopie fuer neuen Datensatz',

View file

@ -1007,8 +1007,6 @@ sub insert_contentoid {
$values .= "'$insert->{$key}',";
}
}
#elsif($key =~ /contentadr_id|cc_id|ct_id|barcode|txt|int|time|owner/){
#2021-03-04 changed with c_id, ct_name and only insert if value
elsif($key =~ /^c_id|ct_name|barcode|txt|int|time|owner/ && ($insert->{$key} || looks_like_number($insert->{$key}))){
$columns .= "$key,";
if($key =~ /_id|barcode|int|owner/ && !looks_like_number($insert->{$key})){
@ -1035,12 +1033,12 @@ sub insert_contentoid {
my $c_id = $sth->fetchrow_array();
$bw->log("insert_contentoid $source c_id: $c_id",$sql,"") if($debug);
if($insert->{table} =~ /content$|contentadr|contenttrans$|contenttver$|contentusers$/ && $insert->{main_id} && $insert->{template_id}){
if($insert->{table} =~ /content$|contentadr|contenttrans$|contenttver$|contentuser$/ && $insert->{main_id} && $insert->{template_id}){
my $foreignkey = "";
$foreignkey = "ca_id" if($insert->{table} eq "contentadr");
$foreignkey = "cc_id" if($insert->{table} eq "content");
$foreignkey = "ct_id" if($insert->{table} eq "contenttrans");
$foreignkey = "cu_id" if($insert->{table} eq "contentusers");
$foreignkey = "cu_id" if($insert->{table} eq "contentuser");
$foreignkey = "cv_id" if($insert->{table} eq "contenttver");
my $sql_rel = "INSERT INTO relation (main_id,content_id,template_id,change,$foreignkey) VALUES('$insert->{main_id}','$c_id','$insert->{template_id}','now()','$c_id')";
my $sth3 = $dbh->prepare($sql_rel);

View file

@ -88,7 +88,7 @@ sub handler {
}elsif($netloc =~ /lastenradbayern\.net/){
$varenv{syshost} = "shareeweb-bayern";
}
die "no configuration available" if(!$varenv{syshost});
exit 0 if(!$varenv{syshost});
if($varenv{orga} ne "dms" && $path =~ /DMS|Waren|Kunden\/|Einstellung|journal|Faktur/i){
@ -352,6 +352,9 @@ sub handler {
$return = $pl->delete_relation($R::main_id,$users_dms->{u_id});
}elsif($R::rel_edit eq "new_relation" && $R::main_id && $R::main_id >= 200000){
$return = $pl->new_relation($R::main_id,$users_dms->{u_id});
}elsif($R::rel_edit eq "save_ctuser" && $R::main_id && $R::main_id >= 200000){
$return = "failure::TODO Service-Config save";
#$return = $pl->save_ctuser($users_dms);
}elsif($R::rel_edit && $R::main_id && $R::main_id >= 200000){
$return = $pm->maininit($users_dms);
}
@ -738,12 +741,17 @@ sub handler {
});";
}
my $favicon = "css/favicon.ico";
my $base_uri = "true";
my $title = "";
$title = $dbt->{primary}->{$varenv{dbname}}->{title} if($dbt->{primary}->{$varenv{dbname}}->{title});
$title = $dbt->{operator}->{$varenv{dbname}}->{title} if($dbt->{operator}->{$varenv{dbname}}->{title});
$title = $dbt->{website}->{$varenv{syshost}}->{title} if($dbt->{website}->{$varenv{syshost}}->{title});
if($dbt->{website}->{$varenv{syshost}}->{title}){
$title = $dbt->{website}->{$varenv{syshost}}->{title};
$favicon = "data/favicon.ico";
}
$title .= " devel" if($dbt->{copri_conf}->{stage} eq "test");
my $html5 = $q->start_html(-title=>"$title",
-lang=>'de',
-onload=>"$onload",
@ -755,7 +763,7 @@ sub handler {
Link({
-rel=>'shortcut icon',
-type=>'image/x-icon',
-href=>"$varenv{metahost}/css/favicon.ico"
-href=>"$varenv{metahost}/$favicon"
})
],
-meta=>{

View file

@ -32,20 +32,34 @@ my $bw = new Basework;
sub handler {
my $r = shift;
my $q = new CGI;
$q->import_names('R');
my $dbt = new DBtank;
my $apif = new APIfunc;
my $cf = new Config;
my %varenv = $cf->envonline();
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
my $coo = $q->cookie('domcookie') || $R::sessionid || "";
my $users_sharee = { c_id => 0 };
my $api_return = { authcookie => '' };
($api_return,$users_sharee) = $apif->auth_verify($q,$coo,"");
if($dbt->{website}->{$varenv{syshost}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{website}->{$varenv{syshost}}->{merchant_id} if(!$api_return->{authcookie});
}elsif($dbt->{operator}->{$varenv{dbname}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{operator}->{$varenv{dbname}}->{merchant_id} if(!$api_return->{authcookie});
}elsif($dbt->{primary}->{$varenv{dbname}}->{merchant_id}){
$api_return->{authcookie} = $dbt->{primary}->{$varenv{dbname}}->{merchant_id} if(!$api_return->{authcookie});
}
$users_sharee->{c_id} = "0" if(!$users_sharee->{c_id});
$bw->log("kmlGenerator handler with api_return: ",$api_return,"");
my $kmlfile = kmlGenerator($api_return,\%varenv,$users_sharee);
#print out test with kml file
if(1==2){
#print $q->header();
#print out kml file, used by Karte.pm js maps
if(1==1){
print $q->header(-type => "application/vnd.google-earth.kml+xml", -charset=>"utf-8");
if (open(my $fh, '<', "$varenv{basedir}/xml/$kmlfile")) {
@ -68,12 +82,9 @@ sub kmlGenerator {
my $dbt = new DBtank;
my $json = JSON->new->allow_nonref;
my $cf = new Config;
#my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $lang="de";
my $dbh = "";
#my $netloc = $q->url(-base=>1);
#print "kmlGenerator accessed by netlocation: " . $netloc;
my $project = "all";
$project = $dbt->{website}->{$varenv->{syshost}}->{project} if($dbt->{website}->{$varenv->{syshost}}->{project});
$project = $dbt->{operator}->{$varenv->{dbname}}->{project} if($dbt->{operator}->{$varenv->{dbname}}->{project});

View file

@ -205,7 +205,7 @@ sub new_relation {
my $new_submain_id = $dbt->get_freenode($dbh,$prefix_id);
my $new_subtemplate_id = $dbt->get_freetpl($dbh,"401","499");
my $ret_tpl_id = $dbt->copy_template($dbh,"401",$new_subtemplate_id,$owner);
my $ret_tpl_id = $dbt->copy_template($dbh,"400",$new_subtemplate_id,$owner);
my $insert_sub = {
main_id => $new_submain_id,

View file

@ -424,7 +424,7 @@ print ATTR "next: $next\n" if($debug);
#if($ib_key =~ /save/ && $R::c_id && $R::rel_id){
my $c_id = $R::c_id || $c_idnew;#also over new
my $rel_id = $R::rel_id || $rel_idnew;#also over new
if(($ib_key =~ /save_content|save_user|save_adr|save_nel|newsletter_mailman/) || ($ib_key =~ /new_content/ && $R::search_pattern) && $c_id){
if(($ib_key =~ /save_content|save_ctuser|save_adr/) || ($ib_key =~ /new_content/ && $R::search_pattern) && $c_id){
if($ib_key eq "save_user"){
$table = "contentuser";