Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e46a3e27

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID e46a3e2747cf08aa2e4d76af6b38267060015fa7
  • Vorgänger c1524c56
  • Nachfolger a3a6d136

ActionBar: Setup in is.pl in eigene Funktion ausgelagert

Unterschiede anzeigen:

bin/mozilla/is.pl
252 252
  $main::lxdebug->leave_sub();
253 253
}
254 254

  
255
sub setup_is_action_bar {
256
  my $form                    = $::form;
257
  my $change_never            = $::instance_conf->get_is_changeable == 0;
258
  my $change_on_same_day_only = $::instance_conf->get_is_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
259
  my @req_trans_desc          = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
260

  
261
  for my $bar ($::request->layout->get('actionbar')) {
262
    $bar->add_actions([ t8('Update'),
263
      submit    => [ '#form', { action_update => 1 } ],
264
      disabled  => $form->{locked} ? t8('The billing period has already been locked.') : undef,
265
      id        => 'update_button',
266
      accesskey => 'enter',
267
    ]);
268

  
269
    $bar->add_actions("combobox");
270
    $bar->actions->[-1]->add_actions([ t8('Post'),
271
      submit   => [ '#form', { action_post => 1 } ],
272
      checks   => [ @req_trans_desc ],
273
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
274
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
275
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
276
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
277
                :                                             undef,
278
    ]);
279
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
280
      submit   => [ '#form', { action_post_payment => 1 } ],
281
      checks   => [ @req_trans_desc ],
282
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
283
    ]);
284
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
285
      submit   => [ '#form', { action_mark_as_paid => 1 } ],
286
      confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
287
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
288
    ]) if $::instance_conf->get_is_show_mark_as_paid;
289

  
290

  
291
    $bar->add_actions("combobox");
292
    $bar->actions->[-1]->add_actions([ t8('Storno'),
293
      submit   => [ '#form', { action_storno => 1 } ],
294
      confirm  => t8('Do you really want to cancel this invoice?'),
295
      checks   => [ @req_trans_desc ],
296
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
297
    ]);
298
    $bar->actions->[-1]->add_actions([ t8('Delete'),
299
      submit   => [ '#form', { action_delete => 1 } ],
300
      confirm  => t8('Do you really want to delete this object?'),
301
      checks   => [ @req_trans_desc ],
302
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
303
                : $form->{locked}          ? t8('The billing period has already been locked.')
304
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
305
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
306
                :                            undef,
307
    ]);
308

  
309
    $bar->add_actions('separator');
310

  
311
    $bar->add_actions('combobox');
312
    $bar->actions->[-1]->add_actions([ t8('Workflow'),
313
      disabled => 1,
314
    ]);
315
    $bar->actions->[-1]->add_actions([ t8('Use As New'),
316
      submit   => [ '#form', { action_use_as_new    => 1 } ],
317
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
318
    ]);
319
    $bar->actions->[-1]->add_actions([ t8('Credit Note'),
320
      submit   => [ '#form', { action_credit_note    => 1 } ],
321
      checks   => [ @req_trans_desc ],
322
      disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
323
                : !$form->{id}                   ? t8('This invoice has not been posted yet.')
324
                :                                  undef,
325
    ]);
326
    $bar->actions->[-1]->add_actions([ t8('Sales Order'),
327
      submit   => [ '#form', { action_sales_order   => 1 } ],
328
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
329
    ]);
330

  
331
    $bar->add_actions('combobox');
332
    $bar->actions->[-1]->add_actions([ t8('Export'),
333
      disabled => 1,
334
    ]);
335
    $bar->actions->[-1]->add_actions([ ($form->{id} ? t8('Print') : t8('Preview')),
336
      submit   => [ '#form', { action_print => 1 } ],
337
      checks   => [ @req_trans_desc ],
338
      disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
339
    ]);
340
    $bar->actions->[-1]->add_actions([ t8('E Mail'),
341
      submit   => [ '#form', { action_print => 1 } ],
342
      checks   => [ @req_trans_desc ],
343
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
344
    ]);
345
    $bar->add_actions('combobox');
346
    $bar->actions->[-1]->add_actions([ t8('more'),
347
      disabled => 1,
348
    ]);
349
    $bar->actions->[-1]->add_actions([ t8('History'),
350
      call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
351
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
352
    ]);
353
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
354
      call     => [ 'follow_up_window' ],
355
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
356
    ]);
357
    $bar->actions->[-1]->add_actions([ t8('Drafts'),
358
      call     => [ 'kivi.Draft.popup', 'is', 'invoice', $form->{draft_id}, $form->{draft_description} ],
359
      disabled => $form->{id}     ? t8('This invoice has already been posted.')
360
                : $form->{locked} ? t8('The billing period has already been locked.')
361
                :                   undef,
362
    ]);
363
  }
364
}
365

  
255 366
sub form_header {
256 367
  $main::lxdebug->enter_sub();
257 368

  
......
359 470
  $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice();
360 471
  $form->{duedate}             = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR{payment_terms_obj};
361 472

  
362
  my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
363

  
364
  my $change_never            = $::instance_conf->get_is_changeable == 0;
365
  my $change_on_same_day_only = $::instance_conf->get_is_changeable == 2 && ($form->current_date(\%myconfig) ne $form->{gldate});
366

  
367
  for my $bar ($::request->layout->get('actionbar')) {
368
    $bar->add_actions([ t8('Update'),
369
      submit => [ '#form', { action_update         => 1 } ],
370
      disabled => $form->{locked} ? t8('The billing period has already been locked.') : undef,
371
      id => 'update_button',
372
      accesskey => '13',
373
    ]);
374
    $bar->add_actions("combobox");
375
    $bar->actions->[-1]->add_actions([ t8('Post'),
376
      submit => [ '#form', { action_post           => 1 } ],
377
      checks => [ @req_trans_desc ],
378
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
379
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
380
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
381
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
382
                :                                             undef,
383
    ]);
384
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
385
      submit => [ '#form', { action_post_payment    => 1 } ],
386
      checks => [ @req_trans_desc ],
387
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
388
    ]);
389
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
390
      submit => [ '#form', { action_mark_as_paid    => 1 } ],
391
      confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
392
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
393
    ]) if $::instance_conf->get_is_show_mark_as_paid;
394

  
395
    $bar->add_actions("combobox");
396
    $bar->actions->[-1]->add_actions([ t8('Storno'),
397
      submit => [ '#form', { action_storno         => 1 } ],
398
      confirm => t8('Do you really want to cancel this invoice?'),
399
      checks => [ @req_trans_desc ],
400
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
401
    ]);
402
    $bar->actions->[-1]->add_actions([ t8('Delete'),
403
      submit => [ '#form', { action_delete         => 1 } ],
404
      confirm => t8('Do you really want to delete this object?'),
405
      checks => [ @req_trans_desc ],
406
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
407
                : $form->{locked}          ? t8('The billing period has already been locked.')
408
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
409
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
410
                :                            undef,
411
    ]);
412
    $bar->add_actions('separator');
413

  
414
    $bar->add_actions('combobox');
415
    $bar->actions->[-1]->add_actions([ t8('Workflow'),
416
      disabled => 1,
417
    ]);
418
    $bar->actions->[-1]->add_actions([ t8('Use As New'),
419
      submit => [ '#form', { action_use_as_new    => 1 } ],
420
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
421
    ]);
422
    $bar->actions->[-1]->add_actions([ t8('Credit Note'),
423
      submit => [ '#form', { action_credit_note    => 1 } ],
424
      checks => [ @req_trans_desc ],
425
      disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
426
                : !$form->{id}                   ? t8('This invoice has not been posted yet.')
427
                :                                  undef,
428
    ]);
429
    $bar->actions->[-1]->add_actions([ t8('Sales Order'),
430
      submit => [ '#form', { action_sales_order   => 1 } ],
431
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
432
    ]);
433

  
434
    $bar->add_actions('combobox');
435
    $bar->actions->[-1]->add_actions([ t8('Export'),
436
      disabled => 1,
437
    ]);
438
    $bar->actions->[-1]->add_actions([ ($form->{id} ? t8('Print') : t8('Preview')),
439
      submit => [ '#form', { action_print          => 1 } ],
440
      checks => [ @req_trans_desc ],
441
      disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
442
    ]);
443
    $bar->actions->[-1]->add_actions([ t8('E Mail'),
444
      submit => [ '#form', { action_print          => 1 } ],
445
      checks => [ @req_trans_desc ],
446
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
447
    ]);
448
    $bar->add_actions('combobox');
449
    $bar->actions->[-1]->add_actions([ t8('more'),
450
      disabled => 1,
451
    ]);
452
    $bar->actions->[-1]->add_actions([ t8('History'),
453
      call     => [ 'set_history_window', $form->{id} * 1, 'id' ],
454
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
455
    ]);
456
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
457
      call     => [ 'follow_up_window' ],
458
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
459
    ]);
460
    $bar->actions->[-1]->add_actions([ t8('Drafts'),
461
      call     => [ 'kivi.Draft.popup', 'is', 'invoice', $form->{draft_id}, $form->{draft_description} ],
462
      disabled => $form->{id}     ? t8('This invoice has already been posted.')
463
                : $form->{locked} ? t8('The billing period has already been locked.')
464
                :                   undef,
465
    ]);
466

  
467
  }
473
  setup_is_action_bar();
468 474

  
469 475
  $form->header();
470 476

  

Auch abrufbar als: Unified diff