diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index 5b9dbbb..d19a1cf 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -565,7 +565,7 @@ sub collect_post(){ my $ct_where = "1=1"; my $cp_where = "1=1"; my $ctcp_where = "1=1"; - my $poscid; + my $poscid = ""; if($fetch->{table} eq "content" && $fetch->{table_pos} eq "contentpos"){ #*2 diff --git a/copri4/main/src/Mod/Indexsharee.pm b/copri4/main/src/Mod/Indexsharee.pm index 2a7607c..e1de5b1 100755 --- a/copri4/main/src/Mod/Indexsharee.pm +++ b/copri4/main/src/Mod/Indexsharee.pm @@ -391,7 +391,7 @@ sub handler { #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}); + $return = $pl->insert_contenttranspos($R::cc_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 diff --git a/copri4/main/src/Mod/Prelib.pm b/copri4/main/src/Mod/Prelib.pm index 9562272..d411ba9 100755 --- a/copri4/main/src/Mod/Prelib.pm +++ b/copri4/main/src/Mod/Prelib.pm @@ -55,7 +55,7 @@ my $debug=1; #part or fee to invoice sub insert_contenttranspos { my $self = shift; - my $c_id = shift || "";#part + my $cc_id = shift || "";#part my $ca_id = shift || "";#adr my $ct_id = shift || "";#invoice my $owner = shift || ""; @@ -63,39 +63,56 @@ sub insert_contenttranspos { my $dbh = ""; my $feedb = { message => "" }; - if(looks_like_number($c_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){ - my $pref_cc = { + if(looks_like_number($cc_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){ + my $pref = { + table => "contenttrans", + table_pos => "contenttranspos", + fetch => "one", + template_id => "218",#Mietjournal tpl_id + ct_id => $ct_id, + "ct.state" => "is::null", + }; + + my $ctpos = { c_id => 0 }; + $ctpos = $dbt->collect_post($dbh,$pref); + + if($ctpos->{c_id}){ + + my $pref_cc = { table => "content", fetch => "one", template_id => "IN::(229)", - c_id => $c_id, + c_id => $cc_id, }; - my $cc_part = { c_id => 0 }; - $cc_part = $dbt->fetch_record($dbh,$pref_cc); + my $cc_part = { c_id => 0 }; + $cc_part = $dbt->fetch_record($dbh,$pref_cc); - my $pref_ca = { + 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 $ctadr = { c_id => 0 }; + $ctadr = $dbt->fetch_record($dbh,$pref_ca); - my $pos_id = 0; - if($cc_part->{int02}){ + 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{ + }else{ $feedb->{message} = "failure::Fehler, VK Preis von Artikel Nr. $cc_part->{barcode} nicht definiert."; - } - if($pos_id > 0){ + } + 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, die Rechnung ist bereits gebucht. Das hinzufügen einer weiteren Rechnungsposition wird somit abgelehnt."; + } }else{ - $feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($c_id && $ca_id && $ct_id)"; + $feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($cc_id && $ca_id && $ct_id)"; } $feedb->{u_rows} = $u_rows; return $feedb; @@ -162,10 +179,10 @@ sub save_contenttranspos { fetch => "one", template_id => "218",#Mietjournal tpl_id c_id => $c_id, - "ct.close_time" => "is::null", + "ct.state" => "is::null", }; - my $ctpos = {}; + my $ctpos = { c_id => 0 }; $ctpos = $dbt->collect_post($dbh,$pref); my $pricing = {}; @@ -200,12 +217,13 @@ sub save_contenttranspos { if($ctpos->{c_id}){ $u_rows += $dbt->update_record($dbh,$update_pos,$ctpos); }else{ - $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen"; + $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht"; } } #again to get setted date-times $ctpos = $dbt->collect_post($dbh,$pref); + #print "$R::start_date $s_hh:$s_mi | $R::start_date $e_hh:$e_mi xxxxxxxxx
";exit; ($pricing,$counting) = $pri->counting_rental(\%varenv,$ctpos,"calc_price"); $update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38})); $update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39})); @@ -229,7 +247,7 @@ sub save_contenttranspos { template_id => "218",#Mietjournal tpl_id start_time => ">::$end_time", barcode => $ctpos->{barcode}, - "ct.close_time" => "is::null", + "ct.state" => "is::null", }; my $ctpos2ck = { c_id => 0 }; @@ -273,7 +291,7 @@ sub save_contenttranspos { $u_rows += $dbt->update_record($dbh,$ctpref,$ctpref); } }else{ - $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen"; + $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht"; } } @@ -289,10 +307,10 @@ sub save_contenttranspos { fetch => "one", template_id => "218",#Mietjournal tpl_id c_id => $c_id, - "ct.close_time" => "is::null", + "ct.state" => "is::null", }; - my $ctpos = {}; + my $ctpos = { c_id => 0 }; $ctpos = $dbt->collect_post($dbh,$pref); my $update_pos = { @@ -307,7 +325,7 @@ sub save_contenttranspos { if($ctpos->{c_id}){ $u_rows += $dbt->update_record($dbh,$update_pos,$ctpos); }else{ - $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen"; + $feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht"; } }else{ $feedb->{message} = "failure::Fehler, es sind nur numerische Werte erlaubt."; diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index 0cfd16e..c2baead 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -98,9 +98,10 @@ sub counting_rental { my $computed_end_time = $ctpos->{end_time} || $today4db; $computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3); + my $computed_start_time = $ctpos->{start_time} || $today4db;#should be only used on parts #main counting rental time and convert it to minute - my $dt0 = DateTime::Format::Pg->parse_datetime($ctpos->{start_time}); + my $dt0 = DateTime::Format::Pg->parse_datetime($computed_start_time); my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time); my $dur10 = $dt1->subtract_datetime($dt0); my ($durdd,$durhh,$durmm) = $dur10->in_units( 'days', 'hours','minutes' ); @@ -247,7 +248,7 @@ sub counting_rental { $total_price = sprintf('%.2f', $total_price); $total_price = $total_price * $ctpos->{int01} if($ctpos->{int01}); - $return->{start_time} = "$ctpos->{start_time}"; + $return->{start_time} = "$computed_start_time"; $return->{end_time} = "$computed_end_time"; $return->{freed_time} = "$freed_time"; $return->{computed_hours} = "$computed_hours"; diff --git a/copri4/main/src/Mod/Printpreview.pm b/copri4/main/src/Mod/Printpreview.pm index 6d76763..81651e0 100755 --- a/copri4/main/src/Mod/Printpreview.pm +++ b/copri4/main/src/Mod/Printpreview.pm @@ -246,8 +246,8 @@ td { $position = "position:absolute; top: $h_toppx;" if($h_top); my $height = "120px;"; - my $margin = "0 0 200px 0;"; - if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){ + my $margin = "0 0 100px 0;"; + if($dbt->{operator}->{$varenv{dbname}}->{project} =~ /Bayern|Freiburg/){ $height = "200px;"; $margin = "0;"; } @@ -262,8 +262,8 @@ td { $ctt->{txt01} = $lb->newline($ctt->{txt01},"","0"); my $height = "120px;"; - my $margin = "0 0 200px 0;"; - if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){ + my $margin = "0 0 100px 0;"; + if($dbt->{operator}->{$varenv{dbname}}->{project} =~ /Bayern|Freiburg/){ $height = "200px;"; $margin = "0;"; } diff --git a/copri4/main/src/Tpl/Calorin.pm b/copri4/main/src/Tpl/Calorin.pm index b56ff31..dc28858 100755 --- a/copri4/main/src/Tpl/Calorin.pm +++ b/copri4/main/src/Tpl/Calorin.pm @@ -189,7 +189,7 @@ sub tpl(){ $search = { %$search, start_date_time => "$start_date_time", end_date_time => "$end_date_time", - } if(!$R::cttpos_id); + } if(!$R::cttpos_id && !$R::ct_id); #$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 diff --git a/copri4/main/src/Tpl/Liste3.pm b/copri4/main/src/Tpl/Liste3.pm index 3bfe6fc..1e8913f 100755 --- a/copri4/main/src/Tpl/Liste3.pm +++ b/copri4/main/src/Tpl/Liste3.pm @@ -417,8 +417,8 @@ sub tpl(){ #$ctrel = $db->get_ctrel("contenttrans","",$lang,"",$users_dms->{c_id4trans},$users_dms->{tpl_id4trans}); #without limit it will takes only one dataset - #if(($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) - if((($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) && ($limit > $varenv{limit})){ + if(($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)){ + #if((($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) && ($limit > $varenv{limit})){ $ct4rel = $db->collect_cid($table,$lang,$tpl_id,$R::rel_id,$R::barcode,"c_id",$c_id4trans); } @@ -827,7 +827,7 @@ sub tpl(){ #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;'})); + 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->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-512-copy.png", -style=>'height:1.3em;'})); } if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|225/)){