Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision db7d17f2

Von Tamino Steinert vor 1 Tag hinzugefügt

  • ID db7d17f2e3cceb19e83502a46b7336f69a1c7b2f
  • Vorgänger eaf77a00
  • Nachfolger 15a630c6

POS: Neukunden anlegen

Unterschiede anzeigen:

SL/Controller/POS.pm
9 9
use SL::DB::ValidityToken;
10 10
use SL::DB::Order::TypeData qw(:types);
11 11
use SL::DB::DeliveryOrder::TypeData qw(:types);
12
use SL::DB::TaxZone;
13
use SL::DB::Currency;
12 14

  
13 15
use SL::Locale::String qw(t8);
14 16

  
......
68 70
  my ($self) = @_;
69 71

  
70 72
  my $cash_customer_id = $::instance_conf->get_pos_cash_customer_id or
71
    die "No cash customer set in client config\n";
73
    die "No cash customer set in client config.";
72 74
  my $cash_customer = SL::DB::Manager::Customer->find_by( id => $cash_customer_id );
73 75

  
76
  $self->change_customer($cash_customer);
77
}
78

  
79
sub action_create_new_customer {
80
  my ($self) = @_;
81
  die "id can't be given" if defined $::form->{new_customer}->{id};
82
  my $name = delete $::form->{new_customer}->{name}
83
    or die "name is needed.";
84

  
85
  my $taxzone_id = SL::DB::Manager::TaxZone->get_all_sorted(
86
    query => [ obsolete => 0 ]
87
  )->[0]->id;
88
  my $currency_id = SL::DB::Default->get->currency_id;
89

  
90
  my $new_customer = SL::DB::Customer->new(
91
    name => $name,
92
    taxzone_id  => $taxzone_id,
93
    currency_id => $currency_id,
94
    %{$::form->{new_customer}}
95
  );
96
  $new_customer->save();
97

  
98
  $self->change_customer($new_customer);
99
}
100

  
101
sub change_customer {
102
  my ($self, $customer) = @_;
103

  
104
  die "Need customer object." unless ref $customer eq 'SL::DB::Customer';
105

  
74 106
  return $self->js
75
    ->val('#order_customer_id', $cash_customer->id)
76
    ->val(        '#order_customer_id_name', $cash_customer->displayable_name)
107
    ->val(        '#order_customer_id',      $customer->id)
108
    ->val(        '#order_customer_id_name', $customer->displayable_name)
77 109
    ->removeClass('#order_customer_id_name', 'customer-vendor-picker-undefined')
78 110
    ->addClass(   '#order_customer_id_name', 'customer-vendor-picker-picked')
79 111
    ->run('kivi.Order.reload_cv_dependent_selections')
80 112
    ->render();
81 113
}
82 114

  
115
sub action_open_new_customer_dialog {
116
  my ($self) = @_;
117

  
118
  $self->render(
119
    'pos/_new_customer_dialog', { layout => 0 },
120
    popup_dialog            => 1,
121
    popup_js_close_function => '$("#new_customer_dialog").dialog("close")',
122
  );
123
}
124

  
83 125
sub action_add_discount_item_dialog {
84 126
  my ($self) = @_;
85 127

  
......
98 140
    popup_dialog            => 1,
99 141
    popup_js_close_function => '$("#add_discount_item_dialog").dialog("close")',
100 142
    TYPE_NAME               => $type_name,
101

  
102 143
  );
103 144
}
104 145

  
js/kivi.POS.js
95 95
    $.post("controller.pl", data, kivi.eval_json_result);
96 96
  }
97 97

  
98
  ns.set_cash_customer = function() {
99
    var data = $('#order_form').serializeArray();
100
    data.push({ name: 'action', value: 'POS/set_cash_customer' });
101

  
102
    $.post("controller.pl", data, kivi.eval_json_result);
103
  }
104

  
105
  ns.open_new_customer_dialog = function() {
106
    kivi.popup_dialog({
107
      url:    'controller.pl?action=POS/open_new_customer_dialog',
108
      id:     'new_customer_dialog',
109
      load:   function() {
110
        kivi.reinit_widgets();
111
        document.getElementById("new_customer_name").focus();
112
      },
113
      dialog: {
114
        title:  kivi.t8('New Customer'),
115
        width:  400,
116
        height: 300
117
      }
118
    });
119
  }
120

  
121
  ns.create_new_customer = function() {
122
    if (!kivi.Validator.validate_all('#new_customer_form')) return;
123

  
124
    var order_data = $('#order_form').serializeArray();
125
    var new_customer_data = $('#new_customer_form').serializeArray();
126
    var data = order_data.concat(new_customer_data);
127
    data.push({ name: 'action', value: 'POS/create_new_customer' });
128

  
129
    $.post("controller.pl", data, kivi.eval_json_result);
130
    $("#new_customer_dialog").dialog("close")
131
  }
132

  
98 133
  ns.submit = function(params) {
99 134
    if (!kivi.Order.check_cv()) return;
100 135
    if (!ns.check_items()) return;
templates/design40_webpages/pos/_add_discount_item_dialog.html
3 3
[% USE LxERP %]
4 4
[% USE HTML %]
5 5

  
6
<form method="post" id="item_row_pos_form" onsubmit="kivi.POS.apply_dicount_item_value()">
6
<form method="post" id="discount_item_form" onsubmit="kivi.POS.apply_dicount_item_value(); return false">
7 7
  <table class="tbl-horizontal">
8 8
    <caption>
9 9
      [% TYPE_NAME | html %]
......
28 28
  </table>
29 29

  
30 30
 <p>
31
  [% L.button_tag(popup_js_close_function, LxERP.t8('Cancel')) %]
31
  [% L.button_tag(popup_js_close_function, LxERP.t8('Cancel'), class="neutral") %]
32 32
 </p>
33 33
</form>
templates/design40_webpages/pos/_new_customer_dialog.html
1
[% USE T8 %]
2
[% USE L %]
3
[% USE P %]
4
[% USE LxERP %]
5
[% USE HTML %]
6

  
7
<form method="post" id="new_customer_form" onsubmit="kivi.POS.create_new_customer(); return false;">
8
  <table class="tbl-horizontal">
9
    <caption>
10
      [% 'Customer' | $T8 %]
11
    </caption>
12
    <tbody>
13
      <tr>
14
        <th>[% 'Customer Name' | $T8 %]</th>
15
        <td>
16
          [% L.input_tag_trim(
17
            'new_customer.name',
18
            '',
19
            class='wi-lightwide',
20
            'data-validate'='required',
21
            ) %]
22
        </td>
23
      </tr>
24
      <tr>
25
        <th>[% 'Street' | $T8 %]</th>
26
        <td>
27
          [% L.input_tag_trim(
28
            'new_customer.street',
29
            '',
30
            class='wi-lightwide',
31
            ) %]
32
        </td>
33
      </tr>
34
      <tr>
35
        <th>[% 'Zipcode' | $T8 %]/[% 'City' | $T8 %]</th>
36
        <td>
37
          [%
38
            L.input_tag_trim('new_customer.zipcode',
39
              '',
40
              class='wi-verysmall',
41
              )
42
          %][%
43
            L.input_tag_trim('new_customer.city',
44
              '',
45
              class='wi-lightwide--verysmall',
46
              )
47
          %]
48
        </td>
49
      </tr>
50
      <tr>
51
        <th>[% 'Country' | $T8 %]</th>
52
        <td>
53
          [% L.input_tag_trim('new_customer.country',
54
            '',
55
            class='wi-lightwide'
56
            ) %]
57
        </td>
58
      </tr>
59
      <tr>
60
        <th>[% 'E-mail' | $T8 %]</th>
61
        <td>[%
62
          P.input_tag_trim('new_customer.email',
63
          '',
64
          class='wi-lightwide'
65
          ) %]
66
        </td>
67
      </tr>
68
      <tr>
69
        <td>
70
          [% L.submit_tag('create_new_customer', LxERP.t8('Apply')) %]
71
        </td>
72
      </tr>
73
    </tbody>
74
  </table>
75

  
76
 <p>
77
  [% L.button_tag(popup_js_close_function, LxERP.t8('Cancel'), class="neutral") %]
78
 </p>
79
</form>
templates/design40_webpages/pos/form.html
39 39
                    LxERP.t8('Cash customer')
40 40
                    ) %]</td>
41 41
                [% END %]
42
                <td>[% L.button_tag("cash_customer", LxERP.t8('Create new customer'), class="neutral" ) %]</td>
42
                <td>[% L.button_tag(
43
                    "kivi.POS.open_new_customer_dialog()",
44
                    LxERP.t8('Create new customer'),
45
                    class="neutral"
46
                    ) %]</td>
43 47
              </tr>
44 48
            </table>
45 49
          </div>

Auch abrufbar als: Unified diff