Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1dbba310

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID 1dbba310dfffc4caa2a786893134fb3dbebd3e28
  • Vorgänger da413cb1
  • Nachfolger 9e02b1f2

Einkaufsrechnungen: Lieferantenwahl über Picker und nicht Multibox

Unterschiede anzeigen:

bin/mozilla/ir.pl
38 38
use SL::DB::Default;
39 39
use SL::DB::Department;
40 40
use SL::DB::PurchaseInvoice;
41
use SL::DB::Vendor;
41 42
use List::Util qw(max sum);
42 43
use List::UtilsBy qw(sort_by);
43 44

  
......
110 111
  # create links
111 112
  $form->create_links("AP", \%myconfig, "vendor");
112 113

  
113
  #quote all_vendor Bug 133
114
  foreach my $ref (@{ $form->{all_vendor} }) {
115
    $ref->{name} = $form->quote($ref->{name});
116
  }
117

  
118
  if ($form->{all_vendor}) {
119
    unless ($form->{vendor_id}) {
120
      $form->{vendor_id} = $form->{all_vendor}->[0]->{id};
121
    }
122
  }
123

  
124 114
  $form->backup_vars(qw(payment_id language_id taxzone_id
125 115
                        currency delivery_term_id intnotes cp_id));
126 116

  
......
133 123
  my @curr = $form->get_all_currencies();
134 124
  map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
135 125

  
136
  $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
137

  
138
  # build vendor/customer drop down comatibility... don't ask
139
  if (@{ $form->{"all_vendor"} || [] }) {
140
    $form->{"selectvendor"} = 1;
141
    $form->{vendor}         = qq|$form->{vendor}--$form->{vendor_id}|;
142
  }
143

  
144 126
  # forex
145 127
  $form->{forex} = $form->{exchangerate};
146 128
  my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
......
248 230
  my %TMPL_VAR = ();
249 231
  my @custom_hiddens;
250 232

  
251
  $TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->new(id => $form->{id})->load if $form->{id};
233
  $TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->load_cached($form->{id}) if $form->{id};
234
  $TMPL_VAR{vendor_obj}  = SL::DB::Vendor->load_cached($form->{vendor_id})   if $form->{vendor_id};
252 235
  $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
253 236
  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
254 237

  
......
259 242

  
260 243
  $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
261 244
                   "currencies"    => "ALL_CURRENCIES",
262
                   "vendors"       => "ALL_VENDORS",
263 245
                   "price_factors" => "ALL_PRICE_FACTORS");
264 246

  
265 247
  $TMPL_VAR{ALL_DEPARTMENTS}       = SL::DB::Manager::Department->get_all_sorted;
......
274 256
    ]
275 257
  ]);
276 258

  
277
  # customer
278
  $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
279
  $TMPL_VAR{vclimit} = $myconfig{vclimit};
280
  $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('vendor', '', 1, 0)";
281
  push @custom_hiddens, "vendor_id";
282
  push @custom_hiddens, "oldvendor";
283
  push @custom_hiddens, "selectvendor";
284

  
285 259
  # currencies and exchangerate
286 260
  my @values = map { $_       } @{ $form->{ALL_CURRENCIES} };
287 261
  my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
......
298 272
  $TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
299 273
  $TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
300 274

  
301
  my $follow_up_vc         =  $form->{vendor};
302
  $follow_up_vc            =~ s/--\d*\s*$//;
303
  $TMPL_VAR{vendor_name} = $follow_up_vc;
304

  
305 275
# set option selected
306 276
  foreach my $item (qw(AP)) {
307 277
    $form->{"select$item"} =~ s/ selected//;
......
473 443

  
474 444
  $main::auth->assert('vendor_invoice_edit');
475 445

  
476
  &check_name('vendor');
446
  if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
447
    IR->get_vendor(\%myconfig, $form);
448
  }
477 449

  
478 450
  if (!$form->{forex}) {        # read exchangerate from input field (not hidden)
479 451
    $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
......
735 707
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
736 708

  
737 709
  $form->isblank("invdate",   $locale->text('Invoice Date missing!'));
738
  $form->isblank("vendor",    $locale->text('Vendor missing!'));
710
  $form->isblank("vendor_id", $locale->text('Vendor missing!'));
739 711
  $form->isblank("invnumber", $locale->text('Invnumber missing!'));
740 712

  
741 713
  $form->{invnumber} =~ s/^\s*//g;
742 714
  $form->{invnumber} =~ s/\s*$//g;
743 715

  
744 716
  # if the vendor changed get new values
745
  if (&check_name('vendor')) {
717
  if (($form->{previous_vendor_id} || $form->{vendor_id}) != $form->{vendor_id}) {
746 718
    &update;
747 719
    $::dispatcher->end_request;
748 720
  }
templates/webpages/ir/form_header.html
4 4
[%- USE L %][%- USE P -%]
5 5
<h1>[% title %]</h1>
6 6

  
7
[%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_name _ ')' %]
7
[%- SET follow_up_trans_info = invnumber _ ' (' _ vendor_obj.name _ ')' %]
8 8
<script type="text/javascript" src="js/common.js"></script>
9
<script type="text/javascript" src="js/vendor_selection.js"></script>
10 9
<script type="text/javascript" src="js/calculate_qty.js"></script>
11 10
<script type="text/javascript" src="js/follow_up.js"></script>
12
<script type="text/javascript" src="js/customer_or_vendor_selection.js"></script>
13 11

  
14 12
<form method="post" name="invoice" action="[% script %]">
15 13

  
......
49 47
        <tr>
50 48
          <th align="right">[% 'Vendor' | $T8 %]</th>
51 49
          <td>
52
            [%- INCLUDE 'generic/multibox.html'
53
                 id            = 'vendor',
54
                 name          = 'vendor',
55
                 style         = 'width: 250px',
56
                 class         = 'initial_focus',
57
                 DATA          = ALL_VENDORS,
58
                 id_sub        = 'vc_keys',
59
                 label_key     = 'name',
60
                 select        = vc_select,
61
                 limit         = vclimit,
62
                 allow_textbox = 1,
63
                 onChange      = "document.getElementById('update_button').click();" -%]
64
            <input type="button" value="[% 'Details (one letter abbreviation)' | $T8 %]" onclick="show_vc_details('[% vc | html %]')">
50
           [% P.customer_vendor_picker("vendor_id", vendor_id, type="vendor", style="width: 250px", class="initial_focus") %]
51
           [% P.button_tag("show_vc_details('vendor')", LxERP.t8('Details (one letter abbreviation)')) %]
52
           [% P.hidden_tag("previous_vendor_id", vendor_id) %]
65 53
          </td>
66
          <input type="hidden" name="vendor_id" value="[% HTML.escape(vendor_id) %]">
67
          <input type="hidden" name="oldvendor" value="[% HTML.escape(oldvendor) %]">
68
          <input type="hidden" name="selectvendor" value="[% HTML.escape(selectvendor) %]">
69 54
        </tr>
70 55
[%- IF ALL_CONTACTS.size %]
71 56
        <tr>

Auch abrufbar als: Unified diff