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')
94 <tr class=listheading>
96 <th class=listheading>| . $locale->text('Part Number') . qq|</th>
97 <th class=listheading>| . $locale->text('Description') . qq|</th>
102 for ($i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) {
103 %p = %{ $form->{"parts"}->[$i - 1] };
105 $checked = "checked";
111 qq|<tr class=listrow$j>
112 <td><input name=ndx class=radio type=radio value=$i $checked></td>
113 <td><input name=\"new_partnumber_$i\" type=hidden value=\"|
114 . $p{"partnumber"} . qq|\">|
117 <td><input name=\"new_description_$i\" type=hidden value=\"|
118 . $p{"description"} . qq|\">|
121 <input name=\"new_parts_id_$i\" type=hidden value=\"| . $p{"id"} . qq|\">
128 qq|<tr><td colspan=3><hr size=3 noshade></td></tr>
131 <input type=hidden name=nextsub value=\"do_add\">
132 <input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
135 $lxdebug->leave_sub();
138 sub print_customer_selection {
139 $lxdebug->enter_sub();
141 set_std_hidden("parts_id", "partnumber", "description");
147 <th class=listtop colspan=5>|
148 . $locale->text('Select from one of the names below')
152 <tr class=listheading>
154 <th class=listheading>| . $locale->text('Customer Number') . qq|</th>
155 <th class=listheading>| . $locale->text('Company Name') . qq|</th>
156 <th class=listheading>| . $locale->text('Street') . qq|</th>
157 <th class=listheading>| . $locale->text('Zipcode') . qq|</th>
158 <th class=listheading>| . $locale->text('City') . qq|</th>
162 print(qq|<tr><td colspan=6><hr size=3 noshade></td></tr>|);
165 for ($i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) {
166 %c = %{ $form->{"all_customers"}->[$i - 1] };
168 $checked = "checked";
174 qq|<tr class=listrow$j>
175 <td><input name=ndx class=radio type=radio value=$i $checked></td>
176 <td><input name=\"new_customer_id_$i\" type=hidden value=\"|
178 . qq|\">$c{"customernumber"}</td>
179 <td><input name=\"new_customer_name_$i\" type=hidden value=\"|
181 . qq|\">$c{"name"}</td>
182 <td>$c{"street"}</td>
183 <td>$c{"zipcode"}</td>
194 <input type=hidden name=nextsub value=\"do_add\">
195 <input type=submit name=action value=| . $locale->text('Continue') . qq|>|);
198 $lxdebug->leave_sub();
201 sub print_license_form {
202 $lxdebug->enter_sub();
207 <th class=listtop>| . $locale->text("Add License") . qq|</th>
212 <th align=right>| . $locale->text('Part Number') . qq|</th>
213 <td><input name=partnumber value=\"|
214 . quot($form->{"partnumber"})
218 <th align=right>| . $locale->text('Description') . qq|</th>
219 <td><input name=description value=\"|
220 . quot($form->{"description"})
224 <th align=right>| . $locale->text('Company Name') . qq|</th>|);
225 if ($form->{"all_customer"}) {
226 print(qq|<td><select name=\"customer\">|);
227 foreach (@{ $form->{"all_customer"} }) {
228 if (!defined($form->{"customer_id"})) {
229 $form->{"customer_id"} = $_->{"id"};
231 $selected = ($_->{"id"} * 1) == $form->{"customer_id"} ? "selected" : "";
232 print(qq|<option $selected> $_->{"name"}--$_->{"id"}</option>|);
234 print(qq|</select></td>|);
236 print( qq|<td><input name=customer_name value=\"|
237 . quot($form->{"customer_name"})
243 <th align=right>| . $locale->text('Comment') . qq|</th>
244 <td><input name=comment value=\"|
245 . quot($form->{"comment"})
249 <th align=right>| . $locale->text('Valid until') . qq|</th>
250 <td><input name=validuntil value=\"|
251 . quot($form->{"validuntil"})
255 <th align=right>| . $locale->text('Quantity') . qq|</th>
256 <td><input name=quantity value=\"|
257 . quot($form->{"quantity"})
261 <th align=right>| . $locale->text('License key') . qq|</th>
262 <td><input name=licensenumber value=\"|
263 . quot($form->{"licensenumber"})
267 <th align=right>| . $locale->text('Own Product') . qq|</th>
268 <td><input type=checkbox name=own_product value=1 checked></td>
272 <input type=submit name=action value=\"| . $locale->text('Update') . qq|\">
278 <input type=submit name=action value=\"|
279 . $locale->text('Save')
287 $lxdebug->leave_sub();
291 $lxdebug->enter_sub();
294 $locale->text('The licensing module has been deactivated in lx-erp.conf.')
298 $form->{"initial"} = 1;
301 $lxdebug->leave_sub();
305 $lxdebug->enter_sub();
306 $form->{"hidden"} = ["parts_id"];
309 if ($form->{"ndx"}) {
310 $ndx = $form->{"ndx"};
311 foreach (keys(%{$form})) {
312 next unless (/^new_.*_${ndx}$/);
315 $form->{$_} = $form->{"new_${_}_${ndx}"};
319 if ($form->{"customer"}) {
320 $form->{"customer_id"} = (split(/--/, $form->{"customer"}))[1];
323 if ($form->{"customer_name"}) {
324 LICENSES->get_customers(\%myconfig, $form);
325 if (scalar(@{ $form->{"all_customers"} }) == 1) {
326 %c = %{ $form->{"all_customers"}->[0] };
327 $form->{"customer_id"} = $c{"id"};
328 $form->{"customer_name"} = $c{"name"};
329 } elsif (scalar(@{ $form->{"all_customers"} }) == 0) {
330 $form->{"customer_name"} = "";
331 delete($form->{"customer_id"});
333 print_customer_selection();
336 } elsif (defined($form->{"customer_name"})) {
337 delete($form->{"customer_id"});
340 if ($form->{"partnumber"} || $form->{"description"}) {
341 $form->{"sort"} = "p.partnumber";
342 $form->{searchitems} = "part";
343 IC->all_parts(\%myconfig, $form);
344 if (scalar(@{ $form->{"parts"} }) == 1) {
345 map({ $form->{$_} = $form->{"parts"}->[0]->{$_}; }
346 ("partnumber", "description"));
347 $form->{"parts_id"} = $form->{"parts"}->[0]->{"id"};
349 } elsif (scalar(@{ $form->{"parts"} }) == 0) {
350 map({ $form->{$_} = ""; }("partnumber", "description", "parts_id"));
353 print_part_selection();
357 delete($form->{"parts_id"});
360 $form->all_vc(\%myconfig, "customer", "");
362 print_license_form($form->{"parts_id"} && $form->{"customer_id"});
365 $lxdebug->leave_sub();
369 $lxdebug->enter_sub();
371 $lxdebug->leave_sub();
375 $lxdebug->enter_sub();
376 &{ $form->{nextsub} };
377 $lxdebug->leave_sub();
381 $lxdebug->enter_sub();
383 ($form->{customername}, $form->{customer_id}) = split /--/,
386 $form->isblank("customer", $locale->text('Customer missing!'));
388 if ( $form->{quantity} eq ""
389 || $form->{quantity} !~ /^[0-9]*$/
390 || $form->{quantity} < 1) {
391 $form->error($locale->text('Please enter a number of licenses.'));
394 if (!$form->{licensenumber} || $form->{licensenumber} eq "") {
395 $form->error($locale->text('Please enter a license key.'));
398 $rc = LICENSES->save_license(\%myconfig, \%$form);
400 # load previous variables
401 if ($form->{previousform}) {
403 # save the new form variables before splitting previousform
404 map { $newform{$_} = $form->{$_} } keys %$form;
406 $previousform = $form->unescape($form->{previousform});
408 # don't trample on previous variables
409 map { delete $form->{$_} } keys %newform;
411 # now take it apart and restore original values
412 foreach $item (split /&/, $previousform) {
413 ($key, $value) = split /=/, $item, 2;
415 $form->{$key} = $value;
418 $form->{"lizenzen_$form->{row}"} =
419 "<option value=$rc>$newform{licensenumber}</option>";
422 delete $form->{action};
424 # restore original callback
425 $callback = $form->unescape($form->{callback});
426 $form->{callback} = $form->unescape($form->{old_callback});
427 delete $form->{old_callback};
429 # put callback together
430 foreach $key (keys %$form) {
432 # do single escape for Apache 2.0
433 $value = $form->escape($form->{$key}, 1);
434 $callback .= qq|&$key=$value|;
436 $form->{callback} = $callback;
444 print("Die Lizenz wurde gespeichert.\n");
448 $lxdebug->leave_sub();
452 $lxdebug->enter_sub();
456 'The licensing module has been deactivated in lx-erp.conf.')
466 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
471 <th align=right>| . $locale->text('Part Number') . qq|</th>
472 <td><input name=partnumber></td>
475 <th align=right>| . $locale->text('Description') . qq|</th>
476 <td><input name=description></td>
479 <th align=right>| . $locale->text('Company Name') . qq|</th>
480 <td><input name=customer_name></td>
483 <th align=right>| . $locale->text('Include in Report') . qq|</th>
484 <td><input type=radio name=all value=1 checked>|
485 . $locale->text('All')
486 . qq| <input type=radio name=all value=0>|
487 . $locale->text('Expiring in x month(s)')
488 . qq| <input size=4 name=expiring_in value="1"><br>
489 <input type=checkbox name=show_expired value=1>|
490 . $locale->text('Expired licenses')
495 <tr><td colspan=4><hr size=3 noshade></td></tr>
498 <input type=hidden name=nextsub value=\"do_search\">
499 <input type=submit name=action value=\"| . $locale->text('Continue') . qq|\">
504 $lxdebug->leave_sub();
508 $lxdebug->enter_sub();
509 LICENSES->search(\%myconfig, $form);
513 ("db", "path", "login", "password",
514 "partnumber", "description", "customer_name", "all",
515 "expiring_in", "show_expired")
517 $callback .= "\&${_}=" . $form->escape($form->{$_}, 1);
519 $details = $form->{"script"} . "?action=details" . $callback . "\&id=";
520 $invdetails = "is.pl?action=edit" . $callback . "\&id=";
521 $callback = $form->{"script"} . "?action=do_search" . $callback;
523 $form->{"sortby"} = "validuntil" unless ($form->{"sortby"});
524 $form->{"sortasc"} *= 1;
525 foreach (("partnumber", "description", "name", "validuntil", "invnumber")) {
526 $columns{$_} = $callback . "\&sortby=${_}\&sortasc=";
527 if ($form->{"sortby"} eq $_) {
528 $columns{$_} .= (1 - $form->{"sortasc"});
540 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
543 if (scalar(@{ $form->{"licenses"} }) == 0) {
545 . $locale->text("No licenses were found that match the search criteria.")
546 . qq|</body></html>|);
555 <th class=listtop><a class=listheading href=\"|
556 . $columns{"partnumber"} . "\">"
557 . $locale->text('Part Number')
559 <th class=listtop><a class=listheading href=\"|
560 . $columns{"description"} . "\">"
561 . $locale->text('Description')
563 <th class=listtop><a class=listheading href=\"|
564 . $columns{"name"} . "\">"
565 . $locale->text('Company Name')
567 <th class=listtop><a class=listheading href=\"|
568 . $columns{"validuntil"} . "\">"
569 . $locale->text('Valid until')
571 <th class=listtop><a class=listheading href=\"|
572 . $columns{"invnumber"} . "\">"
573 . $locale->text('Invoice Number')
579 for ($i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) {
580 $ref = $form->{"licenses"}->[$i];
584 <td><input type=hidden name=id_$i value=| . $ref->{"id"} . qq|
585 <a href=\"${details}$ref->{"id"}\">$ref->{"partnumber"}</a></td>
586 <td><a href=\"${details}$ref->{"id"}\">$ref->{"description"}</a></td>
587 <td><a href=\"${details}$ref->{"id"}\">$ref->{"name"}</a></td>
588 <td><a href=\"${details}$ref->{"id"}\">$ref->{"validuntil"}</a></td>
592 ? qq|<a href=\"${invdetails}$ref->{"invnumber"}\">$ref->{"invnumber"}</a>|
600 $form->{"num_licenses"} = scalar(@{ $form->{"licenses"} });
601 push(@{ $form->{"hidden"} }, "num_licenses");
608 <td><hr size=3 noshade></td>
614 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
618 $lxdebug->leave_sub();
622 $lxdebug->enter_sub();
623 LICENSES->get_license(\%myconfig, $form);
625 { $form->{$_} = $form->{"license"}->{$_}; } keys(%{ $form->{"license"} }));
633 <th class=listtop>| . $locale->text("View License") . qq|</th>
638 <th align=right>| . $locale->text('Part Number') . qq|</th>
639 <td>$form->{"partnumber"}</td>
642 <th align=right>| . $locale->text('Description') . qq|</th>
643 <td>$form->{"description"}</td>
646 <th align=right>| . $locale->text('Company Name') . qq|</th>
647 <td>$form->{"name"}</td>
650 <th align=right>| . $locale->text('Comment') . qq|</th>
651 <td>$form->{"comment"}</td>
654 <th align=right>| . $locale->text('Valid until') . qq|</th>
655 <td>$form->{"validuntil"}</td>
658 <th align=right>| . $locale->text('Quantity') . qq|</th>
659 <td>$form->{"quantity"}</td>
662 <th align=right>| . $locale->text('License key') . qq|</th>
663 <td>$form->{"licensenumber"}</td>
668 <td><hr size=3 noshade></td>
672 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
676 $lxdebug->leave_sub();