adding fees by rental editor

This commit is contained in:
ragu 2022-09-20 16:13:45 +02:00
parent 876d1e6df2
commit 80f7e5efe2
13 changed files with 103 additions and 80 deletions

View file

@ -845,16 +845,8 @@ div#Container_txt1 {
.linknav {margin:3px; color:white; font-size: 1em; text-decoration: none;}
.linknav:hover { background-color:white;color:black;}
.linknav1 {
padding:0.1em;
font-size:0.91em;
border:0px solid gray;
vertical-align:middle;
text-decoration: none;
}
.linknav1:hover {
color:silver;
}
.linknav1 {margin:3px; color:black; font-size: 1em; text-decoration: none;}
.linknav1:hover { background-color:black;color:white;}
.linknav2 {
margin:2px;
@ -878,28 +870,13 @@ div#Container_txt1 {
}
.linknav4 {
position:static;
color:white;
background-color:black;
margin:0;
padding:0.1em 0.4em;
text-decoration: none;
font-weight: bold;
padding:3px;
color:#333399;
font-size: 1em;
}
.linknav4:hover { color:silver;}
.linknav5 {
position:static;
color:#60c6f6;
background-color:black;
margin:0;
padding:0.1em 0.4em;
text-decoration: none;
font-weight: bold;
.linknav4:hover {
color:silver;
}
.linknav5:hover { color:silver;}
.headnav {
margin:0em 0em;

View file

@ -1422,7 +1422,6 @@ sub booking_update(){
$update_cc->{int14} = $1;
#$self->service_automatic($q) if($1 <= 40);
}
$update_cc->{txt15} = $q->escapeHTML($q->param('firmware')) if($q->param('firmware'));
$update_cc->{txt17} = $Ilockit_GUID if($Ilockit_GUID);
}
#end Ilockit || sigo
@ -1451,6 +1450,7 @@ sub booking_update(){
mtime => "now()",
owner => "$owner",
};
$update_cc->{txt28} = $q->escapeHTML($q->param('firmware')) if($q->param('firmware'));
#only by system=Ilockit
if($record_pos->{int11} eq "2" && $q->param('voltage') && $q->param('voltage') =~ /(\d+)/){
@ -1469,6 +1469,7 @@ sub booking_update(){
$update_pos->{txt21} = $q->escapeHTML($q->param('user_device')) if($q->param('user_device'));
$update_pos->{txt26} = $q->escapeHTML($user_agent) if($user_agent);
$update_pos->{txt27} = $q->escapeHTML($q->param('app_debug')) if($q->param('app_debug'));
$update_pos->{txt28} = $q->escapeHTML($q->param('firmware')) if($q->param('firmware'));
}
my $lock_value = 0;

View file

@ -921,7 +921,7 @@ sub update_record(){
$set .= " $key=null,";#we need this for null values in operators loop
}
}
if($key =~ /(mtime|atime)$/){
if($key =~ /(mtime|atime|pay_time|invoice_time)$/){
if($value && $value =~ /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}$/){
$set .= " $key='$value',";
}else{
@ -1104,8 +1104,6 @@ sub collect_transpos {
my $search = shift;
$search->{offset} = 0 if(!$search->{offset});
my $updown = "ASC";
$updown = "DESC" if($search->{cal_sort_updown} && $search->{cal_sort_updown} eq "down");
my $where = "where cp.ct_id=ct.c_id";
foreach my $key (keys (%$search)){
@ -1118,6 +1116,7 @@ sub collect_transpos {
$where .= " and cp.ct_name = '$search->{$key}'" if($key eq "cp_ct_name" && $search->{$key});
$where .= " and ct.ct_name = '$search->{$key}'" if($key eq "ct_ct_name" && $search->{$key});
$where .= " and ct.txt06 ilike '$search->{$key}%'" if($key eq "ct_txt06" && $search->{$key});#PLZ
$where .= " and cp.$key = '$search->{$key}'" if($key eq "ct_id" && looks_like_number($search->{$key}));
$where .= " and cp.$key = $search->{$key}" if($key eq "int10" && looks_like_number($search->{$key}));#bike_state
$where .= " and cp.$key = $search->{$key}" if($key eq "int20" && looks_like_number($search->{$key}));#lock_state
$where .= " and cp.$key = $search->{$key}" if($key eq "barcode" && looks_like_number($search->{$key}));
@ -1133,7 +1132,7 @@ sub collect_transpos {
$where .= " and cp.start_time <= $search->{start_time_interval}";
}
$where .= " ORDER BY cp.end_time $updown LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
$where .= " ORDER BY cp.c_id DESC LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
my $sql = "SELECT cp.*,ct.txt07 AS phone from $search->{table} cp, contenttrans ct $where";
my $sth = $dbh->prepare($sql);
my $rc = $sth->execute();
@ -1149,8 +1148,6 @@ sub collect_theftpos {
my $search = shift;
$search->{offset} = 0 if(!$search->{offset});
my $updown = "ASC";
$updown = "DESC" if($search->{cal_sort_updown} && $search->{cal_sort_updown} eq "down");
my $where = "where 1=1";
foreach my $key (keys (%$search)){
@ -1167,7 +1164,7 @@ sub collect_theftpos {
$where .= " and cp.$key = $search->{$key}" if($key eq "int13" && looks_like_number($search->{$key}));#deviceId
$where .= " and cp.$key = $search->{$key}" if($key eq "owner" && looks_like_number($search->{$key}));
}
$where .= " ORDER BY cp.end_time $updown LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
$where .= " ORDER BY cp.c_id DESC LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
my $sth = $dbh->prepare("SELECT cp.* from $search->{table} cp $where");
my $rc = $sth->execute();
my $ct = $sth->fetchall_hashref("c_id");

View file

@ -383,10 +383,17 @@ sub handler {
$return = "failure::Abbruch. Schreibender Zugriff \"Faktura\" verweigert.";
}
}
#DMS Mietjournal
if($node_meta->{ct_table} eq "contenttranspos" && $R::base_edit eq "save_pos"){
$return = $pl->save_contenttranspos($R::c_id,$users_dms->{u_id});
}
#DMS insert part or fee
if($node_meta->{ct_table} eq "contenttranspos" && $R::insert_contenttranspos){
$return = $pl->insert_contenttranspos($R::c_id,$R::ca_id,$R::ct_id,$users_dms->{u_id});
}
$users_dms = $dbt->select_users($dbh,$users_dms->{u_id},"");#just to get update after save
#none DMS hosts ----------------------------------------------------

View file

@ -1314,7 +1314,7 @@ sub search_jsonadr(){
$sth = $dbh->prepare("SELECT ct.c_id AS id ,ct.$mjkey AS name FROM $table ct, relation rel WHERE ct.c_id=rel.content_id and rel.template_id=$template_id and $sel");
}else{
my $sel = "txt01 ilike '%$search%'";
$sth = $dbh->prepare("SELECT ct.txt01 || ' ,Nr. ' || ct.ct_name AS value, ct.txt01 AS vorname_name, ct.c_id FROM $table ct, relation rel WHERE ct.c_id=rel.content_id and rel.template_id=$template_id and $sel");
$sth = $dbh->prepare("SELECT ct.txt01 || ', ' || ct.txt08 AS value, ct.txt01 AS vorname_name, ct.c_id FROM $table ct, relation rel WHERE ct.c_id=rel.content_id and rel.template_id=$template_id and $sel");
}
my $rc = $sth->execute();
my $rows = $sth->rows;
@ -1333,25 +1333,12 @@ sub search_json(){
my $sel = "1=1";
my $sel2;
#pre_lager select only
if($mandant_id){
my $lager_id = $mandant_id . "0";
my $sth2 = $dbh->prepare("SELECT ct_name from contentuser where c_id='$lager_id'");
my $rc = $sth2->execute();
my $rel = $sth2->fetchrow_hashref();
my $pre_lager = "$rel->{ct_name}" || "";
$sel2 = " and (txt12 ilike '$pre_lager%' OR txt12 like '_')" if($pre_lager);
}
if($ct_name =~ /^\d+$/ && $table eq "content"){
$sel .= " and (ct_name ilike '$ct_name%' OR CAST(barcode AS text) like '$ct_name%')";
}else{
$sel .= " and ct_name ilike '$ct_name%'";
}
my $sth;
#$sel .= " and rel.template_id IN ($tpl_ids)";
#my $sth = $dbh->prepare("SELECT ct.ct_name || ' , Lager ' || ct.txt12 AS label, ct.ct_name AS value, ct.c_id FROM relation rel, content ct WHERE $sel");
#my $sth = $dbh->prepare("SELECT ct.ct_name || ' , Lager ' || ct.txt12 AS label, ct.ct_name AS value, ct.c_id FROM content ct WHERE $sel");
my $sth = "";
#If select only mandant specific warenstamm
if($dbt->{shareedms_conf}->{waren}){
@ -1363,13 +1350,6 @@ sub search_json(){
my $rc = $sth->execute();
my $rows = $sth->rows;
#if false lager (txt12) then global
if(!$varenv{waren_main_id} && $rows < 1){
$sth = $dbh->prepare("SELECT ct.ct_name || ' , Lager ' || ct.txt12 AS value, ct.ct_name AS spart_ct_name, ct.c_id FROM $table ct WHERE $sel");
$rc = $sth->execute();
$rows = $sth->rows;
}
$dbh->disconnect;
return $sth;
}

View file

@ -140,7 +140,7 @@ sub preauthorizationSEPA_main {
$reference = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-S-" . $ctt->{ct_name};
}
#if reference still set then count
if($ctt->{txt25}){
if($ctt->{txt25} && $ctt_rec->{payone_reset}){
if($ctt->{txt25} =~ /\d-\d$/){
my ($refbase,$sub) = split(/-/,$ctt->{txt25});
$sub++;
@ -279,7 +279,7 @@ sub preauthorizationCC_main {
$reference = $dbt->{operator}->{$varenv->{dbname}}->{oprefix} . "-C-" . $ctt->{ct_name};
}
#if reference still set then count
if($ctt->{txt25}){
if($ctt->{txt25} && $ctt_rec->{payone_reset}){
if($ctt->{txt25} =~ /\d-\d$/){
my ($refbase,$sub) = split(/-/,$ctt->{txt25});
$sub++;

View file

@ -52,6 +52,56 @@ my %varenv = $cf->envonline();
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $debug=1;
#part or fee to invoice
sub insert_contenttranspos {
my $self = shift;
my $c_id = shift || "";#part
my $ca_id = shift || "";#adr
my $ct_id = shift || "";#invoice
my $owner = shift || "";
my $dbh = "";
my $feedb = { message => "" };
if(looks_like_number($c_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){
my $pref_cc = {
table => "content",
fetch => "one",
template_id => "IN::(229)",
c_id => $c_id,
};
my $cc_part = { c_id => 0 };
$cc_part = $dbt->fetch_record($dbh,$pref_cc);
my $pref_ca = {
table => "contentadr",
fetch => "one",
template_id => "202",
c_id => "$ca_id",
};
my $ctadr = { c_id => 0 };
$ctadr = $dbt->fetch_record($dbh,$pref_ca);
my $pos_id = 0;
if($cc_part->{int02}){
$pos_id = $dbt->insert_pos($dbh,$ct_id,$cc_part,"",$ctadr,"","",$cc_part->{barcode},"0",$owner,"");
}else{
$feedb->{message} = "failure::Fehler, VK Preis von Artikel Nr. $cc_part->{barcode} nicht definiert.";
}
if($pos_id > 0){
$i_rows += 1;
$dbt->update_content4comp($dbh,$cc_part->{c_id},"-","1");
$feedb->{message} = "Artikel Nr. $cc_part->{barcode} erfolgreich hinzugefügt.";
}
}else{
$feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($c_id && $ca_id && $ct_id)";
}
$feedb->{u_rows} = $u_rows;
return $feedb;
}#end insert_contenttranspos
sub save_contenttranspos {
my $self = shift;
my $c_id = shift;
@ -341,6 +391,7 @@ sub set_workflow {
foreach my $id (sort { lc($cttpos->{$a}->{sort}) cmp lc($cttpos->{$b}->{sort}) } keys(%$cttpos)){
#reverse pos sum for example by Storno
$cttpos->{$id}->{int01} = $cttpos->{$id}->{int01} * -1 if($cttpos->{$id}->{int01} != 0);
$cttpos->{$id}->{txt23} = "Storno" if($cttpos->{$id}->{int01} == -1);
#$cttpos->{$id}->{int02} = $cttpos->{$id}->{int02} * -1 if($cttpos->{$id}->{int02} != 0);
#$cttpos->{$id}->{int07} = $cttpos->{$id}->{int07} * -1 if($cttpos->{$id}->{int07} != 0 && $cttpos->{$id}->{int08} == 1);#if Rabatt int08 != 1 alias €;

View file

@ -199,6 +199,7 @@ sub preinit(){
###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";

View file

@ -32,7 +32,7 @@ sub handler {
print $q->header(-type => "application/json", -charset => "utf-8");
open(FILE,">>/var/log/copri4/ajax_json.log") if($debug);
open(FILE,">>/var/log/copri-bike/ajax_json.log") if($debug);
print FILE "$now_dt|$main_id\n" if($debug);
foreach(@keywords){

View file

@ -334,6 +334,7 @@ EOF
if($key =~ /barcode/){
print $q->hidden(-name=>"$key",-override=>1,-value=>"$cttpos->{$key}"),"\n";
print $q->hidden(-name=>"ct_id",-override=>1,-value=>"$cttpos->{ct_id}"),"\n";
print $q->Tr(),"\n";
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms'}, $q->b("$prefix$cttpos->{$key}")),"\n";
@ -456,6 +457,12 @@ EOF
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms',-nowrap=>"1"},"&nbsp;\n");
}
#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=>'content1_cms'},"&nbsp;\n");
}
}#end edit position
#service-config

View file

@ -191,7 +191,8 @@ sub tpl(){
end_date_time => "$end_date_time",
} if(!$R::cttpos_id);
$search->{barcode} = $q->escapeHTML("$R::barcode") if($R::base_edit eq "save_pos" && $R::barcode);
#$search->{barcode} = $q->escapeHTML("$R::barcode") if($R::base_edit eq "save_pos" && $R::barcode);
$search->{ct_id} = $q->escapeHTML("$R::ct_id") if($R::ct_id);#done on save_pos and insert fee
if(!$start_chck && !$end_chck){
if($node_meta->{ct_table} eq "contenttranspos"){
@ -469,7 +470,7 @@ sub tpl(){
print $q->div({-style=>'float:left;margin-left:1em;'}, "&rarr; Faktura", $q->a({-class=>"linknav3",-style=>"$trans_style",-href=>"/DMS/Faktura?ct_trans=open\&c_id4trans=$c_id4trans\&tpl_id4trans=$tpl_id4trans\&kind_of_trans=Faktura\&owner=$users_dms->{owner}",-title=>"Faktura Terminal öffnen"},"\#$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;'}, " &rarr; $comment"),"\n";
print $q->div({-style=>'float:left;margin-left:1em;'}, " &rarr; $comment"),"\n" if($comment);
}elsif($node_meta->{ct_table} eq "contenttheftpos"){
my $speed = 0;
@ -500,9 +501,9 @@ sub tpl(){
#backward | forward
print $q->div({-style=>'float:left;padding:0.5em;'}, "Zeile: $offset - $offset_nr"),"\n";
print "<div style='padding:0.5em;'>\n";
print $q->a({-class=>"linknav",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>''},"< zurück ... ") if($offset >= $limit);
print $q->a({-class=>"linknav",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>''}," ... vorwärts >") if($nr >= $limit-10);
print "<div style='float:left;padding:0.5em;'>\n";
print $q->a({-class=>"linknav1",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>'backward'}," &larr; ") if($offset >= $limit);
print $q->a({-class=>"linknav1",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>'forward'}," &rarr;") if($nr >= $limit-10);
print "</div>\n";
print $q->end_form;

View file

@ -194,7 +194,6 @@ sub tpl(){
my ($daymarker,$raster_mmpx,$day4month) = $lb->month_line($users_dms);
my $rows = 0;
my $tpath = "";
#get Firma
my $ctf = $db->get_content1("contentuser","$dbt->{sharedms_conf}->{parent_id}");
@ -825,10 +824,12 @@ sub tpl(){
if($table =~ /content$|contentadr|contentnel/){
$ecol++;
print "<td class='tb_inst' style='$set_style' nowrap>\n";
#2021-06-08 disabled because dms must be browser-tab save
if(1==2 && $table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|224|229/)){#bikes|Gutschein|Zubehör
print $q->a({-class=>"editnav",-href=>"$tpath?ct_trans=add_transpos\&mandant_main_id=$dbt->{shareedms_conf}->{parent_id}\&kind_of_trans=$users_dms->{kind_of_trans}\&c_id=$ct4rel->{$id}->{content_id}\&owner=$users_dms->{u_id}",-title=>"zum $users_dms->{kind_of_trans} \#$ctrel->{ct_name} $ctrel->{txt01} hinzufügen"}, $q->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-512-copy.png", -style=>'height:1.3em;'}));
#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\&c_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->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-512-copy.png", -style=>'height:1.3em;'}));
}
if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|225/)){
my $rnid = $ct4rel->{$id}->{rel_id};
my $node_names = "failure $rnid | $relnod->{$rnid}->{content_id} == $ct4rel->{$id}->{c_id}";
@ -1351,10 +1352,10 @@ sub tpl(){
print $q->hidden(-name=>'tpl_id',-override=>'1', -value=>"$tpl_id");
print "<div id='jump_bottom' style='clear:both;border:0px dotted silver;height:35px;'>\n";
if($R::detail_search !~ /suchen/ && $rows > $limit && $nr > 0){
print $q->div({-style=>'float:left;padding:6px 0 0 20px;'},"Datensätze pro Seite:",$q->textfield(-style=>'height:16px;',-name=>"limit",-default=>"$limit",-size=>"3",-maxlength=>10)),"\n";
print $q->div({-style=>'float:left;padding:7px 0 0 10px;'},$but->singlesubmit3("detail_search","reload_search","$varenv{metahost}/img/refresh.png","height:14px;","Tabelle neu laden")),"\n";
}
#if($R::detail_search !~ /suchen/ && $rows > $limit && $nr > 0){
#print $q->div({-style=>'float:left;padding:6px 0 0 20px;'},"Datensätze pro Seite:",$q->textfield(-style=>'height:16px;',-name=>"limit",-default=>"$limit",-size=>"3",-maxlength=>10)),"\n";
#print $q->div({-style=>'float:left;padding:7px 0 0 10px;'},$but->singlesubmit3("detail_search","reload_search","$varenv{metahost}/img/refresh.png","height:14px;","Tabelle neu laden")),"\n";
#}
print $q->end_form;
my $offset_nr = $offset + $nr;
@ -1364,8 +1365,8 @@ sub tpl(){
#backward | forward
print "<div style='padding:6px 0 0 10px;'>\n";
print $q->a({-class=>"linknav",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>''},"< zurück ... ") if($offset >= $limit);
print $q->a({-class=>"linknav",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>''}," ... vorwärts >") if($counter >= $limit-10); #if($rows > $limit && $nr > 0);
print $q->a({-class=>"linknav1",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>'backward'},"&larr; ") if($offset >= $limit);
print $q->a({-class=>"linknav1",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>'forward'}," &rarr;") if($counter >= $limit-10); #if($rows > $limit && $nr > 0);
print "</div>\n";
print "</div>\n";
print $q->div({-style=>'padding:6px 0 6px 20px;text-decoration:underline;'}, "Symbol Legende"),"\n";

View file

@ -441,8 +441,8 @@ EOF
#backward | forward
print "<div style='padding:0.5em;'>\n";
print $q->a({-class=>"linknav",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>''},"< zurück ... ") if($offset >= $limit);
print $q->a({-class=>"linknav",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>''}," ... vorwärts >") if($nr >= $limit-10); #if($rows > $limit && $nr > 0);
print $q->a({-class=>"linknav1",-href=>"?go=backward_list;offset=$offset;limit=$limit",-title=>'backward'}," &larr; ") if($offset >= $limit);
print $q->a({-class=>"linknav1",-href=>"?go=forward_list;offset=$offset;limit=$limit",-title=>'forward'}," &rarr; ") if($nr >= $limit-10); #if($rows > $limit && $nr > 0);
print "</div>\n";
print $q->end_form,"\n";