1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
11 # Author: Moritz Bunkus
12 # Email: m.bunkus@linet-services.de
13 # Web: http://www.linet-services.de/
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
30 # Software license module
32 #======================================================================
39 $lxdebug->enter_sub();
40 $_[0] =~ s/\"/\"/g;
41 $lxdebug->leave_sub();
46 $lxdebug->enter_sub();
52 <form method=post action=$form->{script}>|);
53 $lxdebug->leave_sub();
57 $lxdebug->enter_sub();
58 my @items = ("path", "login", "password", "old_callback", "previousform");
59 push(@items, @{ $form->{"hidden"} });
61 print("<input type=hidden name=$_ value=\"" . quot($form->{$_}) . "\">\n"
70 $lxdebug->leave_sub();
74 $lxdebug->enter_sub();
75 $form->{"hidden"} = ["comment", "validuntil", "quantity", @_];
76 $lxdebug->leave_sub();
79 sub print_part_selection {
80 $lxdebug->enter_sub();
82 set_std_hidden("business");
89 <th class=listtop colspan=5>|
90 . $locale->text('Select from one of the items below') . qq|</th>
93 <tr class=listheading>
95 <th class=listheading>| . $locale->text('Part Number') . qq|</th>
96 <th class=listheading>| . $locale->text('Description') . qq|</th>
101 for ($i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) {
102 %p = %{ $form->{"parts"}->[$i - 1] };
104 $checked = "checked";
110 qq|<tr class=listrow$j>
111 <td><input name=ndx class=radio type=radio value=$i $checked></td>
112 <td><input name=\"new_partnumber_$i\" type=hidden value=\"|
113 . $p{"partnumber"} . qq|\">| . $p{"partnumber"} . qq|</td>
114 <td><input name=\"new_description_$i\" type=hidden value=\"|
115 . $p{"description"} . qq|\">| . $p{"description"} . qq|</td>
116 <input name=\"new_parts_id_$i\" type=hidden value=\"| . $p{"id"} . qq|\">
123 qq|<tr><td colspan=3><hr size=3 noshade></td></tr>
126 <input type=hidden name=nextsub value=\"do_add\">
127 <input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
130 $lxdebug->leave_sub();
133 sub print_customer_selection {
134 $lxdebug->enter_sub();
136 set_std_hidden("parts_id", "partnumber", "description");
142 <th class=listtop colspan=5>|
143 . $locale->text('Select from one of the names below') . qq|</th>
146 <tr class=listheading>
148 <th class=listheading>| . $locale->text('Customer Number') . qq|</th>
149 <th class=listheading>| . $locale->text('Company Name') . qq|</th>
150 <th class=listheading>| . $locale->text('Street') . qq|</th>
151 <th class=listheading>| . $locale->text('Zipcode') . qq|</th>
152 <th class=listheading>| . $locale->text('City') . qq|</th>
156 print(qq|<tr><td colspan=6><hr size=3 noshade></td></tr>|);
159 for ($i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) {
160 %c = %{ $form->{"all_customers"}->[$i - 1] };
162 $checked = "checked";
168 qq|<tr class=listrow$j>
169 <td><input name=ndx class=radio type=radio value=$i $checked></td>
170 <td><input name=\"new_customer_id_$i\" type=hidden value=\"|
171 . $c{"id"} . qq|\">$c{"customernumber"}</td>
172 <td><input name=\"new_customer_name_$i\" type=hidden value=\"|
173 . $c{"name"} . qq|\">$c{"name"}</td>
174 <td>$c{"street"}</td>
175 <td>$c{"zipcode"}</td>
186 <input type=hidden name=nextsub value=\"do_add\">
187 <input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
190 $lxdebug->leave_sub();
193 sub print_license_form {
194 $lxdebug->enter_sub();
199 <th class=listtop>| . $locale->text("Add License") . qq|</th>
204 <th align=right>| . $locale->text('Part Number') . qq|</th>
205 <td><input name=partnumber value=\"|
206 . quot($form->{"partnumber"}) . qq|\"></td>
209 <th align=right>| . $locale->text('Description') . qq|</th>
210 <td><input name=description value=\"|
211 . quot($form->{"description"}) . qq|\"></td>
214 <th align=right>| . $locale->text('Company Name') . qq|</th>|);
215 if ($form->{"all_customer"}) {
216 print(qq|<td><select name=\"customer\">|);
217 foreach (@{ $form->{"all_customer"} }) {
218 if (!defined($form->{"customer_id"})) {
219 $form->{"customer_id"} = $_->{"id"};
221 $selected = ($_->{"id"} * 1) == $form->{"customer_id"} ? "selected" : "";
222 print(qq|<option $selected> $_->{"name"}--$_->{"id"}</option>|);
224 print(qq|</select></td>|);
226 print( qq|<td><input name=customer_name value=\"|
227 . quot($form->{"customer_name"})
233 <th align=right>| . $locale->text('Comment') . qq|</th>
234 <td><input name=comment value=\"|
235 . quot($form->{"comment"}) . qq|\"></td>
238 <th align=right>| . $locale->text('Valid until') . qq|</th>
239 <td><input name=validuntil value=\"|
240 . quot($form->{"validuntil"}) . qq|\"></td>
243 <th align=right>| . $locale->text('Quantity') . qq|</th>
244 <td><input name=quantity value=\"|
245 . quot($form->{"quantity"}) . qq|\"></td>
248 <th align=right>| . $locale->text('License key') . qq|</th>
249 <td><input name=licensenumber value=\"|
250 . quot($form->{"licensenumber"}) . qq|\"></td>
253 <th align=right>| . $locale->text('Own Product') . qq|</th>
254 <td><input type=checkbox name=own_product value=1 checked></td>
258 <input type=submit name=action value=\"| . $locale->text('Update') . qq|\">
264 <input type=submit name=action value=\"|
265 . $locale->text('Save') . qq|\">\n|);
272 $lxdebug->leave_sub();
276 $lxdebug->enter_sub();
280 'The licensing module has been deactivated in lx-erp.conf.')
284 $form->{"initial"} = 1;
287 $lxdebug->leave_sub();
291 $lxdebug->enter_sub();
292 $form->{"hidden"} = ["parts_id"];
295 if ($form->{"ndx"}) {
296 $ndx = $form->{"ndx"};
297 foreach (keys(%{$form})) {
298 next unless (/^new_.*_${ndx}$/);
301 $form->{$_} = $form->{"new_${_}_${ndx}"};
305 if ($form->{"customer"}) {
306 $form->{"customer_id"} = (split(/--/, $form->{"customer"}))[1];
309 if ($form->{"customer_name"}) {
310 LICENSES->get_customers(\%myconfig, $form);
311 if (scalar(@{ $form->{"all_customers"} }) == 1) {
312 %c = %{ $form->{"all_customers"}->[0] };
313 $form->{"customer_id"} = $c{"id"};
314 $form->{"customer_name"} = $c{"name"};
315 } elsif (scalar(@{ $form->{"all_customers"} }) == 0) {
316 $form->{"customer_name"} = "";
317 delete($form->{"customer_id"});
319 print_customer_selection();
322 } elsif (defined($form->{"customer_name"})) {
323 delete($form->{"customer_id"});
326 if ($form->{"partnumber"} || $form->{"description"}) {
327 $form->{"sort"} = "p.partnumber";
328 $form->{searchitems} = "part";
329 IC->all_parts(\%myconfig, $form);
330 if (scalar(@{ $form->{"parts"} }) == 1) {
331 map({ $form->{$_} = $form->{"parts"}->[0]->{$_}; }
332 ("partnumber", "description"));
333 $form->{"parts_id"} = $form->{"parts"}->[0]->{"id"};
335 } elsif (scalar(@{ $form->{"parts"} }) == 0) {
336 map({ $form->{$_} = ""; }("partnumber", "description", "parts_id"));
339 print_part_selection();
343 delete($form->{"parts_id"});
346 $form->all_vc(\%myconfig, "customer", "");
348 print_license_form($form->{"parts_id"} && $form->{"customer_id"});
351 $lxdebug->leave_sub();
355 $lxdebug->enter_sub();
357 $lxdebug->leave_sub();
361 $lxdebug->enter_sub();
362 &{ $form->{nextsub} };
363 $lxdebug->leave_sub();
367 $lxdebug->enter_sub();
369 ($form->{customername}, $form->{customer_id}) = split /--/,
372 $form->isblank("customer", $locale->text('Customer missing!'));
374 if ( $form->{quantity} eq ""
375 || $form->{quantity} !~ /^[0-9]*$/
376 || $form->{quantity} < 1) {
377 $form->error($locale->text('Please enter a number of licenses.'));
380 if (!$form->{licensenumber} || $form->{licensenumber} eq "") {
381 $form->error($locale->text('Please enter a license key.'));
384 $rc = LICENSES->save_license(\%myconfig, \%$form);
386 # load previous variables
387 if ($form->{previousform}) {
389 # save the new form variables before splitting previousform
390 map { $newform{$_} = $form->{$_} } keys %$form;
392 $previousform = $form->unescape($form->{previousform});
394 # don't trample on previous variables
395 map { delete $form->{$_} } keys %newform;
397 # now take it apart and restore original values
398 foreach $item (split /&/, $previousform) {
399 ($key, $value) = split /=/, $item, 2;
401 $form->{$key} = $value;
404 $form->{"lizenzen_$form->{row}"} =
405 "<option value=$rc>$newform{licensenumber}</option>";
408 delete $form->{action};
410 # restore original callback
411 $callback = $form->unescape($form->{callback});
412 $form->{callback} = $form->unescape($form->{old_callback});
413 delete $form->{old_callback};
415 # put callback together
416 foreach $key (keys %$form) {
418 # do single escape for Apache 2.0
419 $value = $form->escape($form->{$key}, 1);
420 $callback .= qq|&$key=$value|;
422 $form->{callback} = $callback;
430 print("Die Lizenz wurde gespeichert.\n");
434 $lxdebug->leave_sub();
438 $lxdebug->enter_sub();
442 'The licensing module has been deactivated in lx-erp.conf.')
452 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
457 <th align=right>| . $locale->text('Part Number') . qq|</th>
458 <td><input name=partnumber></td>
461 <th align=right>| . $locale->text('Description') . qq|</th>
462 <td><input name=description></td>
465 <th align=right>| . $locale->text('Company Name') . qq|</th>
466 <td><input name=customer_name></td>
469 <th align=right>| . $locale->text('Include in Report') . qq|</th>
470 <td><input type=radio name=all value=1 checked>|
471 . $locale->text('All')
472 . qq| <input type=radio name=all value=0>|
473 . $locale->text('Expiring in x month(s)')
474 . qq| <input size=4 name=expiring_in value="1"><br>
475 <input type=checkbox name=show_expired value=1>|
476 . $locale->text('Expired licenses') . qq|</td>
480 <tr><td colspan=4><hr size=3 noshade></td></tr>
483 <input type=hidden name=nextsub value=\"do_search\">
484 <input type=submit name=action value=\"| . $locale->text('Continue') . qq|\">
489 $lxdebug->leave_sub();
493 $lxdebug->enter_sub();
494 LICENSES->search(\%myconfig, $form);
498 ("db", "path", "login", "password",
499 "partnumber", "description", "customer_name", "all",
500 "expiring_in", "show_expired")
502 $callback .= "\&${_}=" . $form->escape($form->{$_}, 1);
504 $details = $form->{"script"} . "?action=details" . $callback . "\&id=";
505 $invdetails = "is.pl?action=edit" . $callback . "\&id=";
506 $callback = $form->{"script"} . "?action=do_search" . $callback;
508 $form->{"sortby"} = "validuntil" unless ($form->{"sortby"});
509 $form->{"sortasc"} *= 1;
510 foreach (("partnumber", "description", "name", "validuntil", "invnumber")) {
511 $columns{$_} = $callback . "\&sortby=${_}\&sortasc=";
512 if ($form->{"sortby"} eq $_) {
513 $columns{$_} .= (1 - $form->{"sortasc"});
525 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
528 if (scalar(@{ $form->{"licenses"} }) == 0) {
531 "No licenses were found that match the search criteria.")
532 . qq|</body></html>|);
541 <th class=listtop><a class=listheading href=\"|
542 . $columns{"partnumber"} . "\">"
543 . $locale->text('Part Number')
545 <th class=listtop><a class=listheading href=\"|
546 . $columns{"description"} . "\">"
547 . $locale->text('Description')
549 <th class=listtop><a class=listheading href=\"|
550 . $columns{"name"} . "\">" . $locale->text('Company Name') . qq|</a></th>
551 <th class=listtop><a class=listheading href=\"|
552 . $columns{"validuntil"} . "\">"
553 . $locale->text('Valid until')
555 <th class=listtop><a class=listheading href=\"|
556 . $columns{"invnumber"} . "\">"
557 . $locale->text('Invoice Number')
563 for ($i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) {
564 $ref = $form->{"licenses"}->[$i];
568 <td><input type=hidden name=id_$i value=| . $ref->{"id"} . qq|
569 <a href=\"${details}$ref->{"id"}\">$ref->{"partnumber"}</a></td>
570 <td><a href=\"${details}$ref->{"id"}\">$ref->{"description"}</a></td>
571 <td><a href=\"${details}$ref->{"id"}\">$ref->{"name"}</a></td>
572 <td><a href=\"${details}$ref->{"id"}\">$ref->{"validuntil"}</a></td>
576 ? qq|<a href=\"${invdetails}$ref->{"invnumber"}\">$ref->{"invnumber"}</a>|
584 $form->{"num_licenses"} = scalar(@{ $form->{"licenses"} });
585 push(@{ $form->{"hidden"} }, "num_licenses");
592 <td><hr size=3 noshade></td>
598 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
602 $lxdebug->leave_sub();
606 $lxdebug->enter_sub();
607 LICENSES->get_license(\%myconfig, $form);
609 { $form->{$_} = $form->{"license"}->{$_}; } keys(%{ $form->{"license"} }));
617 <th class=listtop>| . $locale->text("View License") . qq|</th>
622 <th align=right>| . $locale->text('Part Number') . qq|</th>
623 <td>$form->{"partnumber"}</td>
626 <th align=right>| . $locale->text('Description') . qq|</th>
627 <td>$form->{"description"}</td>
630 <th align=right>| . $locale->text('Company Name') . qq|</th>
631 <td>$form->{"name"}</td>
634 <th align=right>| . $locale->text('Comment') . qq|</th>
635 <td>$form->{"comment"}</td>
638 <th align=right>| . $locale->text('Valid until') . qq|</th>
639 <td>$form->{"validuntil"}</td>
642 <th align=right>| . $locale->text('Quantity') . qq|</th>
643 <td>$form->{"quantity"}</td>
646 <th align=right>| . $locale->text('License key') . qq|</th>
647 <td>$form->{"licensenumber"}</td>
652 <td><hr size=3 noshade></td>
656 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
660 $lxdebug->leave_sub();