Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ef90159c

Von Sven Schöling vor fast 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
    }

Auch abrufbar als: Unified diff