Revision 3ff7346d
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
bin/mozilla/oe.pl | ||
---|---|---|
293 | 293 |
$main::lxdebug->leave_sub(); |
294 | 294 |
} |
295 | 295 |
|
296 |
sub setup_oe_action_bar { |
|
297 |
my %params = @_; |
|
298 |
my $form = $::form; |
|
299 |
|
|
300 |
my $has_active_periodic_invoice; |
|
301 |
if ($params{obj}) { |
|
302 |
$has_active_periodic_invoice = |
|
303 |
$params{obj}->is_type('sales_order') |
|
304 |
&& $params{obj}->periodic_invoices_config |
|
305 |
&& $params{obj}->periodic_invoices_config->active |
|
306 |
&& ( !$params{obj}->periodic_invoices_config->end_date |
|
307 |
|| ($params{obj}->periodic_invoices_config->end_date > DateTime->today_local)) |
|
308 |
&& $params{obj}->periodic_invoices_config->get_previous_billed_period_start_date; |
|
309 |
} |
|
310 |
|
|
311 |
my $allow_invoice = $params{is_req_quo} |
|
312 |
|| $params{is_pur_ord} |
|
313 |
|| ($params{is_sales_quo} && $::instance_conf->get_allow_sales_invoice_from_sales_quotation) |
|
314 |
|| ($params{is_sales_ord} && $::instance_conf->get_allow_sales_invoice_from_sales_order); |
|
315 |
my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps; |
|
316 |
my @warn_p_invoice = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice) x!!$has_active_periodic_invoice; |
|
317 |
|
|
318 |
my $tpca_remainder = 0; |
|
319 |
|
|
320 |
for my $bar ($::request->layout->get('actionbar')) { |
|
321 |
$bar->add_actions([ t8('Update'), |
|
322 |
submit => [ '#form', { action_update => 1 } ], |
|
323 |
id => 'update_button', |
|
324 |
accesskey => 'enter', |
|
325 |
]); |
|
326 |
|
|
327 |
$bar->add_actions("combobox"); |
|
328 |
$bar->actions->[-1]->add_actions([ t8('Save'), |
|
329 |
submit => [ '#form', { action_save => 1 } ], |
|
330 |
checks => [ @req_trans_desc, @warn_p_invoice ], |
|
331 |
confirm => t8('Missing transport cost: #1 Are you sure?', $tpca_remainder), |
|
332 |
]); |
|
333 |
$bar->actions->[-1]->add_actions([ t8('Save as new'), |
|
334 |
submit => [ '#form', { action_save_as_new => 1 } ], |
|
335 |
checks => [ @req_trans_desc ], |
|
336 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
337 |
]); |
|
338 |
$bar->actions->[-1]->add_actions([ t8('Save and Close'), |
|
339 |
submit => [ '#form', { action_save_and_close => 1 } ], |
|
340 |
checks => [ @req_trans_desc, @warn_p_invoice ], |
|
341 |
confirm => t8('Missing transport cost: #1 Are you sure?', $tpca_remainder), |
|
342 |
]); |
|
343 |
$bar->add_actions([ t8('Delete'), |
|
344 |
submit => [ '#form', { action_delete => 1 } ], |
|
345 |
confirm => t8('Do you really want to delete this object?'), |
|
346 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') |
|
347 |
: ( ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete) |
|
348 |
|| ($params{is_pur_ord} && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.') |
|
349 |
: undef, |
|
350 |
]); |
|
351 |
|
|
352 |
$bar->add_actions('separator'); |
|
353 |
|
|
354 |
$bar->add_actions('combobox'); |
|
355 |
$bar->actions->[-1]->add_actions([ t8('Workflow'), |
|
356 |
disabled => 1, |
|
357 |
]); |
|
358 |
$bar->actions->[-1]->add_actions([ t8('Sales Order'), |
|
359 |
submit => [ '#form', { action_sales_order => 1 } ], |
|
360 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
361 |
]) if $params{is_sales_quo}; |
|
362 |
$bar->actions->[-1]->add_actions([ t8('Purchase Order'), |
|
363 |
submit => [ '#form', { action_sales_order => 1 } ], |
|
364 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
365 |
]) if $params{is_req_quo}; |
|
366 |
$bar->actions->[-1]->add_actions([ t8('Delivery Order'), |
|
367 |
submit => [ '#form', { action_delivery_order => 1 } ], |
|
368 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
369 |
]) if $params{is_sales_ord} || $params{is_pur_ord}; |
|
370 |
$bar->actions->[-1]->add_actions([ t8('Invoice'), |
|
371 |
submit => [ '#form', { action_invoice => 1 } ], |
|
372 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
373 |
]) if $allow_invoice; |
|
374 |
$bar->actions->[-1]->add_actions([ t8('Quotation'), |
|
375 |
submit => [ '#form', { action_quotation => 1 } ], |
|
376 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
377 |
]); |
|
378 |
$bar->actions->[-1]->add_actions([ t8('Request for Quotation'), |
|
379 |
submit => [ '#form', { action_reqest_for_quotation => 1 } ], |
|
380 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
381 |
]); |
|
382 |
|
|
383 |
$bar->add_actions('combobox'); |
|
384 |
$bar->actions->[-1]->add_actions([ t8('Export'), |
|
385 |
disabled => 1, |
|
386 |
]); |
|
387 |
$bar->actions->[-1]->add_actions([ t8('Print'), |
|
388 |
submit => [ '#form', { action_print => 1 } ], |
|
389 |
checks => [ @req_trans_desc ], |
|
390 |
]); |
|
391 |
$bar->actions->[-1]->add_actions([ t8('E Mail'), |
|
392 |
submit => [ '#form', { action_print => 1 } ], |
|
393 |
checks => [ @req_trans_desc ], |
|
394 |
]); |
|
395 |
$bar->add_actions('combobox'); |
|
396 |
$bar->actions->[-1]->add_actions([ t8('more'), |
|
397 |
disabled => 1, |
|
398 |
]); |
|
399 |
$bar->actions->[-1]->add_actions([ t8('History'), |
|
400 |
call => [ 'set_history_window', $form->{id} * 1, 'id' ], |
|
401 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
402 |
]); |
|
403 |
$bar->actions->[-1]->add_actions([ t8('Follow-Up'), |
|
404 |
call => [ 'follow_up_window' ], |
|
405 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
406 |
]); |
|
407 |
} |
|
408 |
} |
|
409 |
|
|
296 | 410 |
sub form_header { |
297 | 411 |
$main::lxdebug->enter_sub(); |
298 | 412 |
my @custom_hiddens; |
... | ... | |
308 | 422 |
# visible in form_footer too, so package local level and not my here. |
309 | 423 |
%TMPL_VAR = (); |
310 | 424 |
if ($form->{id}) { |
311 |
my $obj = SL::DB::Order->new(id => $form->{id})->load; |
|
312 |
$TMPL_VAR{warn_save_active_periodic_invoice} = |
|
313 |
$obj->is_type('sales_order') |
|
314 |
&& $obj->periodic_invoices_config |
|
315 |
&& $obj->periodic_invoices_config->active |
|
316 |
&& ( !$obj->periodic_invoices_config->end_date |
|
317 |
|| ($obj->periodic_invoices_config->end_date > DateTime->today_local)) |
|
318 |
&& $obj->periodic_invoices_config->get_previous_billed_period_start_date; |
|
319 |
|
|
320 |
$TMPL_VAR{oe_obj} = $obj; |
|
425 |
$TMPL_VAR{oe_obj} = SL::DB::Order->new(id => $form->{id})->load; |
|
321 | 426 |
} |
322 |
my $warn_save_active_periodic_invoice = $TMPL_VAR{warn_save_active_periodic_invoice}; |
|
323 | 427 |
|
324 | 428 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
325 | 429 |
|
... | ... | |
440 | 544 |
|
441 | 545 |
|
442 | 546 |
# original snippets: |
443 |
my $is_sales = scalar ($form->{type} =~ /^sales_/); # these vars are exported, so that the template |
|
444 |
my $is_order = scalar ($form->{type} =~ /_order$/); # may determine what to show |
|
445 |
my $is_sales_quo = scalar ($form->{type} =~ /sales_quotation$/); |
|
446 |
my $is_req_quo = scalar ($form->{type} =~ /request_quotation$/); |
|
447 |
my $is_sales_ord = scalar ($form->{type} =~ /sales_order$/); |
|
448 |
my $is_pur_ord = scalar ($form->{type} =~ /purchase_order$/); |
|
449 |
my $allow_invoice = $is_req_quo || $is_pur_ord || ($is_sales_quo && $::instance_conf->get_allow_sales_invoice_from_sales_quotation) || ($is_sales_ord && $::instance_conf->get_allow_sales_invoice_from_sales_order); |
|
450 |
my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps; |
|
451 |
my @warn_p_invoice = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice) x!!$warn_save_active_periodic_invoice; |
|
452 |
|
|
453 |
my $tpca_remainder = 0; |
|
547 |
my %type_check_vars = ( |
|
548 |
is_sales => scalar($form->{type} =~ /^sales_/), |
|
549 |
is_order => scalar($form->{type} =~ /_order$/), |
|
550 |
is_sales_quo => scalar($form->{type} =~ /sales_quotation$/), |
|
551 |
is_req_quo => scalar($form->{type} =~ /request_quotation$/), |
|
552 |
is_sales_ord => scalar($form->{type} =~ /sales_order$/), |
|
553 |
is_pur_ord => scalar($form->{type} =~ /purchase_order$/), |
|
554 |
); |
|
454 | 555 |
|
455 |
for my $bar ($::request->layout->get('actionbar')) { |
|
456 |
$bar->add_actions([ t8('Update'), |
|
457 |
submit => [ '#form', { action_update => 1 } ], |
|
458 |
id => 'update_button', |
|
459 |
accesskey => 'enter', |
|
460 |
]); |
|
461 |
$bar->add_actions("combobox"); |
|
462 |
$bar->actions->[-1]->add_actions([ t8('Save'), |
|
463 |
submit => [ '#form', { action_save => 1 } ], |
|
464 |
checks => [ @req_trans_desc, @warn_p_invoice ], |
|
465 |
confirm => t8('Missing transport cost: #1 Are you sure?', $tpca_remainder), |
|
466 |
]); |
|
467 |
$bar->actions->[-1]->add_actions([ t8('Save as new'), |
|
468 |
submit => [ '#form', { action_save_as_new => 1 } ], |
|
469 |
checks => [ @req_trans_desc ], |
|
470 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
471 |
]); |
|
472 |
$bar->actions->[-1]->add_actions([ t8('Save and Close'), |
|
473 |
submit => [ '#form', { action_save_and_close => 1 } ], |
|
474 |
checks => [ @req_trans_desc, @warn_p_invoice ], |
|
475 |
confirm => t8('Missing transport cost: #1 Are you sure?', $tpca_remainder), |
|
476 |
]); |
|
477 |
$bar->add_actions([ t8('Delete'), |
|
478 |
submit => [ '#form', { action_delete => 1 } ], |
|
479 |
confirm => t8('Do you really want to delete this object?'), |
|
480 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') |
|
481 |
: ( ($is_sales_ord && !$::instance_conf->get_sales_order_show_delete) |
|
482 |
|| ($is_pur_ord && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.') |
|
483 |
: undef, |
|
484 |
]); |
|
485 |
$bar->add_actions('separator'); |
|
486 |
$bar->add_actions('combobox'); |
|
487 |
$bar->actions->[-1]->add_actions([ t8('Workflow'), |
|
488 |
disabled => 1, |
|
489 |
]); |
|
490 |
$bar->actions->[-1]->add_actions([ t8('Sales Order'), |
|
491 |
submit => [ '#form', { action_sales_order => 1 } ], |
|
492 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
493 |
]) if $is_sales_quo; |
|
494 |
$bar->actions->[-1]->add_actions([ t8('Purchase Order'), |
|
495 |
submit => [ '#form', { action_sales_order => 1 } ], |
|
496 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
497 |
]) if $is_req_quo; |
|
498 |
$bar->actions->[-1]->add_actions([ t8('Delivery Order'), |
|
499 |
submit => [ '#form', { action_delivery_order => 1 } ], |
|
500 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
501 |
]) if $is_sales_ord || $is_pur_ord; |
|
502 |
$bar->actions->[-1]->add_actions([ t8('Invoice'), |
|
503 |
submit => [ '#form', { action_invoice => 1 } ], |
|
504 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
505 |
]) if $allow_invoice; |
|
506 |
$bar->actions->[-1]->add_actions([ t8('Quotation'), |
|
507 |
submit => [ '#form', { action_quotation => 1 } ], |
|
508 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
509 |
]); |
|
510 |
$bar->actions->[-1]->add_actions([ t8('Request for Quotation'), |
|
511 |
submit => [ '#form', { action_reqest_for_quotation => 1 } ], |
|
512 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
513 |
]); |
|
514 |
$bar->add_actions('combobox'); |
|
515 |
$bar->actions->[-1]->add_actions([ t8('Export'), |
|
516 |
disabled => 1, |
|
517 |
]); |
|
518 |
$bar->actions->[-1]->add_actions([ t8('Print'), |
|
519 |
submit => [ '#form', { action_print => 1 } ], |
|
520 |
checks => [ @req_trans_desc ], |
|
521 |
]); |
|
522 |
$bar->actions->[-1]->add_actions([ t8('E Mail'), |
|
523 |
submit => [ '#form', { action_print => 1 } ], |
|
524 |
checks => [ @req_trans_desc ], |
|
525 |
]); |
|
526 |
$bar->add_actions('combobox'); |
|
527 |
$bar->actions->[-1]->add_actions([ t8('more'), |
|
528 |
disabled => 1, |
|
529 |
]); |
|
530 |
$bar->actions->[-1]->add_actions([ t8('History'), |
|
531 |
call => [ 'set_history_window', $form->{id} * 1, 'id' ], |
|
532 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
533 |
]); |
|
534 |
$bar->actions->[-1]->add_actions([ t8('Follow-Up'), |
|
535 |
call => [ 'follow_up_window' ], |
|
536 |
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef, |
|
537 |
]); |
|
538 |
} |
|
556 |
setup_oe_action_bar(%type_check_vars); |
|
539 | 557 |
|
540 | 558 |
$form->header; |
541 | 559 |
if ($form->{CFDD_shipto} && $form->{CFDD_shipto_id} ) { |
... | ... | |
557 | 575 |
|
558 | 576 |
%TMPL_VAR = ( |
559 | 577 |
%TMPL_VAR, |
560 |
is_sales => $is_sales, |
|
561 |
is_order => $is_order, |
|
562 |
is_sales_quo => $is_sales_quo, |
|
563 |
is_req_quo => $is_req_quo, |
|
564 |
is_sales_ord => $is_sales_ord, |
|
565 |
is_pur_ord => $is_pur_ord, |
|
578 |
%type_check_vars, |
|
566 | 579 |
); |
567 | 580 |
|
568 | 581 |
$TMPL_VAR{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; |
Auch abrufbar als: Unified diff
ActionBar: Setup in oe.pl in eigene Funktion ausgelagert