Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a3a6d136

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID a3a6d136cbd97bd18b5943937b80b1b1b504ef3b
  • Vorgänger e46a3e27
  • Nachfolger 3ff7346d

ActionBar: Setup in ir.pl in eigene Funktion ausgelagert

Unterschiede anzeigen:

bin/mozilla/ir.pl
216 216
  $main::lxdebug->leave_sub();
217 217
}
218 218

  
219
sub setup_ir_action_bar {
220
  my $form                    = $::form;
221
  my $change_never            = $::instance_conf->get_ir_changeable == 0;
222
  my $change_on_same_day_only = $::instance_conf->get_ir_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
223

  
224
  for my $bar ($::request->layout->get('actionbar')) {
225
    $bar->add_actions([ t8('Update'),
226
      submit    => [ '#form', { action_update => 1 } ],
227
      id        => 'update_button',
228
      accesskey => 'enter',
229
    ]);
230

  
231
    $bar->add_actions("combobox");
232
    $bar->actions->[-1]->add_actions([ t8('Post'),
233
      submit   => [ '#form', { action_post => 1 } ],
234
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
235
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
236
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
237
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
238
                :                                             undef,
239
    ]);
240
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
241
      submit   => [ '#form', { action_post_payment => 1 } ],
242
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
243
    ]);
244
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
245
      submit   => [ '#form', { action_mark_as_paid => 1 } ],
246
      confirm  => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
247
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
248
    ]) if $::instance_conf->get_ir_show_mark_as_paid;
249

  
250

  
251
    $bar->add_actions("combobox");
252
    $bar->actions->[-1]->add_actions([ t8('Storno'),
253
      submit   => [ '#form', { action_storno => 1 } ],
254
      confirm  => t8('Do you really want to cancel this invoice?'),
255
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
256
    ]);
257
    $bar->actions->[-1]->add_actions([ t8('Delete'),
258
      submit   => [ '#form', { action_delete => 1 } ],
259
      confirm  => t8('Do you really want to delete this object?'),
260
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
261
                : $form->{locked}          ? t8('The billing period has already been locked.')
262
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
263
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
264
                :                            undef,
265
    ]);
266

  
267
    $bar->add_actions('separator');
268

  
269
    $bar->add_actions('combobox');
270
    $bar->actions->[-1]->add_actions([ t8('more'),
271
      disabled => 1,
272
    ]);
273
    $bar->actions->[-1]->add_actions([ t8('History'),
274
      call     => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ],
275
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
276
    ]);
277
    $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
278
      call     => [ 'follow_up_window' ],
279
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
280
    ]);
281
    $bar->actions->[-1]->add_actions([ t8('Drafts'),
282
      call     => [ 'kivi.Draft.popup', 'ir', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
283
      disabled => $form->{id}     ? t8('This invoice has already been posted.')
284
                : $form->{locked} ? t8('The billing period has already been locked.')
285
                :                   undef,
286
    ]);
287
  }
288
}
289

  
219 290
sub form_header {
220 291
  $main::lxdebug->enter_sub();
221 292

  
......
298 369

  
299 370
  $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File  kivi.SalesPurchase kivi.Part ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_project client_js));
300 371

  
301
  my $change_never            = $::instance_conf->get_ir_changeable == 0;
302
  my $change_on_same_day_only = $::instance_conf->get_ir_changeable == 2 && ($form->current_date(\%myconfig) ne $form->{gldate});
303

  
304
  for my $bar ($::request->layout->get('actionbar')) {
305
    $bar->add_actions([ t8('Update'),
306
      submit => [ '#form', { action_update         => 1 } ],
307
      id => 'update_button',
308
      accesskey => '13',
309
    ]);
310
    $bar->add_actions("combobox");
311
    $bar->actions->[-1]->add_actions([ t8('Post'),
312
      submit => [ '#form', { action_post           => 1 } ],
313
      disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
314
                : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
315
                : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
316
                : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
317
                :                                             undef,
318
    ]);
319
    $bar->actions->[-1]->add_actions([ t8('Post Payment'),
320
      submit => [ '#form', { action_post_payment    => 1 } ],
321
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
322
    ]);
323
    $bar->actions->[-1]->add_actions([ t8('mark as paid'),
324
      submit => [ '#form', { action_mark_as_paid    => 1 } ],
325
      confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
326
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
327
    ]) if $::instance_conf->get_ir_show_mark_as_paid;
328

  
329
    $bar->add_actions("combobox");
330
    $bar->actions->[-1]->add_actions([ t8('Storno'),
331
      submit => [ '#form', { action_storno         => 1 } ],
332
      confirm => t8('Do you really want to cancel this invoice?'),
333
      disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
334
    ]);
335
    $bar->actions->[-1]->add_actions([ t8('Delete'),
336
      submit => [ '#form', { action_delete         => 1 } ],
337
      confirm => t8('Do you really want to delete this object?'),
338
      disabled => !$form->{id}             ? t8('This invoice has not been posted yet.')
339
                : $form->{locked}          ? t8('The billing period has already been locked.')
340
                : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
341
                : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
342
                :                            undef,
343
    ]);
344
    $bar->add_actions('separator');
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', 'glid' ],
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', 'ir', '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
  }
372
  setup_ir_action_bar();
364 373

  
365 374
  $form->header();
366 375

  

Auch abrufbar als: Unified diff