Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dbbf8923

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID dbbf892309056494e9243df8b7599096ef9e42c5
  • Vorgänger 3fdb26b1
  • Nachfolger 5fd2cf41

Verwaltung von Zahlungsbedingungen auf Controller/Model umgestellt

Conflicts:

locale/de/all

Unterschiede anzeigen:

bin/mozilla/am.pl
2018 2018
  $main::lxdebug->leave_sub();
2019 2019
}
2020 2020

  
2021
sub add_payment {
2022
  $main::lxdebug->enter_sub();
2023

  
2024
  my $form     = $main::form;
2025
  my %myconfig = %main::myconfig;
2026

  
2027
  $main::auth->assert('config');
2028

  
2029
  $form->{title} = "Add";
2030

  
2031
  $form->{callback} = "am.pl?action=add_payment" unless $form->{callback};
2032

  
2033
  $form->{terms_netto} = 0;
2034
  $form->{terms_skonto} = 0;
2035
  $form->{percent_skonto} = 0;
2036
  my @languages = AM->language(\%myconfig, $form, 1);
2037
  map({ $_->{"language"} = $_->{"description"};
2038
        $_->{"language_id"} = $_->{"id"}; } @languages);
2039
  $form->{"TRANSLATION"} = \@languages;
2040
  &payment_header;
2041
  &form_footer;
2042

  
2043
  $main::lxdebug->leave_sub();
2044
}
2045

  
2046
sub edit_payment {
2047
  $main::lxdebug->enter_sub();
2048

  
2049
  my $form     = $main::form;
2050
  my %myconfig = %main::myconfig;
2051

  
2052
  $main::auth->assert('config');
2053

  
2054
  $form->{title} = "Edit";
2055

  
2056
  AM->get_payment(\%myconfig, $form);
2057
  $form->{percent_skonto} =
2058
    $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2059

  
2060
  &payment_header;
2061

  
2062
  $form->{orphaned} = 1;
2063
  &form_footer;
2064

  
2065
  $main::lxdebug->leave_sub();
2066
}
2067

  
2068
sub list_payment {
2069
  $main::lxdebug->enter_sub();
2070

  
2071
  my $form     = $main::form;
2072
  my %myconfig = %main::myconfig;
2073
  my $locale   = $main::locale;
2074

  
2075
  $main::auth->assert('config');
2076

  
2077
  AM->payment(\%myconfig, \%$form);
2078

  
2079
  $form->{callback} = build_std_url("action=list_payment");
2080

  
2081
  my $callback = $form->escape($form->{callback});
2082

  
2083
  $form->{title} = $locale->text('Payment Terms');
2084

  
2085
  my @column_index = qw(up down description description_long terms_netto
2086
                     terms_skonto percent_skonto);
2087
  my %column_header;
2088
  $column_header{up} =
2089
      qq|<th class="listheading" align="center" valign="center" width="16">|
2090
    . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2091
    . qq|</th>|;
2092
  $column_header{down} =
2093
      qq|<th class="listheading" align="center" valign="center" width="16">|
2094
    . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2095
    . qq|</th>|;
2096
  $column_header{description} =
2097
      qq|<th class=listheading>|
2098
    . $locale->text('Description')
2099
    . qq|</th>|;
2100
  $column_header{description_long} =
2101
      qq|<th class=listheading>|
2102
    . $locale->text('Long Description')
2103
    . qq|</th>|;
2104
  $column_header{terms_netto} =
2105
      qq|<th class=listheading>|
2106
    . $locale->text('Netto Terms')
2107
    . qq|</th>|;
2108
  $column_header{terms_skonto} =
2109
      qq|<th class=listheading>|
2110
    . $locale->text('Skonto Terms')
2111
    . qq|</th>|;
2112
  $column_header{percent_skonto} =
2113
      qq|<th class=listheading>|
2114
    . $locale->text('Skonto')
2115
    . qq| %</th>|;
2116

  
2117
  $form->header;
2118

  
2119
  print qq|
2120
<body>
2121

  
2122
<table width=100%>
2123
  <tr>
2124
    <th class=listtop>$form->{title}</th>
2125
  </tr>
2126
  <tr height="5"></tr>
2127
  <tr>
2128
    <td>
2129
      <table width=100%>
2130
        <tr class=listheading>
2131
|;
2132

  
2133
  map { print "$column_header{$_}\n" } @column_index;
2134

  
2135
  print qq|
2136
        </tr>
2137
|;
2138

  
2139
  my $swap_link = build_std_url("action=swap_payment_terms");
2140

  
2141
  my $row = 0;
2142
  my ($i, %column_data);
2143
  foreach my $ref (@{ $form->{ALL} }) {
2144

  
2145
    $i++;
2146
    $i %= 2;
2147

  
2148
    print qq|
2149
        <tr valign=top class=listrow$i>
2150
|;
2151

  
2152
    if ($row) {
2153
      my $pref = $form->{ALL}->[$row - 1];
2154
      $column_data{up} =
2155
        qq|<td align="center" valign="center" width="16">| .
2156
        qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2157
        qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2158
        qq|</a></td>|;
2159
    } else {
2160
      $column_data{up} = qq|<td width="16">&nbsp;</td>|;
2161
    }
2162

  
2163
    if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2164
      $column_data{down} = qq|<td width="16">&nbsp;</td>|;
2165
    } else {
2166
      my $nref = $form->{ALL}->[$row + 1];
2167
      $column_data{down} =
2168
        qq|<td align="center" valign="center" width="16">| .
2169
        qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2170
        qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2171
        qq|</a></td>|;
2172
    }
2173

  
2174
    $column_data{description} =
2175
      qq|<td><a href="| .
2176
      build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2177
      qq|">| . H($ref->{description}) . qq|</a></td>|;
2178
    $column_data{description_long} =
2179
      qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2180
    $column_data{terms_netto} =
2181
      qq|<td align=right>$ref->{terms_netto}</td>|;
2182
    $column_data{terms_skonto} =
2183
      qq|<td align=right>$ref->{terms_skonto}</td>|;
2184
    $column_data{percent_skonto} =
2185
      qq|<td align=right>| .
2186
      $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2187
      qq|%</td>|;
2188
    map { print "$column_data{$_}\n" } @column_index;
2189

  
2190
    print qq|
2191
       </tr>
2192
|;
2193
    $row++;
2194
  }
2195

  
2196
  print qq|
2197
      </table>
2198
    </td>
2199
  </tr>
2200
  <tr>
2201
  <td><hr size=3 noshade></td>
2202
  </tr>
2203
</table>
2204

  
2205
<br>
2206
<form method=post action=am.pl>
2207

  
2208
<input name=callback type=hidden value="$form->{callback}">
2209

  
2210
<input type=hidden name=type value=payment>
2211

  
2212
<input class=submit type=submit name=action value="|
2213
    . $locale->text('Add') . qq|">
2214

  
2215
  </form>
2216

  
2217
  </body>
2218
  </html>
2219
|;
2220

  
2221
  $main::lxdebug->leave_sub();
2222
}
2223

  
2224
sub payment_header {
2225
  $main::lxdebug->enter_sub();
2226

  
2227
  my $form     = $main::form;
2228
  my $locale   = $main::locale;
2229

  
2230
  $main::auth->assert('config');
2231

  
2232
  $form->{title}    = $locale->text("$form->{title} Payment Terms");
2233

  
2234
  # $locale->text('Add Payment Terms')
2235
  # $locale->text('Edit Payment Terms')
2236

  
2237
  $form->{description} =~ s/\"/&quot;/g;
2238

  
2239

  
2240

  
2241
  $form->header;
2242

  
2243
  print qq|
2244
<body>
2245

  
2246
<form method=post action=am.pl>
2247

  
2248
<input type=hidden name=id value=$form->{id}>
2249
<input type=hidden name=type value=payment>
2250

  
2251
<table width=100%>
2252
  <tr>
2253
    <th class=listtop colspan=2>$form->{title}</th>
2254
  </tr>
2255
  <tr height="5"></tr>
2256
  <tr>
2257
    <th align=right>| . $locale->text('Description') . qq|</th>
2258
    <td><input name=description size=30 value="$form->{description}"></td>
2259
  <tr>
2260
  <tr>
2261
    <th align=right>| . $locale->text('Long Description') . qq|</th>
2262
    <td><input name=description_long size=50 value="$form->{description_long}"></td>
2263
  </tr>
2264
|;
2265

  
2266
  foreach my $language (@{ $form->{"TRANSLATION"} }) {
2267
    print qq|
2268
  <tr>
2269
    <th align="right">| .
2270
    sprintf($locale->text('Translation (%s)'),
2271
            $language->{"language"})
2272
    . qq|</th>
2273
    <td><input name="description_long_$language->{language_id}" size="50"
2274
         value="| . Q($language->{"description_long"}) . qq|"></td>
2275
  </tr>
2276
|;
2277
  }
2278

  
2279
  print qq|
2280
  <tr>
2281
    <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2282
    <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2283
  </tr>
2284
  <tr>
2285
    <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2286
    <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2287
  </tr>
2288
  <tr>
2289
    <th align=right>| . $locale->text('Skonto') . qq| %</th>
2290
    <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2291
  </tr>
2292
  <td colspan=2><hr size=3 noshade></td>
2293
  </tr>
2294
</table>
2295

  
2296
<p>| . $locale->text("You can use the following strings in the long " .
2297
                     "description and all translations. They will be " .
2298
                     "replaced by their actual values by Lx-Office " .
2299
                     "before they're output.")
2300
. qq|</p>
2301

  
2302
<ul>
2303
  <li>| . $locale->text("&lt;%netto_date%&gt; -- Date the payment is due in " .
2304
                        "full")
2305
. qq|</li>
2306
  <li>| . $locale->text("&lt;%skonto_date%&gt; -- Date the payment is due " .
2307
                        "with discount")
2308
. qq|</li>
2309
  <li>| . $locale->text("&lt;%skonto_amount%&gt; -- The deductible amount")
2310
. qq|</li>
2311
  <li>| . $locale->text("&lt;%skonto_in_percent%&gt; -- The discount in percent")
2312
. qq|</li>
2313
  <li>| . $locale->text("&lt;%total%&gt; -- Amount payable")
2314
. qq|</li>
2315
  <li>| . $locale->text("&lt;%total_wo_skonto%&gt; -- Amount payable less discount")
2316
. qq|</li>
2317
  <li>| . $locale->text("&lt;%invtotal%&gt; -- Invoice total")
2318
. qq|</li>
2319
  <li>| . $locale->text("&lt;%invtotal_wo_skonto%&gt; -- Invoice total less discount")
2320
. qq|</li>
2321
  <li>| . $locale->text("&lt;%currency%&gt; -- The selected currency")
2322
. qq|</li>
2323
  <li>| . $locale->text("&lt;%terms_netto%&gt; -- The number of days for " .
2324
                        "full payment")
2325
. qq|</li>
2326
  <li>| . $locale->text("&lt;%account_number%&gt; -- Your account number")
2327
. qq|</li>
2328
  <li>| . $locale->text("&lt;%bank%&gt; -- Your bank")
2329
. qq|</li>
2330
  <li>| . $locale->text("&lt;%bank_code%&gt; -- Your bank code")
2331
. qq|</li>
2332
</ul>|;
2333

  
2334
  $main::lxdebug->leave_sub();
2335
}
2336

  
2337
sub save_payment {
2338
  $main::lxdebug->enter_sub();
2339

  
2340
  my $form     = $main::form;
2341
  my %myconfig = %main::myconfig;
2342
  my $locale   = $main::locale;
2343

  
2344
  $main::auth->assert('config');
2345

  
2346
  $form->isblank("description", $locale->text('Description missing!'));
2347
  $form->{"percent_skonto"} =
2348
    $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2349
  AM->save_payment(\%myconfig, \%$form);
2350
  $form->redirect($locale->text('Payment Terms saved!'));
2351

  
2352
  $main::lxdebug->leave_sub();
2353
}
2354

  
2355
sub delete_payment {
2356
  $main::lxdebug->enter_sub();
2357

  
2358
  my $form     = $main::form;
2359
  my %myconfig = %main::myconfig;
2360
  my $locale   = $main::locale;
2361

  
2362
  $main::auth->assert('config');
2363

  
2364
  AM->delete_payment(\%myconfig, \%$form);
2365
  $form->redirect($locale->text('Payment terms deleted!'));
2366

  
2367
  $main::lxdebug->leave_sub();
2368
}
2369

  
2370
sub swap_payment_terms {
2371
  $main::lxdebug->enter_sub();
2372

  
2373
  my $form     = $main::form;
2374
  my %myconfig = %main::myconfig;
2375

  
2376
  $main::auth->assert('config');
2377

  
2378
  AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2379
  list_payment();
2380

  
2381
  $main::lxdebug->leave_sub();
2382
}
2383

  
2384 2021
sub edit_defaults {
2385 2022
  $main::lxdebug->enter_sub();
2386 2023

  

Auch abrufbar als: Unified diff