Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ef90159c

Von Sven Schöling vor etwa 13 Jahren hinzugefügt

  • ID ef90159c18e52835e03b1775a23c64fbb91436de
  • Vorgänger cb3a2467
  • Nachfolger 26ab499f

CVars für Kunden

Experimentelles Feature!

Das gleiche kann später für vendors auch analog gemacht werden, beides
gleichzeitig (also eine kompinierte vc box) ist im moment nicht vorgesehen.

Bugs:
- Erneuern sowohl in überlagerten Belegen als auch in den Waren funktioniert noch nicht richtig
- Drucken ist ungetestet
- invalid + überlagern funktioniert noch nicht.

Unterschiede anzeigen:

SL/CVar.pm
240 240
      $cvar->{value} = $cvar->{type} eq 'date'      ? $act_var->{date_value}
241 241
                     : $cvar->{type} eq 'timestamp' ? $act_var->{timestamp_value}
242 242
                     : $cvar->{type} eq 'number'    ? $act_var->{number_value}
243
                     : $cvar->{type} eq 'customer'  ? $act_var->{number_value}
243 244
                     : $cvar->{type} eq 'bool'      ? $act_var->{bool_value}
244 245
                     :                                $act_var->{text_value};
245 246
      $cvar->{valid} = $valid;
......
273 274

  
274 275
    if ($cvar->{type} eq 'number') {
275 276
      $cvar->{value} = $form->format_amount($myconfig, $cvar->{value} * 1, $cvar->{precision});
277
    } elsif ($cvar->{type} eq 'customer') {
278
      require SL::DB::Customer;
279
      $cvar->{value} = SL::DB::Manager::Customer->find_by(id => $cvar->{value} * 1);
276 280
    }
277 281
  }
278 282

  
......
334 338

  
335 339
    } elsif ($config->{type} eq 'bool') {
336 340
      push @values, $value ? 't' : 'f', undef, undef, undef;
341
    } elsif ($config->{type} eq 'customer') {
342
      push @values, undef, undef, undef, $value * 1;
337 343
    }
338 344

  
339 345
    do_statement($form, $sth, $query, @values);
......
489 495

  
490 496
      $not = 'NOT' if ($params{filter}->{$name} eq 'no');
491 497
      push @sub_where,  qq|COALESCE(cvar.bool_value, false) = TRUE|;
498
    } elsif ($config->{type} eq 'customer') {
499
      next unless $params{filter}->{$name};
500

  
501
      push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM customer WHERE name ILIKE ?)|;
502
      push @sub_values, "%$params{filter}->{$name}%";
492 503
    }
493 504

  
494 505
    if (@sub_where) {
......
562 573
          $cfg->{type} eq 'date'      ? $ref->{date_value}
563 574
        : $cfg->{type} eq 'timestamp' ? $ref->{timestamp_value}
564 575
        : $cfg->{type} eq 'number'    ? $form->format_amount($myconfig, $ref->{number_value} * 1, $cfg->{precision})
576
        : $cfg->{type} eq 'customer'  ? SL::DB::Manager::Customer->find_by(id => 1* $ref->{number_value})->name
565 577
        : $cfg->{type} eq 'bool'      ? ($ref->{bool_value} ? $locale->text('Yes') : $locale->text('No'))
566 578
        :                               $ref->{text_value};
567 579
    }
bin/mozilla/amcvar.pl
54 54
                     'timestamp' => $locale->text('Timestamp'),
55 55
                     'bool'      => $locale->text('Yes/No (Checkbox)'),
56 56
                     'select'    => $locale->text('Selection'),
57
                     'customer'  => $locale->text('Customer'),
57 58
                     );
58 59

  
59
our @types = qw(text textfield number date bool select); # timestamp
60
our @types = qw(text textfield number date bool select customer); # timestamp
60 61

  
61 62
our @modules = ({ module => 'CT',       description => $locale->text('Customers and vendors')          },
62 63
                { module => 'IC',       description => $locale->text('Parts, services and assemblies') },
templates/webpages/amcvar/render_inputs.html
1 1
[%- USE T8 %]
2
[% USE HTML %]
2
[%- USE HTML %]
3
[%- USE L %]
3 4

  
4 5
[%- SET var_name = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%]
5 6

  
......
33 34
[%- ELSIF var.type == 'timestamp' %]
34 35
<input name="[% var_name %]" value="[% HTML.escape(var.value) %]">
35 36

  
37
[%- ELSIF var.type == 'customer' %]
38
[% L.customer_picker(var_name, var.value) %]
39

  
36 40
[%- ELSIF var.type == 'select' %]
37 41

  
38 42
<select name="[% var_name %]">
templates/webpages/amcvar/render_inputs_block.html
1 1
[%- USE T8 %]
2 2
[%- USE HTML %]
3
[%- USE L %]
3 4
[%- BLOCK cvar_name %][% HTML.escape(cvar.name_prefix) _ "cvar_" _ HTML.escape(cvar.var.name) _ HTML.escape(cvar.name_postfix) -%][% END %]
4 5
[%- BLOCK cvar_inputs %]
5 6
[%- %]
......
32 33
 <option[% IF option.value == cvar.value %] selected[% END %]>[% HTML.escape(option.value) %]</option>
33 34
 [%- END %]
34 35
</select>
36
[%- ELSIF cvar.var.type == 'customer' %]
37
[% render_input_blocks__cvar_name = PROCESS cvar_name %][% L.customer_picker(render_input_blocks__cvar_name, cvar.value) %]
35 38
[%- ELSE %]
36 39
<input name="[% PROCESS cvar_name %]" value="[% HTML.escape(cvar.value) %]" [%- IF cvar.var.maxlength %] maxlength="[% HTML.escape(cvar.var.maxlength) %]"[% END -%]>
37 40
[%- END %]
templates/webpages/amcvar/search_filter.html
46 46
     </select>
47 47
     <input name="cvar_[% HTML.escape(var.name) %]"[% IF var.maxlength %]maxlength="[% HTML.escape(var.maxlength) %]"[% END %]>
48 48

  
49
     [%- ELSIF var.type == 'customer' %]
50
     <input name="cvar_[% var.name | html %]">
51

  
49 52
     [% ELSIF var.type == 'select' %]
50 53
     <select name="cvar_[% HTML.escape(var.name) %]">
51 54
      <option value="" selected>---</option>

Auch abrufbar als: Unified diff