diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index ffe896c..a691c2e 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -965,7 +965,7 @@ sub booking_request(){ if($pos_id){ $response_state = "OK, bike " . $bike . " succesfully requested"; - $response_text = "Fahrrad Nr. $bike wurde erfolgreich für 15 Min. reserviert"; + $response_text = "Rad $bike wurde erfolgreich für 15 Min. reserviert"; $bw->log("booking_request insert contenttranspos pos_id: $pos_id\n","",""); my $update_ctt = { @@ -1088,7 +1088,7 @@ sub booking_update(){ }; $record_pos = $dbt->fetch_tablerecord($dbh,$booking_pos) if($bike_id > 0 && $auth->{c_id} > 0); if(!$record_pos->{c_id}){ - $booking_values->{response_state} = "Failure 758: Can not find bike " . $q->param('bike') . " rental or reservation"; + $booking_values->{response_state} = "Failure 758: Can not find bike " . $q->param('bike') . " rental or reservation on varenv-dbname: $varenv->{dbname}"; $booking_values->{response_text} = "Keine Miete oder Reservierung zu Rad " . $q->param('bike') . " gefunden."; } @@ -1192,11 +1192,11 @@ sub booking_update(){ $update_cc->{int10} = 1 if($record_cc->{int10} == 2);#only if still requested $booking_values->{response_state} = "OK: canceled bike " . $q->param('bike'); - $booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " wurde erfolgreich storniert"; + $booking_values->{response_text} = "Rad " . $q->param('bike') . " wurde erfolgreich storniert"; $booking_values->{state} = "available"; }else{ $booking_values->{response_state} = "Failure 2002: cancel bike " . $q->param('bike') . " fails, bike not requested"; - $booking_values->{response_text} = "Keine Reservierung zu Fahrrad Nr. " . $q->param('bike') . " gefunden."; + $booking_values->{response_text} = "Keine Reservierung zu Rad " . $q->param('bike') . " gefunden."; } }else{ @@ -1221,7 +1221,7 @@ sub booking_update(){ if($rows > 0){ $booking_values->{response_state} = "OK: occupied bike " . $q->param('bike'); - $booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " Miete gestartet. "; + $booking_values->{response_text} = "Rad " . $q->param('bike') . " Miete gestartet. "; $update_cc->{int10} = 3; #$update_cc->{int04} = "null";#Because of servicetool, we hav to be keep the station } @@ -1295,7 +1295,7 @@ sub booking_update(){ if($rows_end > 0){ $update_cc->{int10} = 1; $booking_values->{response_state} = "OK: available bike " . $q->param('bike'); - $booking_values->{response_text} = "Danke! Die Miete Fahrrad Nr. " . $q->param('bike') . " wurde beendet."; + $booking_values->{response_text} = "Danke! Die Miete Rad " . $q->param('bike') . " wurde beendet."; } $geo_debug .= "Matching station: $stations_raw->{$id}->{barcode}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $gps_data->{geo_distance} Meter\n"; @@ -1351,23 +1351,23 @@ sub booking_update(){ }elsif($record_pos->{int11} != 3){ if(!$gps_data->{gps}){ $booking_values->{response_state} = "Failure 2245: No GPS data, state change forbidden."; - $booking_values->{response_text} = "Fehler! Keine GPS Standortdaten, Die Miete Fahrrad Nr. " . $q->param('bike') . " kann wegen fehlendem GPS nicht $state_text werden. Bitte aktivieren Sie das GPS."; + $booking_values->{response_text} = "Fehler! Keine GPS Standortdaten, Die Miete Rad " . $q->param('bike') . " kann wegen fehlendem GPS nicht $state_text werden. Bitte aktivieren Sie das GPS."; }else{ $booking_values->{response_state} = "Failure 2246: GPS age with $gps_data->{gps_age_minutes} minutes too old, state change forbidden."; - $booking_values->{response_text} = "Fehler! GPS Daten sind mit $gps_data->{gps_age_minutes} Minuten zu alt. Die Miete Fahrrad Nr. " . $q->param('bike') . " kann aufgrund nicht aktueller GPS nicht $state_text werden. Bitte aktivieren Sie das GPS."; + $booking_values->{response_text} = "Fehler! GPS Daten sind mit $gps_data->{gps_age_minutes} Minuten zu alt. Die Miete Rad " . $q->param('bike') . " kann aufgrund nicht aktueller GPS nicht $state_text werden. Bitte aktivieren Sie das GPS."; } } #end if($state eq "available" && $record_pos.state eq occupied || $record_pos.lock_state ne locked }elsif($state_key == 6 && ($record_pos->{int10} == 3 || $record_pos->{int20} != 1)){ $booking_values->{response_state} = "Failure 2012: occupied bike " . $q->param('bike') . " cannot be state $state and $lock_state"; - $booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " ist in Benutzung und kann somit nicht storniert werden."; + $booking_values->{response_text} = "Rad " . $q->param('bike') . " ist in Benutzung und kann somit nicht storniert werden."; }elsif($state_key == 3 && $record_pos->{int10} == 1){ $booking_values->{response_state} = "Failure 2016: available bike " . $q->param('bike') . " have to be at first reserved, thats because cannot be $state"; - $booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " wurde nicht reserviert und kann somit nicht gemietet werden."; + $booking_values->{response_text} = "Rad " . $q->param('bike') . " wurde nicht reserviert und kann somit nicht gemietet werden."; }else{ $booking_values->{response_state} = "Failure 2035: bike " . $q->param('bike') . " state change to state $state and $lock_state not possible."; - $booking_values->{response_text} = "Fehler! Die Miete Fahrrad Nr. " . $q->param('bike') . " kann nicht mit dem vorhandenen Status $state_text werden."; + $booking_values->{response_text} = "Fehler! Der Mietstatus zu Rad " . $q->param('bike') . " kann mit dem vorhandenen Status \"state:$state and lock_state:$lock_state\" nicht geändert werden."; } #contenttrans @@ -1555,21 +1555,21 @@ sub smartlock { $update_pos->{int22} = $gps_data->{gps_accuracy}; $update_pos->{int23} = "null";# only computed on rental-end $booking_values->{response_state} = "OK: bike " . $q->param('bike') . " locked confirmed. "; - $booking_values->{response_text} = "Abschließen von Fahrrad Nr. " . $q->param('bike') . " bestätigt. "; + $booking_values->{response_text} = "Schloss schließen von Rad " . $q->param('bike') . " bestätigt. "; }elsif($q->param('lock_state') eq "unlocked"){ $lock_value = 2; $update_cc->{int20} = "$lock_value"; $update_pos->{int20} = "$lock_value"; $booking_values->{response_state} = "OK: bike " . $q->param('bike') . " unlocked confirmed. "; - $booking_values->{response_text} = "Aufschließen von Fahrrad Nr. " . $q->param('bike') . " bestätigt. "; + $booking_values->{response_text} = "Schloss öffnen von Rad " . $q->param('bike') . " bestätigt. "; }elsif($q->param('lock_state') eq "locking"){ $lock_value = 3; $update_cc->{int20} = "$lock_value"; $update_pos->{int20} = "$lock_value"; $booking_values->{response_state} = "OK: bike " . $q->param('bike') . " locking in progress. "; - $booking_values->{response_text} = "Abschließen von Fahrrad Nr. " . $q->param('bike') . " ist im Prozess. Bitte warten bis das smartlock vollständig geschlossen wurde und das abschließen bestätigt wird. "; + $booking_values->{response_text} = "Schloss schließen von Rad " . $q->param('bike') . " ist im Prozess. Bitte warten bis das smartlock vollständig geschlossen wurde und das Schloss schließen bestätigt wird. "; if($varenv->{dbname} ne "sharee_lv" && !$record_pos->{int32}){ $bw->log("$varenv->{basedir}/src/scripts/sms_message.pl $varenv->{syshost} locking_progress $auth->{c_id} $record_pos->{c_id}",$record_pos->{c_id},""); system("$varenv->{basedir}/src/scripts/sms_message.pl $varenv->{syshost} locking_progress $auth->{c_id} $record_pos->{c_id} &"); @@ -1580,7 +1580,7 @@ sub smartlock { $update_cc->{int20} = "$lock_value"; $update_pos->{int20} = "$lock_value"; $booking_values->{response_state} = "OK: bike " . $q->param('bike') . " unlocking in progress. "; - $booking_values->{response_text} = "Aufschließen von Fahrrad Nr. " . $q->param('bike') . " ist im Prozess. "; + $booking_values->{response_text} = "Schloss öffnen von Rad " . $q->param('bike') . " ist im Prozess. "; } $dbt->update_record($dbh,$update_pos,$record_pos); @@ -1645,8 +1645,10 @@ sub user_rentals_history(){ my %varenv = $cf->envonline(); my $today = strftime("%Y-%m-%d",localtime(time)); + my %operator_hash = (); my $record_all = {}; + if($auth->{c_id}){ my $pref = { table => "contenttrans", table_pos => "contenttranspos", @@ -1667,7 +1669,6 @@ sub user_rentals_history(){ $pref->{'ct.int14'} = "is::null"; } - my %operator_hash = (); if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){ if($auth->{txt17}){ if($auth->{txt17} =~ /\w\s\w/){ @@ -1684,6 +1685,7 @@ sub user_rentals_history(){ }else{ $record_all = $dbt->collect_post($dbh,$pref); } + } return ($record_all,\%operator_hash); }#end user_rental_history diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index 15def5d..d4ca286 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -408,7 +408,7 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki my $booking_values = {}; #update on sig - if($ctpos->{int11} == 3){ + if($ctpos->{int11} && $ctpos->{int11} == 3){ if($q->param('state') eq "occupied"){ system("$varenv{basedir}/src/scripts/sig_client.pl '$varenv{syshost}' 'rental' '$authraw->{c_id}' '$ctpos->{txt22}' '$ctpos->{c_id}' &"); } @@ -521,13 +521,13 @@ elsif($q->param('request') eq "bikes_available"){ $response->{bikes} = $apif->bikes_available($q,\%varenv,\%varenv,$authraw); } - #return also bikes_occupied on bikes_available by operator request - if(1==1 && $varenv{syshost} ne "shareeapp-primary" && $dbt->{copri_conf}->{betau_id}->{$authraw->{c_id}}){ + #2023-11-13, return also bikes_occupied on bikes_available by operator request + #if(1==1 && $varenv{syshost} ne "shareeapp-primary" && $dbt->{copri_conf}->{betau_id}->{$authraw->{c_id}}){ #return list of occupied/requested bikes my $record = {}; $record = $apif->user_bikes_occupied($dbh,$authraw,""); $response->{bikes_occupied} = $apif->rentals(\%varenv,$record,$authraw,"1");#returns JSON rental values - } + #} } if(ref($response->{bikes}) ne "HASH"){ $response->{response_state} = "Failure 5003: cannot find any user defined bike tariff"; diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index 2b2616c..e1f984e 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -689,21 +689,6 @@ sub collect_post(){ }else{ $cp_where .= " and cp.$key $op '$value'"; } - }elsif($varenv{systype} && $varenv{systype} eq "azn"){ - if($key =~ /^ct\.(contentadr_id|owner|barcode|int\d+)$/ && $value){ - $ct_where .= " and $key $op $value"; - }elsif($key eq "barcode" && $fetch->{fetch} eq "all"){ - if($value =~ /\d-\d/){ - my ($start_val,$end_val) = split(/-/, $value); - $cp_where .= " and (cp.$key >= $start_val AND cp.$key <= $end_val)"; - }else{ - my $start_val = $value . "01"; - my $end_val = $value . "31"; - $cp_where .= " and (cp.$key >= $start_val AND cp.$key <= $end_val)"; - } - }elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){ - $cp_where .= " and cp.$key $op $value"; - } }elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){ if($value eq "null"){ $cp_where .= " and (cp.$key is null OR cp.$key = 0)"; @@ -727,8 +712,7 @@ sub collect_post(){ $sth = $dbh->prepare($sql); }else{ #rental pos with capture booking ct.state - #$sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $poscid IN (SELECT ct.c_id FROM relation rel, $fetch->{table} ct WHERE rel.content_id=ct.c_id and $ct_where) order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry - $sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $ct_where order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry + $sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $ct_where order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry $sth = $dbh->prepare($sql); } $bw->log("DBtank collect_post ",$sql,"") if($debug); @@ -799,7 +783,7 @@ sub fetch_record(){ $where .= " and ct.$key $op '$value'"; } } - if($key =~ /^(c_id|ca_id|barcode|int\d+|owner|contentadr_id)$/){ + if($key =~ /^(c_id|barcode|int\d+|owner)$/){ if(looks_like_number($value) || $value eq "null"){ if($value eq "null"){ $where .= " and (ct.$key is null OR ct.$key = 0)"; @@ -854,7 +838,8 @@ sub fetch_tablerecord(){ my $dbh = shift || $dbh_intern; my ($fetch) = @_; my $where = "where 1=1"; - + my $source = $dbh->get_info( $GetInfoType{SQL_DATABASE_NAME} ); + foreach my $key (keys %$fetch){ if($fetch->{$key}){ $fetch->{$key} =~ s/^\s//g; @@ -913,7 +898,9 @@ sub fetch_tablerecord(){ my $sql = "SELECT * FROM $fetch->{table} $where"; my $sth = $dbh->prepare($sql); my $rc = $sth->execute(); - #$bw->log("DBtank fetch_tablerecord :",$sql,"") if($debug); + + #debug $fetch->{table} eq "contenttranspos" on Failure 758 + $bw->log("DBtank fetch_tablerecord source-dbname $source:",$sql,"") if($debug && $fetch->{table} eq "contenttranspos"); my $record = { c_id => 0 }; if($fetch->{fetch} eq "all" && $fetch->{keyfield}){ @@ -952,11 +939,16 @@ sub update_one(){ my $rows = 0; my $where = ""; - if($c_id){ - $where = "where c_id = $c_id"; - }elsif($update->{c_id}){ - $where = "where c_id = $update->{c_id}"; - } + + if($update->{table} =~ /content/){ + if($c_id){ + $where = "where c_id = $c_id"; + }elsif($update->{c_id}){ + $where = "where c_id = $update->{c_id}"; + }elsif($update->{barcode}){ + $where = "where barcode = $update->{barcode}"; + } + } if($update->{table} eq "users" && $update->{u_id}){ $where = "where u_id = $update->{u_id}"; @@ -1023,7 +1015,7 @@ sub update_record(){ $set .= " $key='$value',"; } } - if($key =~ /^(barcode|contentadr_id|int\d+|time\d+|owner|owner_end|start_at\d+|end_at\d+)$/){ + if($key =~ /^(barcode|int\d+|time\d+|owner|owner_end|start_at\d+|end_at\d+)$/){ $value =~ s/,/\./ if($value); if($key =~ /time\d+|start_at\d+|end_at\d+/ && $value && $value =~ /\d+:\d+/){#azn time format $set .= " $key='$value',"; @@ -1129,16 +1121,8 @@ sub insert_contentoid { foreach my $key (keys(%$insert)){ $insert->{$key} =~ s/^\s//g if($insert->{$key}); $insert->{$key} =~ s/\s$//g if($insert->{$key}); - #because of time format without of looks_like_number - if($varenv{systype} && $varenv{systype} eq "azn" && $insert->{table} eq "contenttverpos" && $key =~ /start_at|end_at|int/){ - $columns .= "$key,"; - if(!$insert->{$key} || $insert->{$key} eq "null"){ - $values .= "null,"; - }else{ - $values .= "'$insert->{$key}',"; - } - } - elsif($key =~ /^c_id|ct_name|barcode|txt|int|time|owner|byte/ && ($insert->{$key} || looks_like_number($insert->{$key}))){ + + if($key =~ /^c_id|ct_name|barcode|txt|int|time|owner|byte/ && ($insert->{$key} || looks_like_number($insert->{$key}))){ $columns .= "$key,"; if($key =~ /_id|barcode|int|owner/ && !looks_like_number($insert->{$key})){ $values .= "null,"; @@ -1212,6 +1196,7 @@ sub collect_transpos { my $self = shift; my $dbh = shift || $dbh_intern; my $search = shift; + my $messaging = shift || 0; $search->{offset} = 0 if(!$search->{offset}); @@ -1235,9 +1220,9 @@ sub collect_transpos { $where .= " and (cp.$key = $search->{$key} OR cp.owner_end = $search->{$key})" if($key eq "owner" && looks_like_number($search->{$key})); $where .= " and (cp.$key is $search->{$key} OR cp.$key = 0)" if($key eq "int34" && $search->{$key} eq "null"); $where .= " and cp.$key ilike '%$search->{$key}%'" if($key eq "txt23" && $search->{$key}); - #logs,debug,agent,HW + #debug,log,device,HW if($key eq "txt24" && $search->{$key}){ - $where .= " and (cp.txt24 ilike '%$search->{txt24}%' OR cp.txt25 ilike '%$search->{txt24}%' OR cp.txt26 ilike '%$search->{txt24}%' OR cp.txt27 ilike '%$search->{txt24}%' OR cp.txt28 ilike '%$search->{txt24}%' OR cp.txt29 ilike '%$search->{txt24}%')"; + $where .= " and (cp.txt24 ilike '%$search->{txt24}%' OR cp.txt25 ilike '%$search->{txt24}%' OR cp.txt26 ilike '%$search->{txt24}%' OR cp.txt21 ilike '%$search->{txt24}%' OR cp.txt27 ilike '%$search->{txt24}%' OR cp.txt28 ilike '%$search->{txt24}%' OR cp.txt29 ilike '%$search->{txt24}%')"; } } @@ -1249,7 +1234,11 @@ sub collect_transpos { } $where .= " ORDER BY cp.c_id DESC LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit}); - my $sql = "SELECT cp.*,ct.txt07 AS phone,ct.txt08 AS email,ct.txt11 AS lang from $search->{table} cp, contenttrans ct $where"; + my $sql = "SELECT cp.* from $search->{table} cp, contenttrans ct $where"; + #for system messaging + if($messaging){ + $sql = "SELECT cp.*,ct.txt07 AS phone,ct.txt08 AS email,ct.txt11 AS lang from $search->{table} cp, contenttrans ct $where"; + } my $sth = $dbh->prepare($sql); my $rc = $sth->execute(); my $ct = $sth->fetchall_hashref("c_id"); @@ -1600,15 +1589,15 @@ sub insert_contenttrans(){ my $ctadr = shift; my $main_id = shift; my $tpl_id = shift; - my $invoice_nr = shift || "----"; + my $invoice_nr = shift || 0; my $owner = shift || 0; my $doc_name = "Rechnung"; + $doc_name = "Tagesabschluss" if($tpl_id == 209); $doc_name = "Prepaid Account" if($tpl_id == 219); $owner="199" if(!$owner); - #int10 will be substituted by ca_id. #keep in mind int10 will be mainly used by Prelogic and Printpreview, thats because we save it also - my $sth = $dbh->prepare("INSERT INTO contenttrans (ct_name,txt00,ca_id,int10,txt02,txt01,txt03,txt06,txt07,txt08,txt10,txt11,owner,itime) VALUES('$invoice_nr','$doc_name','$ctadr->{c_id}','$ctadr->{c_id}','$ctadr->{txt02}','$ctadr->{txt01}','$ctadr->{txt03}','$ctadr->{txt06}','$ctadr->{txt07}','$ctadr->{txt08}','$ctadr->{txt10}','$ctadr->{txt11}','$owner','now()') RETURNING c_id"); + my $sth = $dbh->prepare("INSERT INTO contenttrans (ct_name,txt00,int10,txt02,txt01,txt03,txt06,txt07,txt08,txt10,txt11,owner,itime) VALUES('$invoice_nr','$doc_name','$ctadr->{c_id}','$ctadr->{txt02}','$ctadr->{txt01}','$ctadr->{txt03}','$ctadr->{txt06}','$ctadr->{txt07}','$ctadr->{txt08}','$ctadr->{txt10}','$ctadr->{txt11}','$owner','now()') RETURNING c_id"); my $rows = $sth->execute(); my $last_id; @@ -1928,4 +1917,21 @@ sub count_content(){ return $rows; } +#close transactions by close_trans alias Tagesabschluss +sub update_close_transactions { + my $self = shift; + my $dbh = shift || $dbh_intern; + my $close_ref = shift; + + #close transactions int11 close_trans reference c_id + my $sth = $dbh->prepare("UPDATE $close_ref->{table} SET close_time='now()',int11=$close_ref->{close_id} where c_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and (ct.state ~ '[a-z]') and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.close_time is null and ct.int14 is null)"); + my $rows = $sth->execute(); + + #move/set to journal + $sth = $dbh->prepare("UPDATE relation SET main_id=$close_ref->{main_id}, template_id=$close_ref->{template_id} where template_id=$close_ref->{source_template_id} and content_id IN (SELECT ct.c_id from $close_ref->{table} ct, relation rel where ct.c_id=rel.content_id and (ct.state ~ '[a-z]') and ct.int01 is not null and rel.main_id IN ($close_ref->{source_main_id}) and ct.int14 is null)"); + $rows = $sth->execute(); + + return $rows; +} + 1; diff --git a/copri4/main/src/Mod/Indexsharee.pm b/copri4/main/src/Mod/Indexsharee.pm index d9a2aa9..762e2b0 100755 --- a/copri4/main/src/Mod/Indexsharee.pm +++ b/copri4/main/src/Mod/Indexsharee.pm @@ -20,7 +20,6 @@ use Scalar::Util qw(looks_like_number); use Lib::Config; use Mod::Buttons; -use Mod::Prelogic; use Lib::Mlogic; use Mod::Basework; use Mod::DBtank; @@ -39,13 +38,12 @@ sub handler { my $cf = new Config; my $ml = new Mlogic; my $bw = new Basework; - my $pre = new Prelogic; my $tk = new Shareework; my $dbt = new DBtank; my $apif = new APIfunc; my $but = new Buttons; my $pl = new Prelib; - my $payone = new Payment; + my $pay = new Payment; my %varenv = $cf->envonline(); my $netloc = $q->url(-base=>1); @@ -353,7 +351,7 @@ sub handler { if($users_dms_primary->{u_id} && $users_dms_primary->{int02} == 2 && $users_dms->{u_id} && $users_dms->{int02} == 2){ if($R::c_id && $R::base_edit eq "remove_chk4rel"){ my $delete_key = "delete_adr"; - $return = "failure::Datensatz wirklich löschen. ::?base_edit=$delete_key\&exit_box2=1\&c_id=$R::c_id ::löschen"; + $feedb->{message} = "failure::Datensatz wirklich löschen. ::?base_edit=$delete_key\&exit_box2=1\&c_id=$R::c_id ::löschen"; }elsif($R::c_id && $R::base_edit eq "delete_adr"){ $return = $tk->delete_account($R::c_id,$users_dms->{u_id}); }elsif($R::c_id && $R::base_edit eq "save_adr"){ @@ -448,16 +446,36 @@ sub handler { if($users_dms_primary->{u_id} && $users_dms_primary->{int03} >= 1 && $users_dms->{u_id} && $users_dms->{int03} >= 1 && $R::ct_trans eq "open"){#DMS Faktura read $dbt->update_one($dbh,$update_users,"c_id4trans=$R::c_id4trans,tpl_id4trans=$R::tpl_id4trans") if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans)); + $users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'"); } - if($users_dms_primary->{u_id} && $users_dms_primary->{int03} == 2 && $users_dms->{u_id} && $users_dms->{int03} == 2){#DMS Faktura rw + #DMS Faktura rw + elsif($users_dms_primary->{u_id} && $users_dms_primary->{int03} == 2 && $users_dms->{u_id} && $users_dms->{int03} == 2){ $dbt->update_one($dbh,$update_users,"c_id4trans=$R::c_id4trans,tpl_id4trans=$R::tpl_id4trans") if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans)); - if($R::ct_trans =~ /set_workflow2invoice|set_workflow2storno/){ + $users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'"); + + if($R::ct_trans eq "new_trans" && $node_meta->{main_id} && $node_meta->{main_id} >= 200000){ + $feedb = $pl->new_contenttrans($q,$users_dms,$node_meta); + $dbt->update_one($dbh,$update_users,"c_id4trans=$feedb->{c_id},tpl_id4trans=$feedb->{template_id}") if(looks_like_number($feedb->{c_id}) && looks_like_number($feedb->{template_id})); + $users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'"); + } + elsif($R::ct_trans =~ /set_workflow2invoice|set_workflow2storno/){ $return = $pl->set_workflow($q,$users_dms,$R::c_id4trans,$R::set_main_id4workflow) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans) && looks_like_number($R::set_main_id4workflow)); - }elsif($R::ct_trans =~ /set_accounting2invoice/){ + } + elsif($R::ct_trans =~ /set_accounting2invoice/){ $return = $pl->set_accounting2invoice($q,$users_dms,$R::c_id4trans,$R::set_main_id4workflow) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans) && looks_like_number($R::set_main_id4workflow)); - }elsif($R::ct_trans =~ /save_text|save_adr/){ + } + elsif($R::ct_trans =~ /save_text|save_adr/){ $feedb = $pl->save_text2contenttrans($q,$users_dms,$R::c_id4trans) if(looks_like_number($R::c_id4trans)); } + elsif($R::c_id && $R::ct_trans eq "remove_chk4rel"){ + my $delete_key = "delete_trans"; + $feedb->{message} = "failure::Datensatz wirklich löschen. ::?ct_trans=$delete_key\&exit_box2=1\&c_id=$R::c_id ::löschen"; + } + elsif($R::c_id && $R::ct_trans eq "delete_trans"){ + $feedb = $pl->delete_content($node_meta,$R::c_id); + $dbt->update_one($dbh,$update_users,"c_id4trans=0,tpl_id4trans=0"); + $users_dms = $dbt->select_users($dbh,$users_sharee->{c_id},"and cookie='$coo'"); + } #not used because of attachement elsif($R::ct_trans =~ /email_generate/ && $R::c_id4trans && $R::email_select){ #my $sendref = $pl->prepare_email(\%varenv,$R::c_id4trans,$R::email_select); @@ -469,18 +487,31 @@ sub handler { my $ck4ex = "@R::ck4ex" || ""; $return = $pl->operator_accounting($q,$users_dms,$users_sharee,$R::accounting_type,$ck4ex); } - #on prepaid account - elsif($R::ct_trans eq "save_pos" && $R::tpl_id4trans == 219 && $R::c_idpos){ + #position management in invoices + elsif($R::trans2edit eq "transpos" && $R::select_part){ + $feedb = $pl->insert_contenttranspos($q,$users_dms->{u_id}); + } + elsif($R::ct_trans eq "save_pos" && $R::tpl_id4trans =~ /218|219/ && $R::c_idpos){ $feedb = $pl->save_contenttranspos($q,$R::c_idpos,$users_dms->{u_id}); } - #should do all else invoice text save , without positions and booking payment - elsif($R::ct_trans || $R::set_state || $R::v_abschluss || $R::trans2edit){ - if($R::ct_trans !~ /_pos|open/ && looks_like_number($R::c_id4trans) && !$R::v_abschluss && !$R::trans2edit){ - $feedb = $pl->save_text2contenttrans($q,$users_dms,$R::c_id4trans); - } - #in future the prelogic modul should be disabled at all - $return .= "|"; - $return .= $pre->preinit($q,$node_meta,$users_dms); + elsif($R::ct_trans eq "delete_pos" && $R::c_idpos){ + $feedb = $pl->delete_contenttranspos($q,$R::c_idpos,$users_dms->{u_id}); + } + elsif($R::set_state && $R::c_id4trans){ + $feedb = $pay->book_payment($q,\%varenv,$node_meta,$users_dms); + } + elsif($R::print_pdfview && $R::c_id4trans){ + $feedb = $pay->print_pdf($q,\%varenv,$node_meta,$users_dms,$feedb); + } + elsif($R::send_invoice_cms && $R::cms_message_key && $R::c_id4trans){ + $feedb = $pay->send_invoice_cms($q,\%varenv,$node_meta,$users_dms,$feedb); + } + elsif($R::close_trans){ + $feedb = $pay->close_transactions($q,\%varenv,$node_meta,$users_dms); + if($feedb->{u_rows}){ + print redirect("$varenv{wwwhost}/DMS/Faktura/Verkaufsjournal?redirected=1"); + exit 0; + } } }elsif($R::ct_trans){ $feedb->{message} = "failure::Abbruch. Schreibender Zugriff \"Faktura\" verweigert."; @@ -495,7 +526,7 @@ sub handler { #DMS insert part or fee if($node_meta->{ct_table} eq "contenttranspos" && $R::insert_contenttranspos){ - $feedb = $pl->insert_contenttranspos($q,$R::cc_id,$R::ca_id,$R::ct_id,$users_dms->{u_id}); + $feedb = $pl->insert_contenttranspos($q,$users_dms->{u_id}); } $users_dms = $dbt->select_users($dbh,$users_dms->{u_id},"");#just to get update after save @@ -562,7 +593,7 @@ sub handler { owner => $aowner, c_id => $users_sharee->{c_id} }; - my $vde_on_fail = $users_sharee->{int12} || 3;#keep last or set 3 + my $vde_on_fail = $users_sharee->{int12} || 1;#keep last or set 1 #SEPA, done in payone Payment #CC @@ -767,7 +798,11 @@ sub handler { print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_3}?cum=2\&sharee_edit=send_email_send_sms$session_and\&$returnwww");#send both exit 0; } - elsif($payable_check){ + elsif($payable_check && $payable_check == 1){ + print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_2}?cum=2-$payable_check$session_and\&$returnwww"); + exit 0; + } + elsif($payable_check && $payable_check == 2){ print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_3}?cum=2-$payable_check$session_and\&$returnwww"); exit 0; } diff --git a/copri4/main/src/Mod/Payment.pm b/copri4/main/src/Mod/Payment.pm index 00ab9dc..9ee063f 100755 --- a/copri4/main/src/Mod/Payment.pm +++ b/copri4/main/src/Mod/Payment.pm @@ -38,17 +38,359 @@ sub new { return $self; } -my $ua = LWP::UserAgent->new( - ssl_opts => { - SSL_version => 'TLSv12:!SSLv2:!SSLv3:!TLSv1:!TLSv11', +#book_payment is like payone_capture with additional payment-types +sub book_payment { + my $self = shift; + my $q = shift; + my $varenv = shift; + my $node_meta = shift; + my $users_dms = shift; + + $q->import_names('R'); + my $dbh = ""; + my $feedb = { + u_rows => 0, + message => "", + exit_code => 1, + }; + + my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; + open(EMA, ">> $varenv->{logdir}/book_payment.log"); + print EMA "\n*** $now_dt invoice pdf print c_id4trans:$R::c_id4trans\n" . Dumper($q) . "\n"; + + my $pref_ctt = { + table => "contenttrans", + fetch => "one", + c_id => $R::c_id4trans, + }; + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_record($dbh,$pref_ctt) if($R::c_id4trans); + + my $update_ctt = { + table => "contenttrans", + mtime => "now()", + owner => $users_dms->{u_id}, + }; + + my $node_faktura = $dbt->get_node($dbh,$dbt->{shareedms_conf}->{faktura}); + #invoice number counter. Take last number from node.invoice_nr and increment it + if($node_faktura->{invoice_nr} > 0 && $ctt->{c_id} && $ctt->{ct_name} !~ /\d/){ + my $nextNr = $node_faktura->{invoice_nr}; + $update_ctt->{ct_name} = "$nextNr"; + $update_ctt->{barcode} = "$nextNr"; + my $update_node = { + table => "nodes", + main_id => "$dbt->{shareedms_conf}->{faktura}", + change => "no_time", + }; + my $invoice_nr = $node_faktura->{invoice_nr} + 1; + $dbt->update_one($dbh,$update_node,"invoice_nr='$invoice_nr'"); + } + + print EMA "Used invoice c_id:$ctt->{c_id} with invoice nr:$ctt->{ct_name} OR nextNr: $update_ctt->{ct_name}\n"; + + #Set sum values and book payment depending by selected payment-type "state" + if($ctt->{c_id} && !$ctt->{close_time}){ + + my $pref_adr = { + table => "contentadr", + fetch => "one", + c_id => $ctt->{int10}, + }; + my $ctadr = { c_id => 0 }; + $ctadr = $dbt->fetch_tablerecord($dbh,$pref_adr) if($ctt->{int10}); + print EMA "Used adr c_id:$ctadr->{c_id} by ctt.int10: $ctt->{int10}\n"; + + my $sum_paid = "null"; + my $sum_operatorcredit = "null"; + my $sumgeb_teil = "null"; + my $sumgeb_bank = "null"; + my $state = $R::state || ""; + $update_ctt->{state} = "$state"; + $update_ctt->{int14} = 2;#set OPOS + + if($R::sum_paid){ + $sum_paid = $R::sum_paid; + $sum_paid =~ s/,/\./; + $update_ctt->{int01} = $sum_paid; } -); -$ua->agent("sharee payone POST API"); + + if($R::sum_operatorcredit){ + $sum_operatorcredit = $R::sum_operatorcredit; + $sum_operatorcredit =~ s/,/\./; + $update_ctt->{int02} = $sum_operatorcredit; + $update_ctt->{int14} = "null"; + } + + if($R::sumgeb_teil){ + $sumgeb_teil = $R::sumgeb_teil; + $sumgeb_teil =~ s/,/\./; + $update_ctt->{int08} = $sumgeb_teil; + } + + if($R::sumgeb_bank){ + $sumgeb_bank = $R::sumgeb_bank; + $sumgeb_bank =~ s/,/\./; + $update_ctt->{int07} = $sumgeb_bank; + } + + $feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt); + + #$R::state alias payment-type + if($R::state =~ /payone/){ + + if(!$ctt->{txt16}){ + #preauth + if($ctadr->{ct_name} =~ /\w{2}-\d+/){ + my $payoneret = $self->preauthorizationSEPA_main($varenv,$ctadr,$ctt,$users_dms->{u_id}); + sleep 2; + }elsif(length($ctadr->{ct_name}) >= 19){ + my $payoneret = $self->preauthorizationCC_main($varenv,$ctadr,$ctt,$users_dms->{u_id}); + sleep 2; + } + $ctt = $dbt->fetch_record($dbh,$pref_ctt);#re-read values + + #SEPA capture + if($ctt->{txt16} && $R::state =~ /SEPA/){#SEPA + my $payoneret = $self->captureSEPA_main($varenv,$ctadr,$ctt,$users_dms->{u_id}); + } + #CC capture + elsif($ctt->{txt16} && $R::state =~ /Kreditkarte/){#CC + my $payoneret = $self->captureCC_main($varenv,$ctadr,$ctt,$users_dms->{u_id}); + } + else{ + $feedb->{message} = "failure::Achtung, die payone Vorautorisierung hat keine TXID geliefert. Der Geldeinzug war somit nicht möglich (TXID:$ctt->{txt16} && $R::state)."; + } + }else{ + $feedb->{message} = "failure::Abbruch, payone Geldeinzug nicht ausgeführt weil TXID bereits vorhanden. Hatte der Einzug bereits stattgefunden?"; + } + + } + elsif($ctt->{txt00} eq "Storno" || $state eq "Zahlungsausfall"){ + $update_ctt->{int14} = "null"; + $update_ctt->{pay_time} = "now()"; + $feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt); + #delete OPOS at all + #$db->updater($table,"barcode",$ctt->{barcode},"int14","null","","","","",""); + $dbt->update_one($dbh,$update_ctt,"int14=null"); + } + elsif($state eq "fehlgeschlagener Einzug"){ + $update_ctt->{int14} = "null"; + $update_ctt->{pay_time} = "now()"; + $feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt); + } + elsif($ctt->{txt00} eq "Rechnung" && $R::sum_paid <= 0){ + $update_ctt->{int14} = "null"; + $update_ctt->{pay_time} = "now()"; + $feedb->{u_rows} = $dbt->update_record($dbh,$update_ctt,$ctt); + } + + $ctt = $dbt->fetch_record($dbh,$pref_ctt);#re-read values + + #print pdf and messaging + if($ctt->{c_id}){ + my $praefix = "$ctt->{txt00}-$varenv->{praefix}"; + my $lang_ctt = $ctt->{txt11} || "de"; + $varenv->{cms} = $dbt->fetch_cms($dbh,{ lang => $lang_ctt }); + my $sum_paid = $R::sum_paid || 0; + $sum_paid =~ s/,/\./; + + #print pdf + if($R::print_pdf){ + $feedb = $self->print_pdf($q,$varenv,$node_meta,$users_dms,$feedb); + } + + #send_invoice after book payment + if(-f "$varenv->{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && (($R::set_state eq "buchen" && $R::send_invoice && $ctt->{int01} && $ctt->{int01} != 0) || ($R::send_invoice_again))){ + + my $cms_message_key = "email-invoice"; + if(!$varenv->{cms}->{$cms_message_key}->{txt}){ + $feedb->{message} = "failure::Achtung, CMS-Text '$cms_message_key' ist nicht vorhanden. Es wurde keine eMail versandt!"; + }elsif($sum_paid != $ctt->{int01}){ + $feedb->{message} = "failure::Achtung, die Summe der Positionen $sum_paid enstpricht nicht der Rechnung-Summe $ctt->{int01}. Die Rechnung muss vor dem eMail versand erst gebucht werden!"; + }else{ + system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '' '$cms_message_key' '1'"); + print EMA "---> send_invoice $praefix-$ctt->{ct_name}.pdf email command: $dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '' '$cms_message_key' '1'\n"; + } + + } + + }#end print pdf and messaging + + }else{ + $feedb->{message} = "failure::Buchung abbgebrochen. Die Rechnung ist bereits abgeschlossen oder nicht vorhanden ($ctt->{c_id} > 0 && $ctt->{ct_name} && !$ctt->{close_time})"; + } + + close EMA; + return $feedb; +}#end book_payment -#ported from payone_post.pl -#SEPA -#Request "managemandate" +#print pdf +sub print_pdf { + my $self = shift; + my $q = shift; + my $varenv = shift; + my $node_meta = shift; + my $users_dms = shift; + my $feedb = shift; + + $q->import_names('R'); + my $dbh = ""; + + my $pref_ctt = { + table => "contenttrans", + fetch => "one", + c_id => $R::c_id4trans, + }; + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_record($dbh,$pref_ctt) if($R::c_id4trans); + + open(EMA, ">> $varenv->{logdir}/copri-print.log"); + if($ctt->{c_id}){ + + my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg"; + my $aconf = Config::General->new($api_file); + my %apikeyconf = $aconf->getall; + + my $mandant_id = 100002; + my $print_return = ""; + my $lang_ctt = $ctt->{txt11} || "de"; + my $praefix = "$ctt->{txt00}-$varenv->{praefix}"; + + my $psize="A4"; + my $topdf = "$varenv->{basedir}/src/wkhtmltopdf-amd64"; + + #without system() because we have to wait until PDF is ready + $print_return = `$topdf --page-size $psize "$varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$node_meta->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey}" "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf" 2>&1`; + $feedb->{exit_code} = $?; + + my $filesize = -s "$varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf"; + print EMA "$topdf --page-size $psize $varenv->{wwwhost}/Printpreview?printer_id=PDF\&mandant_main_id=$mandant_id\&main_id=$node_meta->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey} $varenv->{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $feedb->{exit_code}\n\n"; + + if($R::print_pdfview){ + if( -f "$varenv->{basedir}/pdf/$praefix-$ctt->{ct_name}.pdf"){ + print ""; + }else{ + $feedb->{message} = "failure::PDF konnte nicht generiert werden, bitte Info an: admin\@sharee.bike\n $varenv->{wwwhost}/pdf/$praefix-$ctt->{ct_name}.pdf"; + } + } + } + + close EMA; + return $feedb; +}#end print_pdf + +#send_invoice_cms for variable ticket-mailing +sub send_invoice_cms { + my $self = shift; + my $q = shift; + my $varenv = shift; + my $node_meta = shift; + my $users_dms = shift; + my $feedb = shift; + $q->import_names('R'); + my $dbh = ""; + + my $pref_ctt = { + table => "contenttrans", + fetch => "one", + c_id => $R::c_id4trans, + }; + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_record($dbh,$pref_ctt) if($R::c_id4trans); + + if($ctt->{c_id}){ + my $praefix = "$ctt->{txt00}-$varenv->{praefix}"; + my $lang_ctt = $ctt->{txt11} || "de"; + $varenv->{cms} = $dbt->fetch_cms($dbh,{ lang => $lang_ctt }); + my $sum_paid = $R::sum_paid || 0; + $sum_paid =~ s/,/\./; + + #print pdf + if($R::print_pdf){ + $feedb = $self->print_pdf($q,$varenv,$node_meta,$users_dms,$feedb); + } + + my $cms_message_key = $R::cms_message_key; + if(!$varenv->{cms}->{$cms_message_key}->{txt}){ + $feedb->{message} = "failure::Achtung, CMS-Text '$cms_message_key' ist nicht vorhanden. Es wurde keine eMail versandt!"; + }if($sum_paid != $ctt->{int01}){ + $feedb->{message} = "failure::Achtung, die Summe der Positionen $sum_paid enstpricht nicht der Rechnung-Summe $ctt->{int01}. Die Rechnung muss vor dem eMail versand erst gebucht werden!"; + }else{ + my $with_pdf = ""; + $with_pdf = 1 if(-f "$varenv->{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && $R::print_pdf); + system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_invoice_cms' '$ctt->{int10}' '$ctt->{c_id}' '' '$cms_message_key' '$with_pdf'"); + } + } + + return $feedb; +}#end send_invoice_cms + + +#Tagesabschluss +sub close_transactions { + my $self = shift; + my $q = shift; + my $varenv = shift; + my $node_meta = shift; + my $users_dms = shift; + + $q->import_names('R'); + my $dbh = ""; + my $feedb = { + u_rows => 0, + message => "", + }; + + #could be Kunden-Faktura 100002 + my $adr_close = { + c_id => 3, + txt01 => '', + txt02 => '', + txt03 => '', + txt06 => '', + txt07 => '', + txt08 => '', + txt10 => '', + txt11 => '', + }; + + my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; + open(EMA, ">> $varenv->{logdir}/close_transactions.log"); + print EMA "\n*** $now_dt close_transactions\n" . Dumper($q) . "\n"; + + my $journal_id = "300011"; + my $journal_tpl = "209"; + my $ct_id = $dbt->insert_contenttrans($dbh,$adr_close,$journal_id,$journal_tpl,"",$users_dms->{u_id}); + my $pref = { + table => "contenttrans", + fetch => "one", + main_id => $journal_id, + template_id => $journal_tpl, + c_id => $ct_id, + }; + + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_record($dbh,$pref) if($pref->{c_id}); + if($ctt->{c_id}){ + my $pref_close = { + table => "contenttrans", + close_id => $ctt->{c_id}, + main_id => $journal_id, + template_id => $journal_tpl, + source_main_id => '300008,300009,300011',#Rechnung,Storno,Verkaufsjournal + source_template_id => 218, + }; + $feedb->{u_rows} += $dbt->update_close_transactions($dbh,$pref_close); + } + + close EMA; + return $feedb; +}#end close_transactions + + +#SEPA request "managemandate" sub managemandate_main { my $self = shift; my $varenv = shift; @@ -95,7 +437,7 @@ sub managemandate_main { $payoneret = $self->rpc("managemandate",$varenv,$request,$ctadr,$ctt,$owner) if($request); } return $payoneret; -} +}#end SEPA request "managemandate" #Request "preauthorizationSEPA" @@ -422,6 +764,13 @@ sub rpc { my $payoneret = ""; my $dbh = ""; + my $ua = LWP::UserAgent->new( + ssl_opts => { + SSL_version => 'TLSv12:!SSLv2:!SSLv3:!TLSv1:!TLSv11', + } + ); + $ua->agent("sharee payone POST API"); + #payone API URL my $payoneLive = 1; my $httpReqServer = "https://api.pay1.de/post-gateway/"; @@ -569,7 +918,7 @@ sub rpc { print FILE "payone RPC end\n\n" if($debug); close(FILE) if($debug); - #set contentadr owner and mtime only if Vde or payone-return will be set by payone id's + #set contentadr owner and mtime only if vde or payone-return will be set by payone id's if((($update_adr->{int12} && $update_adr->{int12} > 0) || $update_adr->{txt28}) && ($owner == 178 || $owner == 179)){ $update_adr->{owner} = "$owner"; $update_adr->{mtime} = "now()"; @@ -616,12 +965,11 @@ sub pdfmandat { } close EMA; return "$varenv->{basedir}/pdfinvoice/SEPA-Lastschriftmandat-$varenv->{dbname}-$ctadr->{ct_name}.pdf"; -} -#end ported from payone_post.pl -# +}#end SEPA PDFGenerator + #jused by payone_cron.pl -sub payone_capture(){ +sub payone_capture { my $self = shift; my $varenv = shift; my $ctf = shift; @@ -632,7 +980,6 @@ sub payone_capture(){ my $lang = "de"; my $mandant_id = 100002; - #my $main_id = 300008;#Rechnung my $main_id = $ctt->{main_id}; my $retval = ""; my $return_text = ""; @@ -649,10 +996,7 @@ sub payone_capture(){ int14 => 2, }; - my $node_faktura = $dbt->get_node($dbh,$dbt->{shareedms_conf}->{faktura}); - my $node = $dbt->get_node($dbh,$main_id);#Rechnung node - if($node_faktura->{invoice_nr} > 0){ if($ctt->{ct_name} !~ /\d/){ my $nextNr = $node_faktura->{invoice_nr}; diff --git a/copri4/main/src/Mod/Prelib.pm b/copri4/main/src/Mod/Prelib.pm index 9930b76..a529ad0 100755 --- a/copri4/main/src/Mod/Prelib.pm +++ b/copri4/main/src/Mod/Prelib.pm @@ -66,7 +66,7 @@ sub prepaid_request { fetch => "one", main_id => 300023, template_id => 219,#prepaid tpl - ca_id => "$ctadr->{c_id}", + int10 => "$ctadr->{c_id}", state => "is::null", close_time => "is::null", }; @@ -134,7 +134,7 @@ sub longterm_occupied { my $dt1 = DateTime->now(time_zone => "Europe/Berlin"); my $cttpos = { c_id => 0 }; - $cttpos = $dbt->collect_transpos($dbh,$search); + $cttpos = $dbt->collect_transpos($dbh,$search,1); my $longterm_ctadr = {}; my $posting = { 78 => 'email', @@ -295,6 +295,39 @@ sub new_content { return $feedb; } + +#insert new_trans +sub new_contenttrans { + my $self = shift; + my $q = shift; + my $users_dms = shift; + my $node_meta = shift; + $q->import_names('R'); + my $dbh = ""; + my $feedb = { message => "" }; + + my $insert_ctt = { + table => "$node_meta->{ct_table}", + itime => 'now()', + mtime => 'now()', + owner => "$users_dms->{u_id}", + ct_name => "---", + template_id => "$node_meta->{template_id}", + main_id => "$node_meta->{main_id}", + txt00 => "$node_meta->{node_name}", + }; + my $c_idnew = 0; + $c_idnew = $dbt->insert_contentoid($dbh,$insert_ctt,""); + + if($c_idnew){ + $feedb->{c_id} = $c_idnew; + $feedb->{template_id} = $node_meta->{template_id}; + $feedb->{i_rows} = $i_rows; + } + return $feedb; +}#end new_contenttrans + + #save content or contentuser sub save_content { my $self = shift; @@ -510,7 +543,7 @@ sub save_text2contenttrans { $update_ctt->{$_} = "$valxx"; } } - elsif($_ =~ /int|time/){ + elsif($_ =~ /int|ca_id|time/){ if(!$valxx){ $update_ctt->{$_} = "null"; }else{ @@ -547,56 +580,53 @@ sub save_text2contenttrans { sub insert_contenttranspos { my $self = shift; my $q = shift; - my $cc_id = shift || "";#part - my $ca_id = shift || "";#adr - my $ct_id = shift || "";#invoice my $owner = shift || ""; + $q->import_names('R'); my $dbh = ""; - my $feedb = { message => "" }; + my $feedb = { i_rows => 0, + pos_id => 0, + message => "", + }; - if(looks_like_number($cc_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){ + if((looks_like_number($R::c_id) || looks_like_number($R::json_select)) && looks_like_number($R::c_id4trans)){ my $pref = { - table => "contenttrans", - table_pos => "contenttranspos", - fetch => "one", - template_id => "218",#Mietjournal tpl_id - ct_id => $ct_id, - "ct.state" => "is::null", - }; + table => "contenttrans", + fetch => "one", + c_id => $R::c_id4trans, + "ct.state" => "is::null", + }; - my $ctpos = { c_id => 0 }; - $ctpos = $dbt->collect_post($dbh,$pref); - - if($ctpos->{c_id}){ + my $ctt = { c_id => 0 }; + $ctt = $dbt->fetch_tablerecord($dbh,$pref); + if($ctt->{c_id}){ my $pref_cc = { - table => "content", - fetch => "one", - template_id => "IN::(229)", - c_id => $cc_id, - }; + table => "content", + fetch => "one", + template_id => "IN::(224,229)", + }; + $pref_cc->{c_id} = $R::c_id if($R::c_id); + $pref_cc->{barcode} = $R::json_select if($R::json_select); my $cc_part = { c_id => 0 }; - $cc_part = $dbt->fetch_record($dbh,$pref_cc); + $cc_part = $dbt->fetch_record($dbh,$pref_cc) if($R::c_id || $R::json_select); - my $pref_ca = { - table => "contentadr", - fetch => "one", - template_id => "202", - c_id => "$ca_id", - }; + my $pref_adr = { + table => "contentadr", + fetch => "one", + c_id => "$ctt->{int10}", + }; my $ctadr = { c_id => 0 }; - $ctadr = $dbt->fetch_record($dbh,$pref_ca); + $ctadr = $dbt->fetch_tablerecord($dbh,$pref_adr) if($ctt->{int10}); - my $pos_id = 0; if($cc_part->{int02}){ - $pos_id = $dbt->insert_pos($dbh,$ct_id,$cc_part,"",$ctadr,"","",$cc_part->{barcode},"0",$owner,""); + $feedb->{pos_id} = $dbt->insert_pos($dbh,$R::c_id4trans,$cc_part,"",$ctadr,"","",$cc_part->{barcode},"0",$owner,""); }else{ - $feedb->{message} = "failure::Fehler, VK Preis von Artikel Nr. $cc_part->{barcode} nicht definiert."; + $feedb->{message} = "failure::Fehler, Artikel nicht vorhanden oder Preis nicht definiert."; } - if($pos_id > 0){ - $i_rows += 1; + if($feedb->{pos_id} > 0){ + $feedb->{i_rows} += 1; $dbt->update_content4comp($dbh,$cc_part->{c_id},"-","1"); $feedb->{message} = "Artikel Nr. $cc_part->{barcode} erfolgreich hinzugefügt."; } @@ -604,9 +634,8 @@ sub insert_contenttranspos { $feedb->{message} = "failure::Fehler, die Rechnung ist bereits gebucht. Das hinzufügen einer weiteren Rechnungsposition wird somit abgelehnt."; } }else{ - $feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($cc_id && $ca_id && $ct_id)"; + $feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($R::c_id && $R::c_id4trans)"; } - $feedb->{u_rows} = $u_rows; return $feedb; }#end insert_contenttranspos @@ -849,6 +878,21 @@ sub save_contenttranspos { return $feedb; }#end save_contenttranspos +#delete_contenttranspos +sub delete_contenttranspos { + my $self = shift; + my $q = shift; + my $c_id = shift; + my $owner = shift; + my $dbh = ""; + my $feedb = { d_rows => 0, + message => "", + }; + $feedb->{d_rows} = $dbt->delete_content($dbh,"contenttranspos",$c_id); + return $feedb; +}#end delete_contenttranspos + + #set Faktura workflow like Rechnung to Storno sub set_workflow { my $self = shift; @@ -1578,11 +1622,17 @@ sub export_csv { my $node_meta = shift; my $users_dms = shift; my $ct4rel = shift || {}; + my $bike_nodes = shift || {}; my $coo = shift || ""; my $time = time; my %varenv = $cf->envonline(); + my $table = $node_meta->{ct_table} || "content"; my $scol = "c_id"; + if($users_dms->{"col_sort_$table"}){ + $scol = $users_dms->{"col_sort_$table"}; + } + my $feedb = { message => "" }; $node_meta->{tpl_order} =~ s/txt06=[\w\s=]+,/byte01=Ilockit Token,/ if($node_meta->{tpl_id} == 205); my @tpl_order = split(/,/,$node_meta->{tpl_order}); @@ -1600,7 +1650,7 @@ sub export_csv { foreach my $id (sort { - if($users_dms->{sort_updown} eq "down"){ + if($users_dms->{"sort_updown_$table"} eq "down"){ if ($scol =~ /barcode|int/) { $ct4rel->{$b}->{$scol} <=> $ct4rel->{$a}->{$scol} }else{ @@ -1620,6 +1670,25 @@ sub export_csv { if($key =~ /byte/){ my $K_int = unpack "H*", $ct4rel->{$id}->{$key}; push @line, $K_int; + }elsif($ct4rel->{$id}->{template_id} == 225 && $key eq "txt24"){ + my $flotten = ""; + foreach my $rid (sort { $bike_nodes->{$a}->{node_name} cmp $bike_nodes->{$b}->{node_name} } keys (%$bike_nodes)){ + $flotten .= "$bike_nodes->{$rid}->{node_name}\n" if($ct4rel->{$id}->{$key} =~ /$bike_nodes->{$rid}->{main_id}/); + } + push @line, $flotten; + }elsif($ct4rel->{$id}->{template_id} == 225 && $key eq "txt25"){ + my %station_filter_hash = (); + if($ct4rel->{$id}->{txt25} && $ct4rel->{$id}->{txt25} =~ /\d\s\d/){ + %station_filter_hash = map { $_ => 1 } split(/\s+/,$ct4rel->{$id}->{txt25}); + }elsif($ct4rel->{$id}->{txt25} && $ct4rel->{$id}->{txt25} =~ /(\d+)/){ + $station_filter_hash{$1} = 1; + } + my $station_filter = ""; + foreach my $type_id (keys (%station_filter_hash)){ + $station_filter .= "$dbt->{copri_conf}->{type_id}->{$type_id}\n"; + } + + push @line, $station_filter; }else{ push @line, $ct4rel->{$id}->{$key}; } diff --git a/copri4/main/src/Mod/Prelogic.pm b/copri4/main/src/Mod/Prelogic.pm deleted file mode 100755 index c1a2fea..0000000 --- a/copri4/main/src/Mod/Prelogic.pm +++ /dev/null @@ -1,759 +0,0 @@ -package Prelogic; -# -#Deprecated module, please use Prelib.pm -# -# SPDX-License-Identifier: AGPL-3.0-or-later -# Copyright (c) Rainer Gümpelein, TeilRad GmbH -# -#should be refactored -# -use strict; -use warnings; -use POSIX; -use CGI; -use CGI::Carp qw(fatalsToBrowser); -use CGI ':standard'; -use Date::Calc qw(:all); -use Scalar::Util qw(looks_like_number); -use DateTime; -use DateTime::Format::Pg; -use Data::Dumper; -use Lib::Config; -use Mod::Buttons; -use Mod::Libenz; -use Mod::Libenzdb; -use Mod::DBtank; -use Mod::Payment; -use Mod::Pricing; - -sub new { - my $class = shift; - my $self = {}; - bless($self,$class); - return $self; -} - -#Template -sub preinit(){ - my $self = shift; - my $q = shift; - my $node_meta = shift; - my $users_dms = shift; - - $q->import_names('R'); - my @keywords = $q->param; - my $cf = new Config; - my $lb = new Libenz; - my $db = new Libenzdb; - my $dbt = new DBtank; - my $but = new Buttons; - my $payone = new Payment; - my $pri = new Pricing; - - my %ib = $but->ibuttons(); - my %varenv = $cf->envonline(); - my $script = $q->script_name(); - my $path_info = $q->path_info(); - my $path = $path_info; - #with meta_host, - if("$varenv{metahost}"){ - $path = "$script" . "$path_info"; - $script=""; - } - my $lang = "de"; - my $c_id = $R::c_id || "0";#c_id aus content - my $time = time(); - my $now_date = strftime "%Y-%m-%d", localtime; - my $today = strftime("%d.%m.%Y",localtime(time)); - my $today4db = strftime("%Y-%m-%d %H:%M",localtime(time)); - my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; - my $day = strftime "%d", localtime; - my $mon = strftime "%m", localtime; - my $year = strftime "%Y", localtime; - my $i_rows=0; - my $u_rows=0; - my $d_rows=0; - my $dbh = ""; - my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg"; - my $aconf = Config::General->new($api_file); - my %apikeyconf = $aconf->getall; - - open(FILE,">>$varenv{logdir}/Prelogic.log"); - print FILE "\n*--> $now_dt| u_id: $users_dms->{u_id}" . Dumper($q) . "\n"; - - - if(!$users_dms->{u_id}){ - return "failure::Fehler
Die Sitzung wurde unterbrochen."; - } - - if((!looks_like_number($R::c_id4trans) || !looks_like_number($R::tpl_id4trans)) && ($R::ct_trans !~ /delete_trans|new_trans/) && !$R::v_abschluss){ - print FILE Dumper($q); - return "failure::Fehler
Daten ID's nicht vollständig (if((!looks_like_number($R::c_id4trans) || !looks_like_number($R::tpl_id4trans)) && ($R::ct_trans !~ /delete_trans|new_trans/) && !$R::v_abschluss))"; - } - - #international buttons - my ($key,$val,$ib_key); - while (($key,$val) = each(%ib)) { - $ib_key = $key if($R::ct_trans eq $val); - } - $ib_key = $R::ct_trans if(!$ib_key); - my ($ct_last,$c_idnew); - - my $table = "contenttrans"; - my $ctt = $db->get_content1($table,$R::c_id4trans); - my $buchen_mtime = $lb->time4de($ctt->{mtime}); - - my $mandant_main_id = 100002; - my $parent_trans = $db->get_node3("$mandant_main_id","Faktura","$lang") if($mandant_main_id); - - if(!$parent_trans->{main_id}){ - return "failure::Fehler
keine eindeutige Modulzuweisung vorhanden."; - } - my $rel = $db->get_rel4tpl4nd($parent_trans->{main_id},$lang,$R::c_id4trans); - $rel = $db->get_rel4tpl4nd("",$lang,$R::c_id4trans,$rel->{template_id}) if($R::c_id4trans > "0"); - - my $ct_name = $q->escapeHTML("$R::ct_name"); - my $barcode=0; - my $s_owner_id=0; - - if($R::s_start_date_time && $varenv{dataflow} =~ /wiki/){ - $db->users_up("cal_start","$R::s_start_date_time",$users_dms->{u_id}); - } - if($R::s_end_date_time && $varenv{dataflow} =~ /wiki/){ - $db->users_up("cal_end","$R::s_end_date_time",$users_dms->{u_id}); - } - if($R::view_list && $varenv{dataflow} =~ /wiki/){ - $db->users_up("view_list","$R::view_list",$users_dms->{u_id}); - } - - - - #OPEN/CLOSE - if($R::ct_trans eq "open"){ - $db->update_users4trans($R::c_id4trans,$R::tpl_id4trans,"",$users_dms->{u_id}); - $users_dms = $db->select_users($users_dms->{u_id}); - }elsif($R::ct_trans eq "close"){ - $db->update_users4trans("0","0","",$users_dms->{u_id}); - $users_dms = $db->select_users($users_dms->{u_id}); - } - - - #NEW contenttrans - if($ib_key =~ /^new_/){ - $ct_name = "----" if(!$ct_name); - my $foreign_key; - my $sort; - my $main_id = $R::main_id; - if($ib_key =~ /new_trans/){ - $table = "contenttrans"; - $foreign_key="ct_id"; - $main_id = $parent_trans->{main_id} if(!$R::main_id); - } - my $node = $db->get_node4multi($main_id,$lang); - - if($table && $main_id){ - my $rel = $db->get_rel4tpl($main_id,$lang); - $c_idnew = $db->insert_content2($table,$ct_name,$users_dms->{u_id},""); - $i_rows += 1 if($c_idnew > 0); - my $rel_id = $db->insert_relationlist($table,$rel->{main_id},$lang,$c_idnew,$rel->{tpl_id},$foreign_key); - $rel->{content_id} = $c_idnew; #notwendig bei prozeduralem $R::select_part - $db->update_content4change($table,$c_idnew,"",$parent_trans->{parent_id},"int09");#mandant_main_id - $db->update_content4change($table,$c_idnew,"",$node->{main_id},"int12");#zusätzl. Formtyp - $db->update_content4change($table,$c_idnew,"",$node->{node_name},"txt00");#node_name - $db->update_users4trans($c_idnew,$R::tpl_id4trans,"",$users_dms->{u_id}); - }else{ - return "failure::Fehler, Datensatz kann nicht angelegt werden weil folgende Informationen fehlen: ($main_id)"; - } - } - - - ###ADD PARTS/DATE TO Transactions - #FIXME, refactorit - if((($ib_key =~ /add_transpos|add_transdate/) || ($R::select_part && ($R::spart_ct_name || $R::json_select))) && (!$ctt->{close_time})){ - $table = "contenttranspos"; - - my $zcolumn = "barcode"; - my $zcontent = "$R::spart_ct_name" || "$R::json_select"; - - #get part for adding and get from_main_id - my $ct_name = "$R::spart_ct_name" || "$R::json_select" || "";#turn-around!§$ - my $c_id = "$R::c_id" || ""; - my $ct = { c_id => 0 }; - $ct = $db->get_ctrel2("content","$ct_name","","$lang","","$c_id","224,229","$zcolumn","$zcontent",""); - - $ct_name = $ct->{ct_name} if($ct->{ct_name}); - - if($ct->{main_id}){ - $users_dms = $db->select_users($users_dms->{u_id}) if($ib_key =~ /new_/);#nur bei new_ mit save_ - if(!$R::c_id4trans && $ib_key !~ /new_transdate/){ - return "failure::Zu welchem Vorgang soll die Aktion verknüpft werden? Bitte erst den entsprechenden Vorgang öffnen."; - } - } - - if($ct->{barcode} && $ct->{barcode} > 0 && $rel->{content_id}){ - $ct->{int02} = $ct->{int02} * -1 if($ct->{template_id} == 224 && $ct->{int02} > 0);#Gutscheine - - #Add Parts from content to contenttranspos################# - my $pos_id = 0; - - my $ctt = { c_id => 0 }; - if(looks_like_number($R::c_id4trans)){ - my $pref_ctt = { - table => "contenttrans", - fetch => "one", - c_id => $R::c_id4trans, - }; - $ctt = $dbt->fetch_tablerecord($dbh,$pref_ctt); - } - my $ctadr = { c_id => $ctt->{int10} }; - $pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct,"",$ctadr,"","","","0",$users_dms->{u_id},""); - - $i_rows += 1 if($pos_id > 0); - $dbt->update_content4comp($dbh,$ct->{c_id},"-","1"); - return "pos_id=$pos_id";#new return-code to get opened Part-Position in Transposition - }else{ - return "failure::Die Artikelnummer konnte nicht gefunden werden.
::$varenv{wwwhost}/DMS/Waren::Waren verwalten"; - } - } - ##### - - #UPDATE CONTENT - #print "@keywords "; - if($ib_key =~ /save/){ - $c_id = $R::c_id if($ib_key eq "save");#only in journal edit - my $table = "contenttrans"; - if($ib_key eq "save_adr" || $ib_key =~ /save_text/){ - $table = "contenttrans"; - $c_id = "$R::c_id4trans"; - }elsif($ib_key eq "save_pos"){ - $table = "contenttranspos"; - $c_id = $R::c_idpos || $R::pos_id; - } - - #Miet- bzw. BaseVA- Zeitraum - if($ib_key =~ /save_pos/ && $R::c_idpos && $R::start_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/ && $R::end_date =~ /\d{1,2}\.\d{1,2}\.\d{4}/){ - my $pos_id = $R::c_idpos; - my $start_date = "$3-$2-$1" if($R::start_date =~ /(\d{1,2})\.(\d{1,2})\.(\d{4})/); - my $end_date = "$3-$2-$1" if($R::end_date =~ /(\d{1,2})\.(\d{1,2})\.(\d{4})/); - my $s_hh = $q->escapeHTML("$R::s_hh") || "0"; - my $s_mi = $q->escapeHTML("$R::s_mi") || "0"; - my $e_hh = $q->escapeHTML("$R::e_hh") || "0"; - my $e_mi = $q->escapeHTML("$R::e_mi") || "0"; - $s_hh = "24" if($s_hh > "24"); - $e_hh = "24" if($e_hh > "24"); - $s_mi = "59" if($s_mi > "59"); - $e_mi = "59" if($e_mi > "59"); - $s_hh = sprintf('%.2d',$s_hh); - $e_hh = sprintf('%.2d',$e_hh); - $s_mi = sprintf('%.2d',$s_mi); - $e_mi = sprintf('%.2d',$e_mi); - my $start_time=""; - my $end_time=""; - $start_time = "$start_date $s_hh:$s_mi:00" if("$start_date $s_hh:$s_mi" =~ /\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}/); - $end_time = "$end_date $e_hh:$e_mi:00" if("$end_date $e_hh:$e_mi" =~ /\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}/); - - if($start_time && $end_time){ - my $dtnow = DateTime->now( time_zone => "Europe/Berlin" ); - my $dt0 = DateTime::Format::Pg->parse_datetime($start_time); - my $dt1 = DateTime::Format::Pg->parse_datetime($end_time); - - if($dt0 < $dtnow && $dt1 < $dtnow){ - - my $pref = { - table => "contenttrans", - table_pos => "contenttranspos", - fetch => "one", - template_id => "218",#Mietjournal tpl_id - c_id => $pos_id, - "ct.close_time" => "is::null", - }; - - my $record_pos = {}; - my $pricing = {}; - my $counting = {}; - $record_pos = $dbt->collect_post($dbh,$pref); - - my $update_pos = { - table => "contenttranspos", - start_time => "$start_time", - end_time => "$end_time", - owner_end => $users_dms->{u_id}, - mtime => "now()", - }; - my $rows = $dbt->update_record($dbh,$update_pos,$record_pos); - #again to get setted date-times - $record_pos = $dbt->collect_post($dbh,$pref); - - ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos); - - #int03 only used for tarif counting backwards compatibility - #$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours})); - $update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38})); - $update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39})); - $update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40})); - $update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41})); - - $update_pos->{int10} = 1; - $update_pos->{int04} = $R::int04 if(looks_like_number($R::int04)); - - if($R::cc_id =~/^\d+$/){ - my $ctpref = { - table => "content", - fetch => "one", - c_id => $R::cc_id, - }; - my $ctbike = $dbt->fetch_tablerecord($dbh,$ctpref); - - if($ctbike->{int10} && ($ctbike->{int10} == 2 || $ctbike->{int10} == 3)){ - $db->updater("content","c_id",$R::cc_id,"int10","1",$users_dms->{u_id}); - if($R::int04 =~/^\d+$/){ - $db->updater("content","c_id",$R::cc_id,"int04","$R::int04",$users_dms->{u_id}); - } - } - } - - $rows = $dbt->update_record($dbh,$update_pos,$record_pos); - $db->updater("contenttrans","c_id",$ctt->{c_id},"start_time","$start_time",$users_dms->{u_id}); - $db->updater("contenttrans","c_id",$ctt->{c_id},"end_time","$end_time",$users_dms->{u_id}); - } - } - } - - #hidden select keys to delete first, marked with off_ (Project.pm) - foreach(@keywords){ - if($_ =~ /off_(txt\d+)/){ - $db->updater("$table","c_id",$c_id,"$1",""); - } - } - - my $ct_exist2; - $ct_exist2 = $db->get_content2($table,$ct_name) if($ct_name); - $ct_exist2 = $db->get_content1($table,$c_id) if($c_id); - if($ct_exist2->{ct_name} && ($ct_exist2->{c_id} ne $c_id)){ - return "failure::$ct_exist2->{ct_name} - $ct_exist2->{c_id} - $c_id
content name exists"; - }elsif($c_id){ - $users_dms = $db->select_users($users_dms->{u_id});#to get new cal_start - my $j=0; - foreach(@keywords){ - $j++; - my $val = $q->param($_); - my $valxx = $q->escapeHTML("$val"); - my @val = $q->param($_); - $valxx = $q->escapeHTML("@val"); - $_ =~ s/col_//; - $ct_exist2->{$_} =~ s/^\s+//; $ct_exist2->{$_} =~ s/\s+$//; - $valxx =~ s/^\s+//; $valxx =~ s/\s+$//; - $valxx .= ".00" if($valxx =~ /^\d+$/ && $_ =~ /int\d+/); - #print "|$_:$ct_exist2->{$_} -- $valxx|
"; - if("$ct_exist2->{$_}" ne "$valxx"){ - if($_ eq "ct_name" && $valxx && $table){ - $u_rows +=$db->updater("$table","c_id",$c_id,"$_","$valxx"); - } - if($_ =~ /txt21|txt6/ && $table){ - $db->update_content4change2($table,$c_id,"$R::txt61,$R::txt62,$R::txt63,$R::txt64,$R::txt65,$R::txt66,$R::txt67,$R::txt68,$R::txt69","txt21") - }elsif($_ =~ /txt(\d+)$/ && $table){ - $valxx = "null" if(!$valxx);#for empty - my $txtxx = $valxx; - $u_rows +=$db->updater("$table","c_id",$c_id,"$_","$valxx"); - } - - if($_ =~ /mtime|warn_time/ && $table){ - my $timexx = $valxx; - $u_rows += $db->update_content4change($table,$c_id,$ct_name,$timexx,$_,$users_dms->{u_id}) if($timexx =~ /\d{1,2}\.\d{1,2}\.\d{2,4}\s\d{1,2}:\d{1,2}/ || $timexx =~ /\d{1,2}\.\d{1,2}\.\d{2,4}$/); - } - if($_ =~ /state/ && $table){ - my $state = $valxx; - $u_rows += $db->update_content4change($table,$c_id,$ct_name,$state,$_,$users_dms->{u_id}); - } - if($_ =~ /(xml_export)/ && $table){#boolean - my $key = $1; - my $value = $valxx || "f"; - $u_rows += $db->update_content4change($table,$c_id,$ct_name,$value,$key,$users_dms->{u_id}); - } - if($_ =~ /int(\d+)/ && $table){ - $valxx =~ s/,/./; - $valxx =~ s/\.00//; - $valxx = "null" if(!$valxx);#for empty - my $intxx = $valxx; - #Ausgaben trigger - if($ib_key eq "save_pos" && $_ eq "int02" && $intxx =~ /-\d/){ - $u_rows += $db->update_content4change($table,$c_id,$ct_name,$intxx,"int02",$users_dms->{u_id}); - }elsif($ib_key eq "save_pos" && $_ eq "int03"){ - #Warenbestands trigger - my $op="+"; - $op = $1 if($intxx =~ s/(-|\+)//); - if($op =~ /-/){ - return "failure::Bitte einen fiktiven Artikel unter \"Ausgaben\" verwenden."; - } - my $add_menge="0"; - #differenz, es wird nur der zuwachs verwendet - $ct_exist2->{$_} = 0 if(!$ct_exist2->{$_}); - $add_menge = - $ct_exist2->{$_} + $intxx if($op eq "+"); - my $rows = $db->update_content4comp("contenttranspos",$R::ct_name,$R::c_idpos,"$op","$add_menge",""); - if($rows){ - $u_rows += $db->update_content4comp("content",$R::ct_name,"$R::cc_id","-","$add_menge","",""); - } - }else{ - $u_rows +=$db->updater("$table","c_id",$c_id,"$_","$valxx"); - } - } - } - } - } - } - - - #delete ask - if("$ib_key" eq "remove_chk4rel" && $R::main_id && $R::c_id && $R::template_id && $R::rel_id){ - my $node_names; my $i=0; - return "failure::Datensatz wirklich löschen. ::?ct_trans=delete_trans\&exit_box2=1\&c_id=$R::c_id\&rel_id=$R::rel_id ::löschen" - } - - #delete Only relation ... without content - if("$ib_key" eq "delete_rel4ct" && $R::main_id && $R::rel_id){ - $d_rows += $db->delete_relation($R::main_id,$lang,$R::rel_id); - $db->cleanup_users($users_dms->{u_id}) if($users_dms->{u_id}); - } - - #DELETE abschluss - if($ib_key eq "delete" || $ib_key =~ /delete_tver/){ - $table = "contenttrans"; - $table = "contenttver" if($ib_key =~ /delete_tver/); - $d_rows += $db->delete_content("$table","$R::c_id"); - $db->update_users4trans("0","0","",$users_dms->{u_id}); - } - - #DELETE - if($ib_key =~ /delete_trans/){ - my $c_id4del = $R::c_id4trans || $R::c_id; - $table = "contenttrans" if($ib_key =~ /delete_trans/); - my $ctt = $db->get_content1("$table","$c_id4del"); - - $d_rows += $db->delete_content($table,$ctt->{c_id}); - $db->update_users4trans("0","0","",$users_dms->{u_id}); - print $q->div({-class=>'elementwhite'},"2... redirecting to ... or CLICK ", $q->a({href=>"$varenv{wwwhost}$script$path"},"$varenv{wwwhost}/DMS/Faktura")); - print redirect("$varenv{wwwhost}/DMS/Faktura?redirected=1\&return=0-0-0|$i_rows-$u_rows-$d_rows"); - exit 0; - } - - my $pos_id = $R::c_idpos || $R::pos_id; - #DELETE pos - if($ib_key =~ /delete_pos/ && $pos_id){ - $table = "contenttranspos"; - my $cttpos = $db->get_content1($table,$pos_id); - - $d_rows += $db->delete_content("$table","$pos_id"); - $ct_name = $1 if($R::ct_name =~ /^(\d+)/); - $u_rows += $db->update_content4comp("content",$ct_name,"$cttpos->{cc_id}","+","$cttpos->{int03}","",""); - } - ### - - #Auftragsstatus - if($R::order_state && $R::c_id4trans){ - my $table = "contenttrans"; - $u_rows += $db->updater($table,"c_id",$R::c_id4trans,"txt22","$R::txt22",$users_dms->{u_id}); - } - if($R::warning_state && $R::c_id4trans){ - my $table = "contenttrans"; - $u_rows += $db->updater($table,"c_id",$R::c_id4trans,"txt19","$R::txt19",$users_dms->{u_id}); - } - - ###SET Relation (like move doc-type) - #executed by Terminal submit-buttons - #2. counter for WaWi and ReNr - if((!$R::close_time && $R::set_main_id) && ($R::set_relation || $R::set_state || $R::open_set_main_id > 300000 || $R::ct_trans =~ /print_pdf/i)){ - if($R::open_set_main_id){ - $R::set_main_id = $R::open_set_main_id; - $users_dms = $db->select_users($users_dms->{u_id}); - } - my $c_id = $R::c_id4trans || "";#Document id - return "failure::Abbruch, die Aktion konnte keinem Dokument zugeordnet werden. Arbeiten Sie mit mehreren Browser-Tabs? Bitte multiple COPRI Tabs schließen und anschließend das Verkauf-Terminal neu öffnen." if(!$c_id); - - my $table = "contenttrans"; - my $ctt = { c_id => 0 }; - my $rel = $db->get_rel4tpl("",$lang,$R::c_id4trans,$R::tpl_id4trans); - $ctt = $db->get_content1("contenttrans",$rel->{content_id}); - return "failure::Bitte erst einen Formular-Typ wählen" if($R::set_main_id <= "300000"); - $u_rows += $db->update_relation2("",$lang,$R::set_main_id,"",$rel->{rel_id}) if(!$R::close_time && $rel->{rel_id}); - - my $node_faktura = $dbt->get_node($dbh,$dbt->{shareedms_conf}->{faktura}); - my $node = $dbt->get_node($dbh,$R::set_main_id); - - my $update_ctt = { - table => "contenttrans", - mtime => "now()", - owner => $users_dms->{u_id}, - }; - - print FILE "c_id4trans:$R::c_id4trans,tpl_id4trans:$R::tpl_id4trans by condition: ($node_faktura->{invoice_nr} > 0) && $ctt->{ct_name} !~ /\d/)\n old-relation $rel->{main_id} \n new-relation $R::set_main_id\n"; - if($node_faktura->{invoice_nr} > 0 && $ctt->{c_id} > 0 && $ctt->{ct_name} !~ /\d/){ - - my $nextNr = $node_faktura->{invoice_nr}; - $update_ctt->{ct_name} = "$nextNr"; - $update_ctt->{barcode} = "$nextNr"; - my $update_node = { - table => "nodes", - main_id => "$dbt->{shareedms_conf}->{faktura}", - change => "no_time", - }; - my $invoice_nr = $node_faktura->{invoice_nr} + 1; - $dbt->update_one($dbh,$update_node,"invoice_nr='$invoice_nr'"); - - $update_ctt->{int12} = $node->{main_id}; - $update_ctt->{txt00} = $node->{node_name}; - $u_rows += $dbt->update_record($dbh,$update_ctt,$ctt); - - } - - - #SET state alias Zahlung buchen - if($R::set_state && !$R::close_time){ - - my $sum_paid = "null"; - my $sum_operatorcredit = "null"; - my $sumgeb_teil = "null"; - my $sumgeb_bank = "null"; - my $state = $R::state || ""; - $update_ctt->{state} = "$state"; - $update_ctt->{int14} = 2;#set OPOS - - if($R::set_state eq "buchen" && $R::sum_paid){ - $sum_paid = $R::sum_paid; - $sum_paid =~ s/,/\./; - $update_ctt->{int01} = $sum_paid; - } - - if($R::set_state eq "buchen" && $R::sum_operatorcredit){ - $sum_operatorcredit = $R::sum_operatorcredit; - $sum_operatorcredit =~ s/,/\./; - $update_ctt->{int02} = $sum_operatorcredit; - $update_ctt->{int14} = "null"; - } - - if($R::set_state eq "buchen" && $R::sumgeb_teil){ - $sumgeb_teil = $R::sumgeb_teil; - $sumgeb_teil =~ s/,/\./; - $update_ctt->{int08} = $sumgeb_teil; - } - - if($R::set_state eq "buchen" && $R::sumgeb_bank){ - $sumgeb_bank = $R::sumgeb_bank; - $sumgeb_bank =~ s/,/\./; - $update_ctt->{int07} = $sumgeb_bank; - } - - $u_rows += $dbt->update_record($dbh,$update_ctt,$ctt); - - if($state =~ /payone/){ - my $ctadr = $db->get_content1("contentadr",$ctt->{int10}); - - $ctt->{payone_reset} = 0; - if($R::payone_reset){ - #after delete preauth after 0€ capture sets new TXID and increment reference - $ctt->{payone_reset} = $R::payone_reset; - $ctt->{int01} = 0; - $ctt->{sequence} = $ctt->{int18} || 1; - $ctt->{sequence}++; - if($ctt->{txt16} && $R::state =~ /SEPA/){#SEPA 0 - my $payoneret = $payone->captureSEPA_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - } - if($ctt->{txt16} && $R::state =~ /Kreditkarte/){#CC 0 - my $payoneret = $payone->captureCC_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - } - $ctt = $db->get_content1("contenttrans",$ctt->{c_id}); - } - - if($state !~ /Zahlungseingang/ && !$ctt->{txt16}){ - if($ctadr->{ct_name} =~ /\w{2}-\d+/){ - my $payoneret = $payone->preauthorizationSEPA_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - sleep 2; - }elsif(length($ctadr->{ct_name}) >= 19){ - my $payoneret = $payone->preauthorizationCC_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - sleep 2; - } - - $ctt = $db->get_content1("contenttrans",$ctt->{c_id}); - $ctt->{sequence} = $R::payone_sequence || 1; - - #SEPA capture - if($ctt->{txt16} && $R::state =~ /SEPA/){#SEPA - my $payoneret = $payone->captureSEPA_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - } - #CC capture - elsif($ctt->{txt16} && $R::state =~ /Kreditkarte/){#CC - my $payoneret = $payone->captureCC_main(\%varenv,$ctadr,$ctt,$users_dms->{u_id}); - } - else{ - my $return_text = "payone capture fails, errorcode ($ctadr->{int03} && TXID:$ctt->{txt16} && $R::state)."; - $update_ctt->{txt23} = "$now_dt $return_text\n" . $ctt->{txt23}; - $dbt->update_record($dbh,$update_ctt,$ctt); - #return "failure::$return_text"; - - } - }else{ - return "failure::Payone Geldeinzug nicht ausgeführt weil TXID bereits vorhanden. Hatte der Einzug bereits stattgefunden?"; - } - }elsif($ctt->{txt00} eq "Storno" || $state eq "Zahlungsausfall"){ - $update_ctt->{int14} = "null"; - $update_ctt->{pay_time} = "now()"; - $u_rows += $dbt->update_record($dbh,$update_ctt,$ctt); - #delete OPOS at all - $db->updater($table,"barcode",$ctt->{barcode},"int14","null","","","","",""); - }elsif($state eq "fehlgeschlagener Einzug"){ - $update_ctt->{int14} = "null"; - $update_ctt->{pay_time} = "now()"; - $u_rows += $dbt->update_record($dbh,$update_ctt,$ctt); - }elsif($ctt->{txt00} eq "Rechnung" && $R::sum_paid <= 0){ - $update_ctt->{int14} = "null"; - $update_ctt->{pay_time} = "now()"; - $u_rows += $dbt->update_record($dbh,$update_ctt,$ctt); - } - } - - } - ###end SET Relation or state (V Terminal submit's) - - my $c_id4print = ""; - $c_id4print = $R::c_id4trans if(looks_like_number($R::c_id4trans)); - if($c_id4print){ - open(EMA, ">> $varenv{logdir}/copri-print.log"); - print EMA "$today4db\n"; - - my $print_return = ""; - my $exit_code = 1; - - my $ctt = { c_id => 0 }; - my $pref_ctt = { - table => "contenttrans", - fetch => "one", - c_id => $R::c_id4trans, - }; - $ctt = $dbt->fetch_tablerecord($dbh,$pref_ctt); - my $lang_ctt = $ctt->{txt11} || "de";#2023-08-10 - - my $praefix = "$ctt->{txt00}-$varenv{praefix}";#like Rechnung-sharee_operator - - - #PDF generate - if($R::ct_trans =~ /print_pdf/ || $R::print_pdf){ - my $psize="A4"; - my $topdf = "$varenv{basedir}/src/wkhtmltopdf-amd64"; - - #without system() because we have to wait until PDF is ready - $print_return = `$topdf --page-size $psize "$varenv{wwwhost}$script/Printpreview?printer_id=$R::printer_id\&mandant_main_id=$mandant_main_id\&main_id=$node_meta->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$c_id4print\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey}" "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf" 2>&1`; - $exit_code = $?; - - my $filesize = -s "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf"; - print EMA "$topdf --page-size $psize $varenv{wwwhost}$script/Printpreview?printer_id=$R::printer_id\&mandant_main_id=$mandant_main_id\&main_id=$node_meta->{main_id}\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$c_id4print\&u_id=$users_dms->{u_id}\&pkey=$apikeyconf{pdfprinter}->{pkey} $varenv{pdf}/$praefix-$ctt->{ct_name}.pdf\nreturn: $print_return\nfilesize: $filesize\nexit_code: $exit_code\nset_state: $R::set_state\n"; - - #no redirect - if($R::ct_trans eq "print_pdf"){ - if( -f "$varenv{basedir}/pdf/$praefix-$ctt->{ct_name}.pdf"){ - print ""; - }else{ - return "failure::PDF konnte nicht generiert werden, bitte Info an: admin\@sharee.bike\n $varenv{wwwhost}/pdf/$praefix-$ctt->{ct_name}.pdf"; - } - } - } - - #PDF will be generated by "print_pdf" in context "buchen" - #"send_invoice_again" will use formarly generated PDF - if(-f "$varenv{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && (($R::set_state eq "buchen" && $R::send_invoice && $ctt->{int01} && $ctt->{int01} != 0) || ($ib_key eq "send_invoice_again"))){ - my $sum_paid = $R::sum_paid || 0; - $sum_paid =~ s/,/\./; - - my $cms_message_key = "email-invoice"; - $varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $lang_ctt }); - if(!$varenv{cms}->{$cms_message_key}->{txt}){ - return "failure::Achtung, CMS-Text '$cms_message_key' ist nicht vorhanden. Es wurde keine eMail versandt!"; - } - if($sum_paid != $ctt->{int01}){ - return "failure::Achtung, die Summe der Positionen $sum_paid enstpricht nicht der Rechnung-Summe $ctt->{int01}. Die Rechnung muss vor dem eMail versand erst gebucht werden!"; - } - - system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '' '$cms_message_key' '1'"); - print EMA "---> Prelogic send_invoice $praefix-$ctt->{ct_name}.pdf email command: $dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice' '$ctt->{int10}' '$ctt->{c_id}' '' '$cms_message_key' '1'\n"; - } - - #send_invoice_cms - if($ib_key eq "send_invoice_cms" && $R::cms_message_key){ - my $sum_paid = $R::sum_paid || 0; - $sum_paid =~ s/,/\./; - - $varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $lang_ctt }); - if(!$varenv{cms}->{$R::cms_message_key}->{txt}){ - return "failure::Achtung, CMS-Text '$R::cms_message_key' ist nicht vorhanden. Es wurde keine eMail versandt!"; - } - if($sum_paid != $ctt->{int01}){ - return "failure::Achtung, die Summe der Positionen $sum_paid enstpricht nicht der Rechnung-Summe $ctt->{int01}. Die Rechnung muss vor dem eMail versand erst gebucht werden!"; - } - - my $with_pdf = ""; - $with_pdf = 1 if(-f "$varenv{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf" && $R::print_pdf); - system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice_cms' '$ctt->{int10}' '$ctt->{c_id}' '' '$R::cms_message_key' '$with_pdf'"); - print EMA "---> Prelogic send_invoice_cms $praefix-$ctt->{ct_name}.pdf email command: $dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/mailTransportcms.pl '$varenv{syshost}' 'send_invoice_cms' '$ctt->{int10}' '$ctt->{c_id}' '' '$R::cms_message_key' '$with_pdf'\n"; - } - - close EMA; - }#end c_id4print - - #SET Tagesabschluss - if($R::v_abschluss){ - my $journal_tpl="209"; - my $journal_id="300011"; - - #test node - my $n_exist = $db->get_node4multi($journal_id,$lang); - my $t_exist = $db->get_tpl($journal_tpl); - if(!$n_exist->{n_id} || !$t_exist->{tpl_id}){ - return "failure::Die Journal Konfiguration ist fehlerhaft."; - } - - #collect sub-nodes - #TODO - my $main_ids = "300008,300009,300011";#Rechnung,Storno,Verkaufsjournal - #my $main_ids = "$parent_trans->{main_id},"; - #$main_ids .= $db->collect_noderec($parent_trans->{main_id},$lang,"nothing") if($parent_trans->{main_id}); - #$main_ids =~ s/,$//; - - my $tpl_vk = "218"; - my $table = "contenttrans"; - my $sum_start = $R::sum_start || "0"; - my $sum_kasse = $R::sum_kasse || "0"; - $sum_start = $lb->checkint($sum_start); - $sum_kasse = $lb->checkint($sum_kasse); - my $c_id4kasse = ""; - my $c_id4abschluss = $db->get_content6("$table","close_time","null","state","Tagesabschluss","int09","$parent_trans->{parent_id}","","","$s_owner_id"); - if($journal_id){ - if($c_id4abschluss->{c_id} && $c_id4abschluss->{c_id} > 0){ - $c_id4kasse = $c_id4abschluss->{c_id}; - }else{ - $ct_name = "--- auto ct_name = c_id ---"; - $c_id4kasse = $db->insert_content2($table,$ct_name,$users_dms->{u_id},"Tagesabschluss"); - $i_rows += 1 if($c_id4kasse > 0); - $db->update_content4change("contenttrans",$c_id4kasse,"$c_id4kasse"); - $db->update_content4change("contenttrans",$c_id4kasse,"",$parent_trans->{parent_id},"int09");#mandant_main_id - $db->update_content4change("contenttrans",$c_id4kasse,"",$c_id4kasse,"int11");#last_ab - $db->update_content4change("contenttrans",$c_id4kasse,"",$journal_id,"int12");#main_id - - $db->update_content4change("contenttrans",$c_id4kasse,"",$n_exist->{node_name},"txt00");#node_name - my $rel_id = $db->insert_relationlist($table,$journal_id,$lang,$c_id4kasse,$tpl_vk,"ct_id"); - } - $u_rows += $db->update_kasse($table,$c_id4kasse,$sum_kasse,$sum_start); - - if($journal_id && $journal_tpl && $R::close_trans){ - my $opos="null"; - $u_rows += $db->update_tagesabschluss($table,$c_id4kasse,$journal_id,$journal_tpl,$tpl_vk,$parent_trans->{parent_id},"$main_ids","$s_owner_id","$opos"); - - print $q->div({-class=>'elementwhite'},"1... redirecting to ... or CLICK ", $q->a({href=>"$varenv{wwwhost}/DMS/Faktura/Verkaufsjournal"},"$varenv{wwwhost}/DMS/Faktura/Verkaufsjournal")); - print redirect("$varenv{wwwhost}/DMS/Faktura/Verkaufsjournal?redirected=1\&return=0-0-0|$i_rows-$u_rows-$d_rows"); - exit 0; - } - } - $db->cleanup_users($users_dms->{u_id}); - } - close(FILE); - ### - return "$i_rows-$u_rows-$d_rows"; -} -1; diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index e506cc4..cea4c71 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -70,7 +70,7 @@ sub count_freedrental { open(FILE,">>$varenv->{logdir}/count_freedrental.log") if($debug); print FILE "\n*-->$today4db $varenv->{dbname}\n" if($debug); print FILE Dumper($q) if($debug); - print FILE "--> pos.c_id:$pos->{c_id}, user:$pos->{ca_id}, bike:$pos->{ct_name} rental_minute_all: $pricing->{rentalog}->{rental_minute_all} >= 5\n" if($debug); + print FILE "--> pos.c_id:$pos->{c_id}, ca_id:$ca_id=pos.ca_id:$pos->{ca_id}, bike:$pos->{ct_name} rental_minute_all: $pricing->{rentalog}->{rental_minute_all} >= 5\n" if($debug); #2023-10-10 changed from 0min to rental_minute_all >= 5min to keep freed time on rentals >=5min #freed mangement will be only dony on accountable rental @@ -99,6 +99,7 @@ sub count_freedrental { my $record_pos = { c_id => 0 }; $record_pos = $dbt->fetch_tablerecord($dbh,$pref_pos); + print FILE Dumper($pref_pos) . "\n" if($debug); foreach my $pid (sort { $record_pos->{$a}->{c_id} <=> $record_pos->{$b}->{c_id} } keys (%$record_pos)){ $freed_count++; if($freed_count > $max_freed_count && $pos->{c_id} != $record_pos->{$pid}->{c_id}){ @@ -115,6 +116,8 @@ sub count_freedrental { print FILE "--> NO further freed_time available on c_id=$record_pos->{$pid}->{c_id}\n" if($debug); } + }else{ + print FILE "--> NO freed_count if($freed_count > $max_freed_count && $pos->{c_id} != $record_pos->{$pid}->{c_id})\n" if($debug); } $further_freedtime_available = 0 if($freed_count >= $max_freed_count); print FILE "if($freed_count >= $max_freed_count && $pos->{c_id} != $record_pos->{$pid}->{c_id})\nfurther_freedtime_available:$further_freedtime_available\n" if($debug); diff --git a/copri4/main/src/Mod/Shareework.pm b/copri4/main/src/Mod/Shareework.pm index ff5be08..da2c2bb 100755 --- a/copri4/main/src/Mod/Shareework.pm +++ b/copri4/main/src/Mod/Shareework.pm @@ -473,6 +473,14 @@ sub save_account(){ my $vde_on_fail = 0; $vde_on_fail = 2 if($valxx && $valxx == 1); $update_adr->{$_} = $vde_on_fail; + }elsif($_ =~ /^int03/){ + #on payment-type change set vde=3 + if($ctadr->{int03} && $ctadr->{int03} != $valxx){ + $update_adr->{$_} = $valxx; + $update_adr->{int12} = 3; + }else{ + $update_adr->{$_} = $valxx; + } }elsif($_ =~ /^int|barcode/){ $update_adr->{$_} = $valxx; }elsif($_ eq "ct_name" && $R::base_edit){ @@ -733,8 +741,7 @@ sub save_transact(){ fetch => "one", main_id => 300008, template_id => 218, - ca_id => "$ctadr_operator->{c_id}", - #int10 => "$ctadr_operator->{c_id}",#deprecated + int10 => "$ctadr_operator->{c_id}", state => "is::null", close_time => "is::null", }; diff --git a/copri4/main/src/Tpl/Address3.pm b/copri4/main/src/Tpl/Address3.pm index c801a27..75e145b 100755 --- a/copri4/main/src/Tpl/Address3.pm +++ b/copri4/main/src/Tpl/Address3.pm @@ -13,7 +13,6 @@ use Scalar::Util qw(looks_like_number); use Lib::Config; use Mod::Buttons; use Mod::Libenz; -use Mod::Libenzdb; use Mod::DBtank; use Tpl::TransPositionen; use Tpl::TransInvoices; @@ -31,12 +30,10 @@ sub tpl(){ my $varenv = shift; my $node_meta = shift; my $users_dms = shift; - my $return = shift || ""; my $q = new CGI; my $cf = new Config; my $lb = new Libenz; - my $db = new Libenzdb; my $dbt = new DBtank; my $but = new Buttons; my $transp = new TransPositionen; @@ -47,47 +44,59 @@ sub tpl(){ my $line_count2 = 0; my $dbh = ""; - #Kunden Faktura ex Firma - #my $ctf = $db->get_content1("contentuser",$dbt->{shareedms_conf}->{parent_id}); + #selects Kunden-Faktura my $ctf = { c_id => 0 }; my $pref_cu = { table => "contentuser", fetch => "one", c_id => $dbt->{shareedms_conf}->{parent_id}, }; - $ctf = $dbt->fetch_tablerecord($dbh,$pref_cu); + $ctf = $dbt->fetch_tablerecord($dbh,$pref_cu) if($pref_cu->{c_id}); my $ctt = { c_id => 0 }; my $pref = { table => "contenttrans", fetch => "one", - template_id => "IN::(208,209,218,219)", + template_id => "IN::(208,209,218,219)", c_id => $users_dms->{c_id4trans}, }; - $ctt = $dbt->fetch_record($dbh,$pref); + $ctt = $dbt->fetch_record($dbh,$pref) if($pref->{c_id}); my $praefix = "$ctt->{txt00}-$varenv->{praefix}"; my $warn_time = $ctt->{warn_time} || ""; $warn_time = $lb->time4de($warn_time,0) if($warn_time); + my $set_main_id = $dbt->{shareedms_conf}->{invoice}; + $set_main_id = $ctt->{main_id} if($ctt->{main_id} > "300000"); my $ctadr = { c_id => 0 }; - my $rel_adr = { rel_id => 0 }; - my $c_idadr = $ctt->{int10} || "";#c_id orig from contentadr + my $c_idadr = $ctt->{ca_id} || $ctt->{int10} || "";#c_id orig from contentadr + my $pref_adr = { + table => "contentadr", + fetch => "one", + template_id => 202, + c_id => $c_idadr, + }; + #selects Operator-Faktura if($node_meta->{tpl_id} == 208){ - $ctadr = $db->get_content1("contentuser","2"); - }else{ - $ctadr = $db->get_content1("contentadr",$c_idadr); - $rel_adr = $db->get_rel4tpl("","$lang","$c_idadr","202"); + $pref_cu->{c_id} = 2; + $ctadr = $dbt->fetch_tablerecord($dbh,$pref_cu) if($pref_cu->{c_id}); + } + #selects end-customer + else{ + $ctadr = $dbt->fetch_record($dbh,$pref_adr) if($pref_adr->{c_id}); } - if(("$R::trans2edit" eq "client" && $R::c_idadr) || ($R::ct_trans eq "add_transadr")){ - $ctadr = $db->get_content1("contentadr",$R::c_idadr); + if($R::trans2edit eq "client" && looks_like_number($R::c_idadr)){ + $pref_adr->{c_id} = $R::c_idadr; + $ctadr = $dbt->fetch_record($dbh,$pref_adr) if($pref_adr->{c_id}); $c_idadr = $ctadr->{c_id}; $ctt->{txt01} = $ctadr->{txt01}; $ctt->{txt03} = $ctadr->{txt03}; $ctt->{txt06} = $ctadr->{txt06}; $ctt->{txt07} = $ctadr->{txt07}; $ctt->{txt08} = $ctadr->{txt08}; + $ctt->{txt10} = $ctadr->{txt10}; + $ctt->{txt11} = $ctadr->{txt11}; } print<{main_id}; - my $set_main_id = $dbt->{shareedms_conf}->{invoice}; - - print "\n
\n"; if(!$ctt->{c_id}){ $lb->failure3("Das Formular wurde gelöscht bzw. ist nicht vorhanden"); @@ -143,12 +148,12 @@ EOF if($channel_map->{$ctt->{owner}}){ $buchen_users = { txt01 => "$channel_map->{$ctt->{owner}}" }; }else{ - $buchen_users = $db->get_content1("contentadr",$ctt->{owner}); + $pref_adr->{c_id} = $ctt->{owner}; + $buchen_users = $dbt->fetch_record($dbh,$pref_adr) if($pref_adr->{c_id}); } my $journalhead = ""; $journalhead = "
Journal" if($ctt->{template_id} == 209); - $set_main_id=$main_id if($ctt->{main_id} > "300000"); print $q->hidden(-name=>'set_main_id', -override=>'1', -value=>"$set_main_id"); print $q->span({-style=>'margin:0em 0.5em 0 0.5em;padding:0.2em 1em;background-color:white;border:solid thin gray;position:absolute;left:3px;'}, "$ctt->{txt00} $varenv->{praefix}-$ctt->{ct_name} $journalhead"); @@ -176,7 +181,7 @@ EOF print $q->hidden(-name=>'main_id', -override=>'1', -value=>"$ctt->{main_id}"); print $q->hidden(-name=>'rel_id', -override=>'1', -value=>"$ctt->{rel_id}"); }elsif(looks_like_number($ctt->{int01}) && ! -f "$varenv->{basedir}/pdfinvoice/$praefix-$ctt->{ct_name}.pdf"){ - print $q->span({-style=>'margin:0 0.2em;position:absolute;right:3px;'}, $but->singlesubmit3("ct_trans","print_pdf","","","")),"\n"; + print $q->span({-style=>'margin:0 0.2em;position:absolute;right:3px;'}, $but->singlesubmit1("print_pdfview","Print PDF","")),"\n"; } print $q->span({-style=>'margin:0 0.2em;padding:0.3em;font-size:0.81em;position:absolute;right:100px;'},$q->a({-class=>"ebutton3",-target=>'_blank', -href=>"$dbt->{shareedms_conf}->{copri_wiki}"}, "copri wiki"), "$buchen_users->{txt01} / $invoice_time "),"\n"; print "
\n"; @@ -211,12 +216,12 @@ EOF my $top = 30; foreach my $id (sort { $ctt_rel->{$b}->{c_id} <=> $ctt_rel->{$a}->{c_id} } keys (%$ctt_rel)){ my $toppx = $top . "px"; - my $rel_color = "#f7ae37"; - $rel_color = "silver" if($ctt->{c_id} == $ctt_rel->{$id}->{c_id}); + my $rel_color = "silver"; + $rel_color = "#f7ae37" if($ctt->{c_id} == $ctt_rel->{$id}->{c_id}); my $journal = ""; $journal = "Journal " if($ctt_rel->{$id}->{template_id} == 209); my $rel_opos = ""; - $rel_opos = "" if($ctt_rel->{$id}->{int14}); + $rel_opos = "" if($ctt_rel->{$id}->{int14}); print $q->div({-style=>"position:absolute;top:$toppx;right:10px;font-size:0.91em;background-color:$rel_color"}, "$journal ", $q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$ctt_rel->{$id}->{node_name}?ct_trans=open\&c_id4trans=$ctt_rel->{$id}->{c_id}\&tpl_id4trans=$ctt_rel->{$id}->{template_id}\&owner=$users_dms->{u_id}",-title=>"Faktura Terminal öffnen"},"[ $rel_opos $ctt_rel->{$id}->{txt00} $varenv->{praefix}-$ctt_rel->{$id}->{ct_name} ]")),"\n"; $top += 22; } @@ -226,26 +231,25 @@ EOF - #Form for AdressData + #Start form addressdata print $q->start_form(-name=>'addressform'),"\n"; #Big table print $q->start_table({-border=>'0', -width=>'100%',-align=>'left', -cellpadding=>'0', -cellspacing=>'0'}),"\n"; - print "\n"; print $q->start_table({-class=>'list', -height=>'10em',-border=>'0', -width=>'100%',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'}),"\n"; - ###Content #Edit Address --> template=Adressenliste $ctt->{txt01} = $q->unescapeHTML("$ctt->{txt01}"); my $int05 = ""; $int05 = "(manuell)" if($ctt->{int05}); - if($users_dms->{u_id} && ($R::trans2edit eq "client" || $R::ct_trans eq "add_transadr")){ - #my @_anrede = ("","Frau","Herr","Firma"); + if($users_dms->{u_id} && $R::trans2edit eq "client"){ print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$ctt->{c_id}"),"\n"; print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$ctt->{template_id}"); - print $q->hidden(-name=>'int10', -override=>'1', -value=>"$c_idadr"),"\n"; - print $q->hidden(-name=>'c_idadr', -override=>'1', -value=>"$c_idadr"),"\n"; print $q->hidden(-name=>'rel_id', -override=>'1', -value=>"$ctt->{rel_id}"),"\n"; + print $q->hidden(-name=>'int10', -override=>'1', -value=>"$c_idadr"),"\n"; + print $q->hidden(-name=>'ca_id', -override=>'1', -value=>"$c_idadr"),"\n"; + print $q->hidden(-name=>'txt10', -override=>'1', -value=>"$ctt->{txt10}"),"\n"; + print $q->hidden(-name=>'txt11', -override=>'1', -value=>"$ctt->{txt11}"),"\n"; print $q->Tr(),"\n"; print ""; @@ -291,10 +295,10 @@ EOF } #print $q->td({-class=>'tdval4'},"$ctt->{txt02}"),"\n"; - if($c_idadr && $rel_adr->{rel_id}){ + if($c_idadr && $ctadr->{rel_id}){ my $vde = ""; $vde = " Vde $ctadr->{int12}" if($ctadr->{int12}); - print $q->td({-class=>'tdval4',-colspan=>'2'},$q->span({-style=>"background-color:#dcd77f;"},$q->a({-class=>"linknav",-href=>"/DMS/Kunden?node2edit=editpart\&mode=manager\&rel_id=$rel_adr->{rel_id}\&tpl_id=202",-title=>"Kunden Stammdaten öffnen"}," Kunden ID $c_idadr ")), $q->span({-style=>"color:red;padding-left:10px;"}," $vde")),"\n"; + print $q->td({-class=>'tdval4',-colspan=>'2'},$q->span({-style=>"background-color:#dcd77f;"},$q->a({-class=>"linknav",-href=>"/DMS/Kunden?node2edit=editpart\&mode=manager\&rel_id=$ctadr->{rel_id}\&tpl_id=202",-title=>"Kunden Stammdaten öffnen"}," Kunden ID $c_idadr ")), $q->span({-style=>"color:red;padding-left:10px;"}," $vde")),"\n"; } $ctt->{txt01} = $lb->newline($ctt->{txt01},"",""); print $q->Tr(),"\n"; $line_count1++; @@ -376,32 +380,29 @@ EOF } print $q->end_table; print "\n"; - - ###end print $q->end_form,"\n"; - + #end form addressdata ###Content #Edit Parts print "\n"; #operator invoices else position accounting if($ctt->{template_id} == 208 || $ctt->{int10} == 2){ - $line_count2 = $trin->tpl($varenv,$node_meta,$users_dms,$set_main_id,$ctt,$return); + $line_count2 = $trin->tpl($varenv,$node_meta,$users_dms,$ctf,$ctadr,$ctt); }else{ - $line_count2 = $transp->tpl($varenv,$node_meta,$users_dms,$set_main_id,$ctt,$return); + $line_count2 = $transp->tpl($varenv,$node_meta,$users_dms,$ctf,$ctadr,$ctt); } print "\n"; ###end Edit Parts #Text & Vorbelegungen - my $tplf = $db->get_tpl("201");#Firma tpl + my $tplf = $dbt->get_tpl($dbh,201);#tpl Kunden-Faktura my @tplf_order = split /,/,$tplf->{tpl_order}; print $q->start_form(),"\n"; print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$ctt->{c_id}"); - print $q->hidden(-name=>'set_main_id', -override=>'1', -value=>"$set_main_id"),"\n"; #Text save area #Internas und Bearbeitungstatus @@ -476,9 +477,6 @@ EOF print $q->td({-class=>'tdval5',-style=>'width:90%;',-colspan=>2}, $but->singlesubmit7("ct_trans","save_text","$ib{save_text}","","","autofocus")),"\n"; } - print $q->hidden(-name=>'c_id4trans', -override=>'1', -value=>"$ctt->{c_id}"),"\n"; - #print $q->hidden(-name=>'set_main_id', -override=>'1', -value=>"$set_main_id"),"\n"; - print $q->end_form,"\n"; print $q->end_table,"\n"; diff --git a/copri4/main/src/Tpl/BaseEdit.pm b/copri4/main/src/Tpl/BaseEdit.pm index 4936058..cb7fd33 100755 --- a/copri4/main/src/Tpl/BaseEdit.pm +++ b/copri4/main/src/Tpl/BaseEdit.pm @@ -308,14 +308,15 @@ sub tpl(){ fetch => "all", keyfield => "c_id", template_id => "IN::(209,218)", - #ca_id => "$ctrel->{c_id}",#future change int10 => "$ctrel->{c_id}", }; my $cttrans = $dbt->fetch_record($dbh,$pref); foreach my $id (sort { $cttrans->{$b}->{c_id} <=> $cttrans->{$a}->{c_id} } keys (%$cttrans)){ my $toppx = $top . "px"; - print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, " TXID $cttrans->{$id}->{txt16} ",$q->span({-style=>"background-color:#f7ae37"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$cttrans->{$id}->{node_name}?ct_trans=open\&c_id4trans=$cttrans->{$id}->{c_id}\&tpl_id4trans=$cttrans->{$id}->{template_id}\&owner=$users_dms->{u_id}",-title=>"Faktura Terminal öffnen"},"[ $cttrans->{$id}->{node_name} #$cttrans->{$id}->{ct_name} ]"))),"\n"; + my $rel_opos = ""; + $rel_opos = "" if($cttrans->{$id}->{int14}); + print $q->div({-style=>"position:absolute;top:$toppx;right:20px;"}, " TXID $cttrans->{$id}->{txt16} ",$q->span({-style=>"background-color:#f7ae37"},$q->a({-class=>"linknav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$cttrans->{$id}->{node_name}?ct_trans=open\&c_id4trans=$cttrans->{$id}->{c_id}\&tpl_id4trans=$cttrans->{$id}->{template_id}\&owner=$users_dms->{u_id}",-title=>"Faktura Terminal öffnen"},"[ $rel_opos $cttrans->{$id}->{node_name} #$cttrans->{$id}->{ct_name} ]"))),"\n"; $top += 22; } }elsif($node_meta->{tpl_id} == 205){ @@ -418,6 +419,12 @@ EOF #print $q->td({-class=>'content1_cms'}, $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{int09}",-size=>"5",-maxlength=>5), "Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{txt04}",-size=>"30",-maxlength=>50)),"\n"; print $q->td({-class=>'content1_cms'}, "$cttpos->{int09} ($cttpos->{txt04})"),"\n"; } + #pos start station + elsif($key eq "int06" && $node_meta->{tpl_id} == 221){ + print $q->Tr(); + print $q->td({-class=>'left_italic_cms',-colspan=>'1'},"$des"); + print $q->td({-class=>'content1_cms',-colspan=>'1'},"$prefix $cttpos->{int06}"); + } #pos end station elsif($key eq "int04" && "$size" eq "select" && $node_meta->{tpl_id} == 221){ my @_valxx = ("null:"); @@ -548,7 +555,7 @@ EOF #only if invoice isn't booked if($key eq "txt23" && $cttpos->{ca_id} && $cttpos->{ct_id} && !$cttpos->{state}){ print $q->Tr(),"\n"; - print $q->td({-class=>'left_italic_cms'}, $q->a({-class=>"linknav4",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Waren/Gebühren?ca_id=$cttpos->{ca_id}\&ct_id=$cttpos->{ct_id}\&owner=$users_dms->{u_id}",-title=>""},"Gebühr hinzufügen")),"\n"; + print $q->td({-class=>'left_italic_cms'}, $q->a({-class=>"linknav4",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Waren/Gebühren?c_id4trans=$cttpos->{ct_id}\&owner=$users_dms->{u_id}",-title=>""},"Gebühr hinzufügen")),"\n"; print $q->td({-class=>'content1_cms'}," "),"\n"; } diff --git a/copri4/main/src/Tpl/Calorin.pm b/copri4/main/src/Tpl/Calorin.pm index 74f86c1..ba37e2a 100755 --- a/copri4/main/src/Tpl/Calorin.pm +++ b/copri4/main/src/Tpl/Calorin.pm @@ -43,7 +43,7 @@ sub tpl(){ my $lang = "de"; my @tpl_order = ('c_id=ID=5=Datensatz ID (nur intern)','date_time=Mietzeit','txt08=Name=15','int06=Start Station=5','int04=End Station=5','barcode=Bike Nr.=5','int12=Group=select','int10=Rental State=select','int20=Lock State=select','owner=User=select','txt23=Comment=15'); - push (@tpl_order, "txt24=debug,log,agent,HW") if($users_dms->{int03} > 1); + push (@tpl_order, "txt24=debug,log,device,HW") if($users_dms->{int03} >= 1); my %varenv = $cf->envonline(); my %ib = $but->ibuttons(); @@ -183,6 +183,7 @@ sub tpl(){ } my $c_id = $R::cttpos_id || $R::c_id || ""; + $c_id = "" if($R::insert_contenttranspos); my $cttpos = {}; $R::ct_ct_name =~ s/\#//; my $search = { @@ -193,6 +194,8 @@ sub tpl(){ if($R::ct_id && looks_like_number($R::ct_id)){ $search->{ct_id} = $R::ct_id; + }elsif($R::c_id4trans && looks_like_number($R::c_id4trans)){ + $search->{ct_id} = $R::c_id4trans; }elsif($c_id && looks_like_number($c_id)){ $search->{cttpos_id} = $c_id; }else{ @@ -218,7 +221,7 @@ sub tpl(){ if(!$start_chck && !$end_chck){ if($node_meta->{ct_table} eq "contenttranspos"){ - $cttpos = $dbt->collect_transpos($dbh,$search); + $cttpos = $dbt->collect_transpos($dbh,$search,0); }elsif($node_meta->{ct_table} eq "contenttheftpos"){ #7=get_event alarm #8=get_position after validate @@ -344,7 +347,7 @@ sub tpl(){ my $id = $cttpos->{$pid}->{ct_id}; if($ct4rel->{$id}->{c_id} == $cttpos->{$pid}->{ct_id}){ $ct_name = $ct4rel->{$id}->{ct_name}; - $opos = "" if($ct4rel->{$id}->{int14}); + $opos = "" if($ct4rel->{$id}->{int14}); $ct_txt00 = $ct4rel->{$id}->{txt00}; $ct_txt01 = $ct4rel->{$id}->{txt01}; $ct_phone = $ct4rel->{$id}->{txt07}; @@ -415,21 +418,17 @@ sub tpl(){ $pos_details .= $did . " = " . $pos_hash->{$did} . "
" if($pos_hash->{$did}); } my $pos_id = "ID $cttpos->{$pid}->{c_id}"; - my $user_device = ""; + my $user_agent = ""; my $charge = ""; $charge .= " → lock-charge $cttpos->{$pid}->{int14} %" if(looks_like_number($cttpos->{$pid}->{int14})); $charge .= " → bike-charge $cttpos->{$pid}->{int19} %" if(looks_like_number($cttpos->{$pid}->{int19}) && $record_part->{$cttpos->{$pid}->{cc_id}}->{energy_id}); if($users_dms_primary->{u_id} && $dbt->{copri_conf}->{betau_id}->{$users_dms_primary->{u_id}}){ $pos_id = $q->div({-class=>"popup",-onclick=>"toggle_box('$pid')"},"$cttpos->{$pid}->{c_id}", $q->span({-class=>"popuptext",-id=>"$pid"},"$pos_details")); - $user_device = ""; - $user_device .= " → endAck" if($cttpos->{$pid}->{int27}); + $user_agent = ""; + $user_agent .= " → endAck" if($cttpos->{$pid}->{int27}); my $txt26 = $cttpos->{$pid}->{txt26}; $txt26 = substr($cttpos->{$pid}->{txt26},0,25) if(length($cttpos->{$pid}->{txt26}) > 20); - $user_device .= " → $txt26" if($txt26); - my $txt21 = $cttpos->{$pid}->{txt21}; - $txt21 = substr($cttpos->{$pid}->{txt21},0,50) . " ..." if(length($cttpos->{$pid}->{txt21}) > 50); - #$user_device .= " → $txt21" if($txt21); - + $user_agent .= " → $txt26" if($txt26); } my $bikenr = $cttpos->{$pid}->{barcode} || $cttpos->{$pid}->{ct_name}; @@ -476,7 +475,7 @@ sub tpl(){ my $debug_log_view = ""; if($search->{txt24}){ - my $debug_log = "appapi-log: $cttpos->{$pid}->{txt24} | sigapi-log: $cttpos->{$pid}->{txt25} | user-agent: $cttpos->{$pid}->{txt26} | app-debug: $cttpos->{$pid}->{txt27} | lock-HW: $cttpos->{$pid}->{txt28} | response-log: $cttpos->{$pid}->{txt29}"; + my $debug_log = "appapi-log: $cttpos->{$pid}->{txt24} | sigapi-log: $cttpos->{$pid}->{txt25} | user-agent: $cttpos->{$pid}->{txt26} | user-device: $cttpos->{$pid}->{txt21} | app-debug: $cttpos->{$pid}->{txt27} | lock-HW: $cttpos->{$pid}->{txt28} | response-log: $cttpos->{$pid}->{txt29}"; my $index = index(lc($debug_log), lc($search->{txt24})); $index -= 20; $debug_log = "... " . substr($debug_log,$index,100) . " ..."; @@ -500,7 +499,7 @@ sub tpl(){ if($users_dms_primary->{u_id} && $users_dms->{u_id} && $users_dms->{int03} >= 1){ print $q->div({-style=>'float:left;margin:0.4em 0 0 1em;'}, "→ Faktura", $q->a({-class=>"linknav3",-style=>"$trans_style",-href=>"/DMS/Faktura?ct_trans=open\&c_id4trans=$c_id4trans\&tpl_id4trans=$tpl_id4trans\&owner=$users_dms->{owner}",-title=>"Faktura Terminal öffnen"},"$opos \#$ct_name")),"\n" if($c_id4trans && $tpl_id4trans); - print $q->div({-style=>'float:left;margin-left:1em;'}, "$user_device"),"\n"; + print $q->div({-style=>'float:left;margin-left:1em;'}, "$user_agent"),"\n"; } }elsif($node_meta->{ct_table} eq "contenttheftpos"){ diff --git a/copri4/main/src/Tpl/Liste3.pm b/copri4/main/src/Tpl/Liste3.pm index b797fbf..13f9931 100755 --- a/copri4/main/src/Tpl/Liste3.pm +++ b/copri4/main/src/Tpl/Liste3.pm @@ -479,7 +479,7 @@ EOF } } $ct4rel = $dbt->search_content($dbh,$searchref,$node_meta,$users_dms,"$main_ids","$tplids","$ct_ids",$v_journal,$ck4ex); - $feedb = $pl->export_csv($node_meta,$users_dms,$ct4rel,$coo) if($ck4ex); + $feedb = $pl->export_csv($node_meta,$users_dms,$ct4rel,$bike_nodes,$coo) if($ck4ex); if($node_meta->{node_name} eq "Faktura" || $tplids =~ /218/){ my $v_journalparts = ""; @@ -762,17 +762,27 @@ EOF $payment_time = $ct4rel->{$id}->{payment_time}; $payment_time = $lb->time4de($payment_time,"1"); } + + #summarize $sum_saldo += $ct4rel->{$id}->{int16} if($ct4rel->{$id}->{state}); - $sum_opos += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{int14} >= 1 && ($ct4rel->{$id}->{state} !~ /ausfall|fehlgeschlagen/i)); - $sum_abb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Abbuchung/); - $sum_ueb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Überweisung/); - $sum_SEPApayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /SEPA.*payone|Zahlungseingang.*payone/); - $sum_CCpayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Kreditkarte.*payone/); - $sum_ausfall += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Zahlungsausfall/); + + if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Zahlungsausfall/){ + $sum_ausfall += $ct4rel->{$id}->{int01}; + }elsif($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /fehlgeschlagen/i){ + $sum_einzugfail += $ct4rel->{$id}->{int01}; + }elsif($ct4rel->{$id}->{state} && $ct4rel->{$id}->{int14} >= 1){ + $sum_opos += $ct4rel->{$id}->{int01}; + }else{ + $sum_abb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Abbuchung/); + $sum_ueb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Überweisung/); + $sum_SEPApayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /SEPA.*payone/); + $sum_CCpayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Kreditkarte.*payone/); + } $sum_gutschrift += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Gutschrift/); - $sum_einzugfail += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /fehlgeschlagen/i); $sum_entgelt += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Entgelt/); $sum_abr -= $ct4rel->{$id}->{int02} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Abrechnung/); + # + $c_id4csv .= "$ct4rel->{$id}->{c_id},"; $ct4rel->{$id}->{ct_name} = $q->unescapeHTML($ct4rel->{$id}->{ct_name}) || ""; $ct4rel->{$id}->{c_id} = $q->unescapeHTML($ct4rel->{$id}->{c_id}) || ""; @@ -811,8 +821,8 @@ EOF print "\n"; #fee2pos - if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /229/) && $R::ca_id && $R::ct_id){ - print $q->a({-class=>"editnav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal?insert_contenttranspos=1\&cc_id=$ct4rel->{$id}->{c_id}\&ca_id=$R::ca_id\&ct_id=$R::ct_id\&owner=$users_dms->{u_id}",-title=>"Gebühr hinzufügen"}, $q->span({-class=>"bi bi-clipboard2-plus", -style=>'font-size:1.5em;'})); + if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /229/) && $R::c_id4trans){ + print $q->a({-class=>"editnav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal?insert_contenttranspos=1\&c_id=$ct4rel->{$id}->{c_id}\&c_id4trans=$R::c_id4trans\&owner=$users_dms->{u_id}",-title=>"Gebühr hinzufügen"}, $q->span({-class=>"bi bi-clipboard2-plus", -style=>'font-size:1.5em;'})); } if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|225/)){ @@ -870,7 +880,7 @@ EOF if($table eq "contentadr" && ($ct4rel->{$id}->{int12} || !$ct4rel->{$id}->{int04} || !$ct4rel->{$id}->{int13})){ print $q->td({-class=>'tdicon',-style=>"$set_style color:red;"},"•","\n") if($ecol <= "2"); }elsif($table eq "contenttrans" && ($ct4rel->{$id}->{int14} && $ct4rel->{$id}->{int14} >= 1)){ - print $q->td({-class=>'tdicon',-style=>"$set_style color:red;"},"•","\n") if($ecol <= "2"); + print $q->td({-class=>'tdicon bi bi-record2', -style=>"$set_style;color:Maroon;"},""),"\n" if($ecol <= "2"); }elsif($table eq "content" && $ct4rel->{$id}->{template_id} == 227){ my $dir_thumb = "$varenv{data}/$node_meta->{main_id}-thumb/$ct4rel->{$id}->{c_id}"; my @pics = $lb->read_dirfiles($dir_thumb,"\.JPG|\.PNG","file",""); @@ -906,7 +916,7 @@ EOF #$ct4rel->{$id}->{$key} = $lb->newline($ct4rel->{$id}->{$key},"","$br4text"); $set_style4nr = $set_style; $set_style4nr="background-color:#e3dbc9;" if(($key eq "barcode") || ($key eq "int04")); - $ct4rel->{$id}->{$key} =~ s/\./,/ if($key =~ /int/); + $ct4rel->{$id}->{$key} =~ s/\./,/ if($key =~ /int/ && $ct4rel->{$id}->{$key}); if($key eq "c_id"){ @@ -928,7 +938,7 @@ EOF elsif($key eq "ct_name" && $ct4rel->{$id}->{$key}){ if($table =~ /contenttrans|contenttver/){ my $opos = ""; - $opos = "" if($ct4rel->{$id}->{int14}); + $opos = "" if($ct4rel->{$id}->{int14}); print $q->td({-class=>'tdint',-style=>"font-weight:normal;$set_style4nr", -nowrap=>1},$q->a({-class=>"linknav3",-href=>"?ct_trans=open\&mode=manager\&c_id4trans=$ct4rel->{$id}->{c_id}\&tpl_id4trans=$ct4rel->{$id}->{template_id}\&owner=$users_dms->{u_id}\&offset=$searchref->{offset}\&limit=$searchref->{limit}",-title=>"Terminal öffnen"},"$opos $ct4rel->{$id}->{$key}")); }elsif($table =~ /content$|contentadr/){ print $q->td({-class=>"tdint",-style=>"font-weight:normal;$set_style4nr"},$q->a({-class=>"linknav3",-href=>"?node2edit=editpart\&mode=manager\&rel_id=$ct4rel->{$id}->{rel_id}\&offset=$searchref->{offset}\&limit=$searchref->{limit}",-title=>"Terminal öffnen"},"$ct4rel->{$id}->{$key}")),"\n"; @@ -952,7 +962,7 @@ EOF foreach my $irid (sort { $ctt_rel->{$b}->{c_id} <=> $ctt_rel->{$a}->{c_id} } keys (%$ctt_rel)){ if($ct4rel->{$id}->{c_id} != $ctt_rel->{$irid}->{c_id}){ my $rel_opos = ""; - $rel_opos = "" if($ctt_rel->{$irid}->{int14}); + $rel_opos = "" if($ctt_rel->{$irid}->{int14}); print $q->a({-class=>"linknav3",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Faktura/$ctt_rel->{$irid}->{node_name}?ct_trans=open\&c_id4trans=$ctt_rel->{$irid}->{c_id}\&tpl_id4trans=$ctt_rel->{$irid}->{template_id}\&owner=$users_dms->{u_id}\&offset=$searchref->{offset}\&limit=$searchref->{limit}",-title=>"Terminal öffnen"},"$rel_opos $ctt_rel->{$irid}->{ct_name}
"); } } @@ -1005,7 +1015,7 @@ EOF $order_state = "$ct4rel->{$id}->{txt22}" if($ct4rel->{$id}->{txt22}); $order_state = "$ct4rel->{$id}->{txt22},
" if($ct4rel->{$id}->{txt22} && $ct4rel->{$id}->{$key}); my $capture_state = "$ct4rel->{$id}->{$key}"; - $capture_state = "$ct4rel->{$id}->{$key}" if($ct4rel->{$id}->{$key} =~ /payone/ && $ct4rel->{$id}->{int14} >= 1); + $capture_state = "$ct4rel->{$id}->{$key}" if($ct4rel->{$id}->{int14} >= 1); print $q->td({-class=>'tdint',-style=>"$txtstyle $set_style"},"$order_state $capture_state"),"\n"; }elsif($ct4rel->{$id}->{template_id} =~ /205|225/ && $key eq "int10"){#bike_state my $colorize = ""; @@ -1059,10 +1069,6 @@ EOF my $timeview = ""; $timeview = $ct4rel->{$id}->{$key} if($ct4rel->{$id}->{$key} && $ct4rel->{$id}->{$key} =~ /\d/); print $q->td({-class=>'tdint',-style=>"$txtstyle $set_style"},"$timeview"),"\n"; - }elsif($key =~ /txt01/ && $v_journal){ - my $txt01 = "$ct4rel->{$id}->{$key}"; - $txt01 = "$txt01" if($ct4rel->{$id}->{state} eq "Kassenbestand"); - print $q->td({-class=>'tdtxt',-style=>"$txtstyle $set_style"},"$txt01"),"\n"; }elsif($key =~ /txt03/ && $ct4rel->{$id}->{template_id} eq "227"){ print $q->td({-class=>'tdtxt',-style=>"$txtstyle $set_style"},$q->a({-style=>"color:black;",-href=>"$varenv{metahost}/site/$ct4rel->{$id}->{$key}", -target=>'_blank',-title=>'anzeigen'},"$ct4rel->{$id}->{$key}")),"\n"; }elsif($key =~ /txt00/ && $v_journal){ @@ -1166,7 +1172,7 @@ EOF }#journal offen ende - if(($nr > 0) && ($v_journal || $R::v_abschluss) && !$R::rel_id){ + if(($nr > 0) && ($v_journal || $R::close_trans) && !$R::rel_id){ my $m = $k - 4; print $q->Tr(); print $q->td({-style=>"background-color:silver;"},""),"\n"; @@ -1225,7 +1231,7 @@ EOF print $q->td({-class=>'tdint',-colspan=>"1",-nowrap=>"1"},"$sum_gutschrift €"); } if($sum_einzugfail != 0){ - $sum_einzugfail *= -1; + #$sum_einzugfail *= -1; $sum_einzugfail = sprintf('%.2f',$sum_einzugfail); $sum_success += $sum_einzugfail; print $q->Tr(); @@ -1266,11 +1272,11 @@ EOF } if($users_dms->{u_id}){ - if($v_journal =~ /bericht/ && $j_exist->{main_id}){ + if($v_journal eq "Tagesbericht" && $j_exist->{main_id}){ print $q->Tr(); print $q->td({-style=>"background-color:silver;"},""),"\n"; - print $q->td({-style=>"background-color:silver;",-class=>'tdsum',-colspan=>"$m"},"Tagesabschluss"),"\n"; - print $q->td({-style=>"background-color:silver;",-class=>'tdsum',-colspan=>"1",-nowrap=>"1"},$but->checkbox("1","close_trans","","Tagesbericht abschließen und in das Verkaufsjournal senden"),$but->singlesubmit("v_abschluss","Speichern")),"\n"; + print $q->td({-style=>"background-color:silver;",-class=>'tdsum',-colspan=>"$m"},"Tagesbericht abschließen, Übertrag in das Verkaufsjournal"),"\n"; + print $q->td({-style=>"background-color:silver;",-class=>'tdsum',-colspan=>"1",-nowrap=>"1"},$but->singlesubmit("close_trans","Speichern")),"\n"; } } @@ -1307,7 +1313,7 @@ EOF if($table eq "contentadr"){ print $q->div({-style=>'padding:0 20px;font-style:italic;'}, $q->span({-style=>'padding:0.1em 0.8em;',-style=>'color:red;'},"•"), "Der Verleih ist nicht freigeschaltet"),"\n"; }elsif($table eq "contenttrans"){ - print $q->div({-style=>'padding:0 20px;font-style:italic;'}, $q->span({-style=>'padding:0.1em 0.8em;',-style=>'color:red;'},"•"), "payone error"),"\n"; + print $q->div({-style=>'padding:0 20px;font-style:italic;'}, $q->span({ -class=>'bi bi-record2', -style=>'padding:0.1em 0.8em;color:Maroon;'},""), "OPOS - Offener Posten"),"\n"; }elsif($table eq "content" && $node_meta->{tpl_id} =~ /205|225/){ print $q->div({-style=>'padding:0 20px;font-style:italic;'}, $q->span({-class=>"bi bi-wrench"}), "Service-Wartung"),"\n"; } diff --git a/copri4/main/src/Tpl/TransInvoices.pm b/copri4/main/src/Tpl/TransInvoices.pm index d8844e4..af000a4 100755 --- a/copri4/main/src/Tpl/TransInvoices.pm +++ b/copri4/main/src/Tpl/TransInvoices.pm @@ -18,7 +18,6 @@ use Data::Dumper; use Lib::Config; use Mod::Buttons; use Mod::Libenz; -use Mod::Libenzdb; use Mod::DBtank; use Mod::APIfunc; use Mod::Pricing; @@ -36,14 +35,13 @@ sub tpl(){ my $varenv = shift; my $node_meta = shift; my $users_dms = shift; - my $set_main_id = shift; + my $ctf = shift; + my $ctadr = shift; my $ctt = shift; - my $return = shift || ""; my $q = new CGI; my $cf = new Config; my $lb = new Libenz; - my $db = new Libenzdb; my $dbt = new DBtank; my $apif = new APIfunc; my $but = new Buttons; @@ -63,14 +61,6 @@ sub tpl(){ my @tpl_order = (); my $cttpos = { c_id => 0 }; - my $ctf = { c_id => 0 }; - my $pref_cu = { - table => "contentuser", - fetch => "one", - c_id => $dbt->{shareedms_conf}->{parent_id}, - }; - $ctf = $dbt->fetch_tablerecord($dbh,$pref_cu); - my $ctf_operator = { c_id => 0 }; my $pref_cuop = { table => "contentuser", @@ -103,7 +93,7 @@ sub tpl(){ @tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int94=Disagio","int95=Transaktion","int96=Zahlungsmeldung","int97=Kreditkarte Zuordnung","int02=Gutschrift"); } } - my $tplf = $dbt->get_tpl($dbh,201);#Kunden-Faktura, ex Firma + my $tplf = $dbt->get_tpl($dbh,201);#Kunden-Faktura Firma my @tplf_order = split /,/,$tplf->{tpl_order}; print $q->start_table({-class=>'list', -border=>'0', -width=>'100%',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'}),"\n"; @@ -301,11 +291,8 @@ sub tpl(){ print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit") if($R::limit); print $q->hidden(-name=>'relids', -override=>'1', -value=>"$R::relids") if($R::relids); - $set_main_id=$ctt->{main_id} if($ctt->{main_id} && $ctt->{main_id} > "300000"); - print $q->hidden(-name=>'set_main_id', -value=>"$set_main_id", -override=>'1'); - - if($users_dms->{int03} == 2){ + if($users_dms->{int03} == 2){ #only if user is also a primary DMS user with invoice rw print $q->hidden(-name=>'printer_id', -value=>"PDF", -override=>'1'); my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); @@ -345,7 +332,7 @@ sub tpl(){ my $send_invoice_checkbox = 0; #$send_invoice_checkbox = 0 if($ctt->{txt30}); print $q->div({-class=>'element6',-style=>'float:right;'}, $q->b("$ctt->{txt00}"), - ": PDF drucken ",$but->checkbox("print_pdf","ct_trans","1","PDF drucken",""), + ": PDF drucken ",$but->checkbox("1","print_pdf","1","PDF drucken",""), " – eMail senden ",$but->checkbox("1","send_invoice","$send_invoice_checkbox","eMail $ctt->{txt00}",""), " – Zahlungsart ", $but->selector("state","250px",$kind_of_payment,@_paymentstate), @@ -366,7 +353,7 @@ sub tpl(){ print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset") if($R::offset); print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit") if($R::limit); print $q->hidden(-name=>'relids', -override=>'1', -value=>"$R::relids") if($R::relids); - print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! $ctt->{txt00} eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","send_invoice_again")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); + #print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! $ctt->{txt00} eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","send_invoice_again")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); print $q->end_form; } @@ -374,7 +361,14 @@ sub tpl(){ print $q->div({-style=>'padding:0.5em;font-size:0.81em;width:98%;text-align:right;'}, "Download: ", $q->a({-href=>"$varenv->{wwwhost}/FileOut?file=$praefix-$ctt->{ct_name}.pdf&sessionid=$coo", -target=>"_blank" , -type=>'application/octet-stream', -style=>'text-decoration:underline;'}), "$praefix-$ctt->{ct_name}.pdf"),"\n"; } - $db->updater("contenttrans","c_id","$ctt->{content_id}","txt20","$accounting_start - $accounting_end","","","","","no_time") if(!$int05 && $accounting_start && $accounting_end); + if(!$int05 && $accounting_start && $accounting_end){ + my $update_ctt = { + table => "contenttrans", + mtime => "no_time", + c_id => $ctt->{content_id}, + }; + $dbt->update_one($dbh,$update_ctt,"txt20='$accounting_start - $accounting_end'"); + } return $line_count2; } diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm index bc7b4d7..52a6e8b 100755 --- a/copri4/main/src/Tpl/TransPositionen.pm +++ b/copri4/main/src/Tpl/TransPositionen.pm @@ -18,7 +18,6 @@ use Data::Dumper; use Lib::Config; use Mod::Buttons; use Mod::Libenz; -use Mod::Libenzdb; use Mod::DBtank; use Mod::APIfunc; use Mod::Pricing; @@ -36,14 +35,13 @@ sub tpl(){ my $varenv = shift; my $node_meta = shift; my $users_dms = shift; - my $set_main_id = shift; + my $ctf = shift; + my $ctadr = shift; my $ctt = shift; - my $return = shift || ""; my $q = new CGI; my $cf = new Config; my $lb = new Libenz; - my $db = new Libenzdb; my $dbt = new DBtank; my $apif = new APIfunc; my $but = new Buttons; @@ -67,23 +65,36 @@ sub tpl(){ my $c_idpos = $R::c_idpos || $R::pos_id || 0; my $cttpos = { c_id => 0 }; - my $ctf = { c_id => 0 }; - my $pref_cu = { - table => "contentuser", - fetch => "one", - c_id => $dbt->{shareedms_conf}->{parent_id}, - }; - $ctf = $dbt->fetch_tablerecord($dbh,$pref_cu); - - my $ctadr = $db->get_content1("contentadr",$ctt->{int10}); my $vibuchen_mtime = "(nicht verfügbar, siehe Internas und log)"; my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int03=Menge (Miet - Gratis Zeit)","int02=Preis","int07=Rabatt","int04=Gesamt"); - my $tplf = $db->get_tpl("201");#Kunden-Faktura, ex Firma + my $tplf = $dbt->get_tpl($dbh,201);#Kunden-Faktura Firma my @tplf_order = split /,/,$tplf->{tpl_order}; ($cttpos,$rows) = $dbt->collect_contentpos($dbh,"contenttrans",$ctt->{content_id}); + my $station_all = {}; + my $pref_st = { + table => "content", + fetch => "all", + keyfield => "c_id", + template_id => 225, + }; + $station_all = $dbt->fetch_record($dbh,$pref_st); + + my @_stationvalxx = ("null:"); + foreach my $rid (sort { $station_all->{$a}->{int04} <=> $station_all->{$b}->{int04} } keys (%$station_all)){ + push (@_stationvalxx, "$station_all->{$rid}->{int04}:$station_all->{$rid}->{int04} - $station_all->{$rid}->{txt01}"); + } + my @_rentalstate_valxx = (); + foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{bike_state} })) { + push @_rentalstate_valxx, "$s_key:$dbt->{copri_conf}->{bike_state}->{$s_key}" if($s_key =~ /1|2|3/); + } + my @_lock_valxx = (); + foreach my $s_key (sort keys (%{ $dbt->{copri_conf}->{lock_state} })) { + push @_lock_valxx, "$s_key:$dbt->{copri_conf}->{lock_state}->{$s_key}"; + } + foreach my $id (keys(%$cttpos)){ if(ref($cttpos->{$id}) eq "HASH"){ if($cttpos->{$id}->{int26}){ @@ -131,7 +142,6 @@ EOF #Parts Header print $q->start_form(-name=>'spartform'); - $c_idpos = $1 if($return && $return =~ /pos_id=(\d+)/); print $q->hidden(-name=>'trans2edit', -value=>"transpos", -override=>'1'),"\n"; print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset"),"\n" if($R::offset); print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit"),"\n" if($R::limit); @@ -200,7 +210,6 @@ EOF my $set_style=""; my $occupied_style = ""; my $time_style = ""; - #$occupied_style = "color:#ff1493" if($cttpos->{$id}->{txt10} =~ /occupied|requested|canceled/); $occupied_style = "color:#ff1493" if($cttpos->{$id}->{int10} == 2 ||$cttpos->{$id}->{int10} == 3 || $cttpos->{$id}->{int10} == 6); #max. Rechnungspositionen @@ -302,15 +311,10 @@ EOF my ($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = $lb->split_date($pricing->{end_time}); print "\n"; - print $q->textarea(-class=>'autos',-style=>"border: 1px solid #ededed;",-name=>"$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-rows=>"3",-cols=>60, -autofocus=>1),"
\n"; + print $q->textarea(-class=>'autos',-style=>"border: 1px solid #ededed;",-name=>"$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-rows=>"2",-cols=>60, -autofocus=>1),"
\n"; #if Traiff Nr. if($cttpos->{$id}->{int09}){ - print $q->span({-style=>"$txtstyle $set_style"}, "Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}
"), "\n"; - - print $q->span({-style=>"$txtstyle $set_style"}, - "Endstation: ", $q->textfield(-class=>'etxt',-name=>"int04",-default=>"$cttpos->{$id}->{int04}",-size=>"5",-maxlength=>40), - "GPS: ", $q->textfield(-class=>'etxt',-name=>"txt06",-default=>"$cttpos->{$id}->{txt06}",-size=>"30",-maxlength=>40)),"
\n"; print $q->span({-style=>"$txtstyle $set_style"},"Mietzeit: ", $q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_date",-default=>"$s_dd.$s_mo.$s_yy",-size=>"8",-maxlength=>10), @@ -318,7 +322,16 @@ EOF $q->textfield(-class=>'etxt',-name=>"s_mi",-default=>"$s_mi",-size=>"1",-maxlength=>2)," → ", $q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"8",-maxlength=>10), $q->textfield(-class=>'etxt',-name=>"e_hh",-default=>"$e_hh",-size=>"1",-maxlength=>2),":", - $q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"1",-maxlength=>2)),"\n"; + $q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"1",-maxlength=>2)),"
\n"; + + my $end_station = "null"; + $end_station = $cttpos->{$id}->{int04} if(looks_like_number($cttpos->{$id}->{int04})); + print $q->span({-style=>"$txtstyle $set_style"},"Station Start: $cttpos->{$id}->{int06}, End: ",$but->selector_class("int04","eselect","width:250px;","$end_station",@_stationvalxx)),"
\n"; + #print $q->span({-style=>"$txtstyle $set_style"},"GPS: $cttpos->{$id}->{txt06}"),"
\n"; + + print $q->span({-style=>"$txtstyle $set_style"},"Rental State:", $but->selector_class("int10","eselect","",$cttpos->{$id}->{int10},@_rentalstate_valxx)); + print $q->span({-style=>"$txtstyle $set_style"},"Lock State:",$but->selector_class("int20","eselect","",$cttpos->{$id}->{int20},@_lock_valxx)),"
\n"; + print $q->span({-style=>"$txtstyle $set_style"}, "Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}"), "
\n"; } print "
Bemerkung (Mietjournal) $cttpos->{$id}->{txt23}\n" if($cttpos->{$id}->{txt23}); @@ -424,25 +437,24 @@ EOF } print "
\n"; } - if($cttpos->{$id}->{txt01} || $cttpos->{$id}->{int09}){ - #$line_count2++; - $cttpos->{$id}->{txt01} =~ s/fixed/\fixed\<\/span\>/; - $cttpos->{$id}->{txt01} =~ s/defect/\defect\<\/span\>/; - my $bike=""; - my $tariff = ""; - $bike = "$cttpos->{$id}->{$key}" if($cttpos->{$id}->{$key}); - $tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04}); - print $q->span("$bike $tariff
"),"\n"; - } - if($cttpos->{$id}->{int06} && $cttpos->{$id}->{int04}){ - print $q->span("Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}, GPS: $cttpos->{$id}->{txt06}"),"\n"; - } + $cttpos->{$id}->{txt01} =~ s/fixed/\fixed\<\/span\>/; + $cttpos->{$id}->{txt01} =~ s/defect/\defect\<\/span\>/; + print $q->span("$cttpos->{$id}->{$key}"),"
\n"; if($pricing->{start_time} && $pricing->{end_time}){ my $start_time = $lb->time4de($pricing->{start_time},"1"); my $end_time = $lb->time4de($pricing->{end_time},"1"); - print "
\n"; - print $q->span({-style=>"$time_style"}, "Mietzeit: $start_time → $end_time"),"\n"; + print $q->span({-style=>"$time_style"}, "Mietzeit: $start_time → $end_time"),"
\n"; } + + if($cttpos->{$id}->{int06} || $cttpos->{$id}->{int04}){ + print $q->span("Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}"),"
\n"; + } + if($cttpos->{$id}->{int09}){ + my $tariff = ""; + $tariff = "Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04}); + print $q->span("$tariff"),"
\n"; + } + print "
Bemerkung (Mietjournal) $cttpos->{$id}->{txt23}\n" if($cttpos->{$id}->{txt23}); print "\n"; }elsif($key =~ /txt/){ @@ -534,9 +546,6 @@ EOF print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset"),"\n" if($R::offset); print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit"),"\n" if($R::limit); - $set_main_id=$ctt->{main_id} if($ctt->{main_id} && $ctt->{main_id} > "300000"); - print $q->hidden(-name=>'set_main_id', -value=>"$set_main_id", -override=>'1'),"\n"; - if($users_dms->{int03} == 2){ #only if user is also a primary DMS user with invoice rw @@ -616,21 +625,9 @@ EOF } } } - - #disabled 2022-11-23, needs more testing. Add +10.- on preauth - if(1==2 && $users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}){ - #further payone capture are only allowed if OPOS && sequence && TXID is set - if($ctt->{int14} && $ctt->{int18} && $ctt->{txt16}){ - print $q->div({-class=>'element6',-style=>'clear:both;'},"Test. Weitere Payone Einzüge über die vorhandene TXID $ctt->{txt16} (vorautorisiert Summe beachten) durch manuelle inkrement der Sequencenr mit +1", $q->textfield(-class=>'etxt',-name=>"payone_sequence",-default=>"", -override=>'1',-size=>"1",-maxlength=>1)),"\n"; - } - #Payone reset if OPOS and TXID - if($ctt->{int14} && $ctt->{txt16}){ - print $q->div({-class=>'element6',-style=>'clear:both;'},"Test. Payone reset löscht den Vorgang mit der TXID $ctt->{txt16} und versucht einen erneuten Einzug", $but->checkbox("1","payone_reset","0","Payone reset","")),"\n"; - } - } - } print $q->end_form; + #end set_stateform my $praefix = "$ctt->{txt00}-$varenv->{praefix}"; print $q->div({-style=>"clear:both;height:0.1px;"},""),"\n"; @@ -643,7 +640,7 @@ EOF print $q->hidden(-name=>'tpl_id4trans', -override=>'1', -value=>"$ctt->{template_id}"),"\n"; print $q->hidden(-name=>'offset', -override=>'1', -value=>"$R::offset"),"\n" if($R::offset); print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit"),"\n" if($R::limit); - print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! $ctt->{txt00} eMail ", $but->singlesubmit1("ct_trans","send_invoice_again","")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); + #print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "eMail wurde nicht versandt! $ctt->{txt00} eMail ", $but->singlesubmit1("send_invoice_again","eMail nochmals senden","")),"\n" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); print $q->end_form; } @@ -666,13 +663,18 @@ EOF print $q->hidden(-name=>'limit', -override=>'1', -value=>"$R::limit"),"\n" if($R::limit); print $q->hidden(-name=>'sum_paid', -override=>'1',-value=>"$sum_paid"); - print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "Copri-Ticket-mailing: ", $but->selector_class("cms_message_key","eselect","width:250px;","",@_valxx), "mit PDF", $but->checkbox("1","print_pdf","1","mit PDF",""), $but->singlesubmit1("ct_trans","send_invoice_cms","")),"\n"; + print $q->div({-style=>"padding:0.5em;font-size:0.81em;width:98%;text-align:right;"}, "Copri-Ticket-mailing: ", $but->selector_class("cms_message_key","eselect","width:250px;","",@_valxx), "mit PDF", $but->checkbox("1","print_pdf","1","mit PDF",""), $but->singlesubmit1("send_invoice_cms","eMail senden","")),"\n"; print $q->end_form; } - $db->updater("contenttrans","c_id","$ctt->{content_id}","txt20","$accounting_start - $accounting_end","","","","","no_time") if(!$int05 && $accounting_start && $accounting_end); - $db->updater("contenttrans","c_id","$ctt->{content_id}","int15","$sum_preauth","","","","","no_time") if($sum_preauth || $sum_preauth == 0); - + if(!$int05 && $accounting_start && $accounting_end){ + my $update_ctt = { + table => "contenttrans", + mtime => "no_time", + c_id => $ctt->{content_id}, + }; + $dbt->update_one($dbh,$update_ctt,"txt20='$accounting_start - $accounting_end'"); + } return "$line_count2"; } 1; diff --git a/copri4/main/src/scripts/Ilockit_cloud.pl b/copri4/main/src/scripts/Ilockit_cloud.pl index 3d7398d..4410487 100755 --- a/copri4/main/src/scripts/Ilockit_cloud.pl +++ b/copri4/main/src/scripts/Ilockit_cloud.pl @@ -125,8 +125,8 @@ sub utctime { #'deviceTime' => '2021-10-14T08:19:35.000+0000', #'serverTime' => '2021-10-14T07:19:37.000+0000', - $utc_epoch -= 2*60*60;# -2 std (Sommerzeit) - #$utc_epoch -= 1*60*60;# -1 std (Winterzeit) + #$utc_epoch -= 2*60*60;# -2 std (Sommerzeit) + $utc_epoch -= 1*60*60;# -1 std (Winterzeit) $utc_epoch += $latency; $time = gmtime($utc_epoch);#epoch @@ -433,8 +433,8 @@ sub get_positions { if($theftmove_count < 10){ system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''"); print FILE "$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/mailTransportcms.pl '$op_name->{syshost}' 'send_alarm2hotline' '1' '$c_id' ''\n\n"; - #only if not requested or occupied - if($op_name->{sms_alert} && $record_cc->{$id}->{int10} !~ /2|3/){ + #only if locked + if($op_name->{sms_alert} && $record_cc->{$id}->{int20} == 1){ system("$dbt->{copri_conf}->{basedir}/$op_name->{syshost}/src/scripts/sms_message.pl '$op_name->{syshost}' 'send_alarm2hotline' '' '$c_id'"); } } diff --git a/copri4/main/src/scripts/Ilockit_trackingcloud.pl b/copri4/main/src/scripts/Ilockit_trackingcloud.pl index 5ecfa3e..2f6ac23 100755 --- a/copri4/main/src/scripts/Ilockit_trackingcloud.pl +++ b/copri4/main/src/scripts/Ilockit_trackingcloud.pl @@ -87,8 +87,8 @@ sub utctime { my $time = Time::Piece->strptime($date, "%Y-%m-%dT%H:%M:%S"); print FILE "localtime: " . $time->datetime . "\n";#localtime my $utc_epoch = $time->epoch; - $utc_epoch -= 2*60*60;# -2 std (Sommerzeit) - #$utc_epoch -= 1*60*60;# -1 std (Winterzeit) + #$utc_epoch -= 2*60*60;# -2 std (Sommerzeit) + $utc_epoch -= 1*60*60;# -1 std (Winterzeit) $utc_epoch += $latency; $time = gmtime($utc_epoch);#epoch print FILE "utctime: " . $time->datetime . "\n";#utc zulu date time diff --git a/copri4/main/src/scripts/mailTransportcms.pl b/copri4/main/src/scripts/mailTransportcms.pl index dea7cf0..fca69b2 100755 --- a/copri4/main/src/scripts/mailTransportcms.pl +++ b/copri4/main/src/scripts/mailTransportcms.pl @@ -391,7 +391,7 @@ sub send_occupied2hotline { }; my $cttpos = { c_id => 0 }; - $cttpos = $dbt->collect_transpos($dbh,$search); + $cttpos = $dbt->collect_transpos($dbh,$search,1); my $bike = ""; foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){ diff --git a/copri4/main/src/scripts/sms_message.pl b/copri4/main/src/scripts/sms_message.pl index 891b5f0..8908889 100755 --- a/copri4/main/src/scripts/sms_message.pl +++ b/copri4/main/src/scripts/sms_message.pl @@ -72,7 +72,7 @@ if($todo eq "24h_occupied"){ my $dt1 = DateTime->now(time_zone => "Europe/Berlin"); my $cttpos = { c_id => 0 }; - $cttpos = $dbt->collect_transpos($dbh,$search); + $cttpos = $dbt->collect_transpos($dbh,$search,1); foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){ if($cttpos->{$pid}->{int10} == 3){ diff --git a/copri4/shareedms-operator/src/Lib/Mlogic.pm b/copri4/shareedms-operator/src/Lib/Mlogic.pm index 033ee21..d19110e 100755 --- a/copri4/shareedms-operator/src/Lib/Mlogic.pm +++ b/copri4/shareedms-operator/src/Lib/Mlogic.pm @@ -347,8 +347,8 @@ sub tplselect(){ require "Mod/Failure.pm"; &Failure::tpl($varenv,$users_dms->{u_id},$feedb_req); }else{ - if(($R::ct_trans !~ /close/) && ($ct_table =~ /contenttrans/) && ($R::ct_trans || $R::trans2edit || $R::ctpos_activ || $R::select_part || $R::set_main_id)){ - &Modalbox::mobox($varenv,$node_meta,$users_dms,$feedb_req); + if(($R::ct_trans !~ /close/) && ($ct_table =~ /contenttrans/) && ($R::ct_trans || $R::trans2edit || $R::select_part || $R::set_main_id || $R::set_state)){ + &Modalbox::mobox($varenv,$node_meta,$users_dms,$feedb_req) if($R::ct_trans ne "delete_trans"); }elsif(($R::ct_trans !~ /close/) && ($ct_table =~ /content$|contentadr|contentuser|contentpos|users$|contenttranspos/ && ($R::ct_trans || $R::rel_edit || $R::base_edit)) || ($R::node2edit && $R::node2edit =~ /edit/)){ &Modalbox3::mobox3($varenv,$node_meta,$users_dms,$feedb_req) if($R::rel_edit !~ /delete|save/ && $R::ct_trans !~ /delete/ && $R::base_edit !~ /delete|save_pos/ && !$R::service_id); }