Revision 4507456b
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
bin/mozilla/ap.pl | ||
---|---|---|
316 | 316 |
|
317 | 317 |
AP->setup_form($form); |
318 | 318 |
|
319 |
$form->{locked} = |
|
320 |
($form->datetonum($form->{transdate}, \%myconfig) <= |
|
321 |
$form->datetonum($form->{closedto}, \%myconfig)); |
|
322 |
|
|
323 | 319 |
$main::lxdebug->leave_sub(); |
324 | 320 |
} |
325 | 321 |
|
... | ... | |
436 | 432 |
my $follow_up_vc = $form->{vendor_id} ? SL::DB::Vendor->load_cached($form->{vendor_id})->name : ''; |
437 | 433 |
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; |
438 | 434 |
|
439 |
$::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js"); |
|
435 |
$::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_customer.js", "show_vc_details.js", "show_history.js", "follow_up.js", "kivi.Draft.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.File.js", "kivi.AP.js");
|
|
440 | 436 |
my $transdate = $::form->{transdate} ? DateTime->from_kivitendo($::form->{transdate}) : DateTime->today_local; |
441 | 437 |
my $first_taxchart; |
442 | 438 |
|
439 |
setup_ap_display_form_action_bar(); |
|
440 |
|
|
443 | 441 |
$form->header(); |
444 | 442 |
|
445 | 443 |
for my $i (1 .. $form->{rowcount}) { |
... | ... | |
568 | 566 |
print $::form->parse_html_template('ap/form_footer', { |
569 | 567 |
num_due => $num_due, |
570 | 568 |
num_follow_ups => $num_follow_ups, |
571 |
show_post_draft => ($transdate > $closedto) && !$::form->{id}, |
|
572 |
show_storno => $storno, |
|
573 | 569 |
}); |
574 | 570 |
|
575 | 571 |
$::lxdebug->leave_sub; |
... | ... | |
861 | 857 |
|
862 | 858 |
$main::auth->assert('ap_transactions'); |
863 | 859 |
|
864 |
map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
|
|
860 |
map { delete $form->{$_} } qw(printed emailed queued invnumber deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno); |
|
865 | 861 |
$form->{paidaccounts} = 1; |
866 | 862 |
$form->{rowcount}--; |
867 |
$form->{invdate} = $form->current_date(\%myconfig); |
|
868 |
&update; |
|
869 |
|
|
870 |
$main::lxdebug->leave_sub(); |
|
871 |
} |
|
872 |
|
|
873 |
sub delete { |
|
874 |
$main::lxdebug->enter_sub(); |
|
875 |
|
|
876 |
my $form = $main::form; |
|
877 |
my $locale = $main::locale; |
|
878 | 863 |
|
879 |
$main::auth->assert('ap_transactions'); |
|
880 |
|
|
881 |
$form->{title} = $locale->text('Confirm!'); |
|
882 |
|
|
883 |
$form->header; |
|
864 |
my $today = DateTime->today_local; |
|
865 |
$form->{transdate} = $today->to_kivitendo; |
|
866 |
$form->{duedate} = $form->{transdate}; |
|
884 | 867 |
|
885 |
delete $form->{header}; |
|
886 |
|
|
887 |
print qq| |
|
888 |
<form method=post action=$form->{script}> |
|
889 |
|; |
|
890 |
|
|
891 |
foreach my $key (keys %$form) { |
|
892 |
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); |
|
893 |
$form->{$key} =~ s/\"/"/g; |
|
894 |
print qq|<input type=hidden name=$key value="$form->{$key}">\n|; |
|
868 |
if ($form->{vendor_id}) { |
|
869 |
my $payment_terms = SL::DB::Vendor->load_cached($form->{vendor_id})->payment; |
|
870 |
$form->{duedate} = $payment_terms->calc_date(reference_date => $today)->to_kivitendo if $payment_terms; |
|
895 | 871 |
} |
896 | 872 |
|
897 |
print qq| |
|
898 |
<h2 class=confirm>$form->{title}</h2> |
|
899 |
|
|
900 |
<h4>| |
|
901 |
. $locale->text('Are you sure you want to delete Transaction') |
|
902 |
. qq| $form->{invnumber}</h4> |
|
903 |
|
|
904 |
<input name=action class=submit type=submit value="| |
|
905 |
. $locale->text('Yes') . qq|"> |
|
906 |
</form> |
|
907 |
|; |
|
873 |
&update; |
|
908 | 874 |
|
909 | 875 |
$main::lxdebug->leave_sub(); |
910 | 876 |
} |
911 | 877 |
|
912 |
sub yes { |
|
913 |
$main::lxdebug->enter_sub(); |
|
914 |
|
|
878 |
sub delete { |
|
915 | 879 |
my $form = $main::form; |
916 | 880 |
my %myconfig = %main::myconfig; |
917 | 881 |
my $locale = $main::locale; |
... | ... | |
930 | 894 |
$form->redirect($locale->text('Transaction deleted!')); |
931 | 895 |
} |
932 | 896 |
$form->error($locale->text('Cannot delete transaction!')); |
933 |
|
|
934 |
$main::lxdebug->leave_sub(); |
|
935 | 897 |
} |
936 | 898 |
|
937 | 899 |
sub search { |
... | ... | |
1180 | 1142 |
|
1181 | 1143 |
$main::lxdebug->leave_sub(); |
1182 | 1144 |
} |
1145 |
|
|
1146 |
sub setup_ap_display_form_action_bar { |
|
1147 |
my $transdate = $::form->datetonum($::form->{transdate}, \%::myconfig); |
|
1148 |
my $closedto = $::form->datetonum($::form->{closedto}, \%::myconfig); |
|
1149 |
my $is_closed = $transdate <= $closedto; |
|
1150 |
|
|
1151 |
my $change_never = $::instance_conf->get_ar_changeable == 0; |
|
1152 |
my $change_on_same_day_only = $::instance_conf->get_ar_changeable == 2 && ($::form->current_date(\%::myconfig) ne $::form->{gldate}); |
|
1153 |
|
|
1154 |
my $is_storno = IS->is_storno(\%::myconfig, $::form, 'ap', $::form->{id}); |
|
1155 |
my $has_storno = IS->has_storno(\%::myconfig, $::form, 'ap'); |
|
1156 |
|
|
1157 |
for my $bar ($::request->layout->get('actionbar')) { |
|
1158 |
$bar->add( |
|
1159 |
action => [ |
|
1160 |
t8('Update'), |
|
1161 |
submit => [ '#form', { action => "update" } ], |
|
1162 |
id => 'update_button', |
|
1163 |
accesskey => 'enter', |
|
1164 |
], |
|
1165 |
|
|
1166 |
combobox => [ |
|
1167 |
action => [ |
|
1168 |
t8('Post'), |
|
1169 |
submit => [ '#form', { action => "post" } ], |
|
1170 |
checks => [ 'kivi.AP.check_fields_before_posting' ], |
|
1171 |
disabled => $is_closed ? t8('The billing period has already been locked.') |
|
1172 |
: $is_storno ? t8('A canceled invoice cannot be posted.') |
|
1173 |
: ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.') |
|
1174 |
: ($::form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.') |
|
1175 |
: undef, |
|
1176 |
], |
|
1177 |
action => [ |
|
1178 |
t8('Post Payment'), |
|
1179 |
submit => [ '#form', { action => "post_payment" } ], |
|
1180 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1181 |
], |
|
1182 |
action => [ t8('Mark as paid'), |
|
1183 |
submit => [ '#form', { action => "mark_as_paid" } ], |
|
1184 |
confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'), |
|
1185 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1186 |
only_if => $::instance_conf->get_is_show_mark_as_paid, |
|
1187 |
], |
|
1188 |
], # end of combobox "Post" |
|
1189 |
|
|
1190 |
combobox => [ |
|
1191 |
action => [ t8('Storno'), |
|
1192 |
submit => [ '#form', { action => "storno" } ], |
|
1193 |
checks => [ 'kivi.AP.check_fields_before_posting' ], |
|
1194 |
confirm => t8('Do you really want to cancel this invoice?'), |
|
1195 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1196 |
: $has_storno ? t8('This invoice has been canceled already.') |
|
1197 |
: $is_storno ? t8('Reversal invoices cannot be canceled.') |
|
1198 |
: $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.') |
|
1199 |
: undef, |
|
1200 |
], |
|
1201 |
action => [ t8('Delete'), |
|
1202 |
submit => [ '#form', { action => "delete" } ], |
|
1203 |
confirm => t8('Do you really want to delete this object?'), |
|
1204 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') |
|
1205 |
: $change_never ? t8('Changing invoices has been disabled in the configuration.') |
|
1206 |
: $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.') |
|
1207 |
: $has_storno ? t8('This invoice has been canceled already.') |
|
1208 |
: $is_closed ? t8('The billing period has already been locked.') |
|
1209 |
: undef, |
|
1210 |
], |
|
1211 |
], # end of combobox "Storno" |
|
1212 |
|
|
1213 |
'separator', |
|
1214 |
|
|
1215 |
combobox => [ |
|
1216 |
action => [ t8('Workflow') ], |
|
1217 |
action => [ |
|
1218 |
t8('Use As New'), |
|
1219 |
submit => [ '#form', { action => "use_as_new" } ], |
|
1220 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1221 |
], |
|
1222 |
], # end of combobox "Workflow" |
|
1223 |
|
|
1224 |
combobox => [ |
|
1225 |
action => [ t8('more') ], |
|
1226 |
action => [ |
|
1227 |
t8('History'), |
|
1228 |
call => [ 'set_history_window', $::form->{id} * 1, 'glid' ], |
|
1229 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1230 |
], |
|
1231 |
action => [ |
|
1232 |
t8('Follow-Up'), |
|
1233 |
call => [ 'follow_up_window' ], |
|
1234 |
disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef, |
|
1235 |
], |
|
1236 |
action => [ |
|
1237 |
t8('Record templates'), |
|
1238 |
call => [ 'kivi.RecordTemplate.popup', 'ap_transaction' ], |
|
1239 |
], |
|
1240 |
action => [ |
|
1241 |
t8('Drafts'), |
|
1242 |
call => [ 'kivi.Draft.popup', 'ap', 'invoice', $::form->{draft_id}, $::form->{draft_description} ], |
|
1243 |
disabled => $::form->{id} ? t8('This invoice has already been posted.') |
|
1244 |
: $is_closed ? t8('The billing period has already been locked.') |
|
1245 |
: undef, |
|
1246 |
], |
|
1247 |
], # end of combobox "more" |
|
1248 |
); |
|
1249 |
} |
|
1250 |
} |
Auch abrufbar als: Unified diff
ActionBar: Verwendung in Kreditorenbuchungen