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();
295 'The licensing module has been deactivated in lx-erp.conf.')
299 $form->{"initial"} = 1;
302 $lxdebug->leave_sub();
306 $lxdebug->enter_sub();
307 $form->{"hidden"} = ["parts_id"];
310 if ($form->{"ndx"}) {
311 $ndx = $form->{"ndx"};
312 foreach (keys(%{$form})) {
313 next unless (/^new_.*_${ndx}$/);
316 $form->{$_} = $form->{"new_${_}_${ndx}"};
320 if ($form->{"customer"}) {
321 $form->{"customer_id"} = (split(/--/, $form->{"customer"}))[1];
324 if ($form->{"customer_name"}) {
325 LICENSES->get_customers(\%myconfig, $form);
326 if (scalar(@{ $form->{"all_customers"} }) == 1) {
327 %c = %{ $form->{"all_customers"}->[0] };
328 $form->{"customer_id"} = $c{"id"};
329 $form->{"customer_name"} = $c{"name"};
330 } elsif (scalar(@{ $form->{"all_customers"} }) == 0) {
331 $form->{"customer_name"} = "";
332 delete($form->{"customer_id"});
334 print_customer_selection();
337 } elsif (defined($form->{"customer_name"})) {
338 delete($form->{"customer_id"});
341 if ($form->{"partnumber"} || $form->{"description"}) {
342 $form->{"sort"} = "p.partnumber";
343 $form->{searchitems} = "part";
344 IC->all_parts(\%myconfig, $form);
345 if (scalar(@{ $form->{"parts"} }) == 1) {
346 map({ $form->{$_} = $form->{"parts"}->[0]->{$_}; }
347 ("partnumber", "description"));
348 $form->{"parts_id"} = $form->{"parts"}->[0]->{"id"};
350 } elsif (scalar(@{ $form->{"parts"} }) == 0) {
351 map({ $form->{$_} = ""; }("partnumber", "description", "parts_id"));
354 print_part_selection();
358 delete($form->{"parts_id"});
361 $form->all_vc(\%myconfig, "customer", "");
363 print_license_form($form->{"parts_id"} && $form->{"customer_id"});
366 $lxdebug->leave_sub();
370 $lxdebug->enter_sub();
372 $lxdebug->leave_sub();
376 $lxdebug->enter_sub();
377 &{ $form->{nextsub} };
378 $lxdebug->leave_sub();
382 $lxdebug->enter_sub();
384 ($form->{customername}, $form->{customer_id}) = split /--/,
387 $form->isblank("customer", $locale->text('Customer missing!'));
389 if ( $form->{quantity} eq ""
390 || $form->{quantity} !~ /^[0-9]*$/
391 || $form->{quantity} < 1) {
392 $form->error($locale->text('Please enter a number of licenses.'));
395 if (!$form->{licensenumber} || $form->{licensenumber} eq "") {
396 $form->error($locale->text('Please enter a license key.'));
399 $rc = LICENSES->save_license(\%myconfig, \%$form);
401 # load previous variables
402 if ($form->{previousform}) {
404 # save the new form variables before splitting previousform
405 map { $newform{$_} = $form->{$_} } keys %$form;
407 $previousform = $form->unescape($form->{previousform});
409 # don't trample on previous variables
410 map { delete $form->{$_} } keys %newform;
412 # now take it apart and restore original values
413 foreach $item (split /&/, $previousform) {
414 ($key, $value) = split /=/, $item, 2;
416 $form->{$key} = $value;
419 $form->{"lizenzen_$form->{row}"} =
420 "<option value=$rc>$newform{licensenumber}</option>";
423 delete $form->{action};
425 # restore original callback
426 $callback = $form->unescape($form->{callback});
427 $form->{callback} = $form->unescape($form->{old_callback});
428 delete $form->{old_callback};
430 # put callback together
431 foreach $key (keys %$form) {
433 # do single escape for Apache 2.0
434 $value = $form->escape($form->{$key}, 1);
435 $callback .= qq|&$key=$value|;
437 $form->{callback} = $callback;
445 print("Die Lizenz wurde gespeichert.\n");
449 $lxdebug->leave_sub();
453 $lxdebug->enter_sub();
457 'The licensing module has been deactivated in lx-erp.conf.')
467 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
472 <th align=right>| . $locale->text('Part Number') . qq|</th>
473 <td><input name=partnumber></td>
476 <th align=right>| . $locale->text('Description') . qq|</th>
477 <td><input name=description></td>
480 <th align=right>| . $locale->text('Company Name') . qq|</th>
481 <td><input name=customer_name></td>
484 <th align=right>| . $locale->text('Include in Report') . qq|</th>
485 <td><input type=radio name=all value=1 checked>|
486 . $locale->text('All')
487 . qq| <input type=radio name=all value=0>|
488 . $locale->text('Expiring in x month(s)')
489 . qq| <input size=4 name=expiring_in value="1"><br>
490 <input type=checkbox name=show_expired value=1>|
491 . $locale->text('Expired licenses')
496 <tr><td colspan=4><hr size=3 noshade></td></tr>
499 <input type=hidden name=nextsub value=\"do_search\">
500 <input type=submit name=action value=\"| . $locale->text('Continue') . qq|\">
505 $lxdebug->leave_sub();
509 $lxdebug->enter_sub();
510 LICENSES->search(\%myconfig, $form);
514 ("db", "path", "login", "password",
515 "partnumber", "description", "customer_name", "all",
516 "expiring_in", "show_expired")
518 $callback .= "\&${_}=" . $form->escape($form->{$_}, 1);
520 $details = $form->{"script"} . "?action=details" . $callback . "\&id=";
521 $invdetails = "is.pl?action=edit" . $callback . "\&id=";
522 $callback = $form->{"script"} . "?action=do_search" . $callback;
524 $form->{"sortby"} = "validuntil" unless ($form->{"sortby"});
525 $form->{"sortasc"} *= 1;
526 foreach (("partnumber", "description", "name", "validuntil", "invnumber")) {
527 $columns{$_} = $callback . "\&sortby=${_}\&sortasc=";
528 if ($form->{"sortby"} eq $_) {
529 $columns{$_} .= (1 - $form->{"sortasc"});
541 <th class=listtop>| . $locale->text("Licenses") . qq|</th>
544 if (scalar(@{ $form->{"licenses"} }) == 0) {
547 "No licenses were found that match the search criteria.")
548 . qq|</body></html>|);
557 <th class=listtop><a class=listheading href=\"|
558 . $columns{"partnumber"} . "\">"
559 . $locale->text('Part Number')
561 <th class=listtop><a class=listheading href=\"|
562 . $columns{"description"} . "\">"
563 . $locale->text('Description')
565 <th class=listtop><a class=listheading href=\"|
566 . $columns{"name"} . "\">"
567 . $locale->text('Company Name')
569 <th class=listtop><a class=listheading href=\"|
570 . $columns{"validuntil"} . "\">"
571 . $locale->text('Valid until')
573 <th class=listtop><a class=listheading href=\"|
574 . $columns{"invnumber"} . "\">"
575 . $locale->text('Invoice Number')
581 for ($i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) {
582 $ref = $form->{"licenses"}->[$i];
586 <td><input type=hidden name=id_$i value=| . $ref->{"id"} . qq|
587 <a href=\"${details}$ref->{"id"}\">$ref->{"partnumber"}</a></td>
588 <td><a href=\"${details}$ref->{"id"}\">$ref->{"description"}</a></td>
589 <td><a href=\"${details}$ref->{"id"}\">$ref->{"name"}</a></td>
590 <td><a href=\"${details}$ref->{"id"}\">$ref->{"validuntil"}</a></td>
594 ? qq|<a href=\"${invdetails}$ref->{"invnumber"}\">$ref->{"invnumber"}</a>|
602 $form->{"num_licenses"} = scalar(@{ $form->{"licenses"} });
603 push(@{ $form->{"hidden"} }, "num_licenses");
610 <td><hr size=3 noshade></td>
616 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
620 $lxdebug->leave_sub();
624 $lxdebug->enter_sub();
625 LICENSES->get_license(\%myconfig, $form);
627 { $form->{$_} = $form->{"license"}->{$_}; } keys(%{ $form->{"license"} }));
635 <th class=listtop>| . $locale->text("View License") . qq|</th>
640 <th align=right>| . $locale->text('Part Number') . qq|</th>
641 <td>$form->{"partnumber"}</td>
644 <th align=right>| . $locale->text('Description') . qq|</th>
645 <td>$form->{"description"}</td>
648 <th align=right>| . $locale->text('Company Name') . qq|</th>
649 <td>$form->{"name"}</td>
652 <th align=right>| . $locale->text('Comment') . qq|</th>
653 <td>$form->{"comment"}</td>
656 <th align=right>| . $locale->text('Valid until') . qq|</th>
657 <td>$form->{"validuntil"}</td>
660 <th align=right>| . $locale->text('Quantity') . qq|</th>
661 <td>$form->{"quantity"}</td>
664 <th align=right>| . $locale->text('License key') . qq|</th>
665 <td>$form->{"licensenumber"}</td>
670 <td><hr size=3 noshade></td>
674 <input type=submit name=action value=\"| . $locale->text("Add") . qq|\">
678 $lxdebug->leave_sub();