Umstellung der Benutzerverwaltung von Dateien im Verzeichnis "users" auf die Verwendu...
[kivitendo-erp.git] / bin / mozilla / licenses.pl
index 4efab2f..93efc24 100644 (file)
@@ -35,6 +35,8 @@ use SL::IC;
 use SL::IS;
 use SL::LICENSES;
 
+require "bin/mozilla/common.pl";
+
 sub quot {
   $lxdebug->enter_sub();
   $_[0] =~ s/\"/\"/g;
@@ -44,6 +46,10 @@ sub quot {
 
 sub form_header {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
+  $form->{jsscript} = 1;
   $form->header();
 
   print(
@@ -55,7 +61,10 @@ sub form_header {
 
 sub form_footer {
   $lxdebug->enter_sub();
-  my @items = ("path", "login", "password", "old_callback", "previousform");
+
+  $auth->assert('license_edit');
+
+  my @items = qw(old_callback previousform);
   push(@items, @{ $form->{"hidden"} });
   map({
       print("<input type=hidden name=$_ value=\"" . quot($form->{$_}) . "\">\n"
@@ -78,6 +87,9 @@ sub set_std_hidden {
 
 sub print_part_selection {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   form_header();
   set_std_hidden("business");
 
@@ -87,8 +99,7 @@ sub print_part_selection {
 <table width=100%>
   <tr>
     <th class=listtop colspan=5>|
-      . $locale->text('Select from one of the items below')
-      . qq|</th>
+      . $locale->text('Select from one of the items below') . qq|</th>
   </tr>
   <tr height="5"></tr>
   <tr class=listheading>
@@ -111,13 +122,9 @@ sub print_part_selection {
       qq|<tr class=listrow$j>
       <td><input name=ndx class=radio type=radio value=$i $checked></td>
       <td><input name=\"new_partnumber_$i\" type=hidden value=\"|
-        . $p{"partnumber"} . qq|\">|
-        . $p{"partnumber"}
-        . qq|</td>
+        . $p{"partnumber"} . qq|\">| . $p{"partnumber"} . qq|</td>
       <td><input name=\"new_description_$i\" type=hidden value=\"|
-        . $p{"description"} . qq|\">|
-        . $p{"description"}
-        . qq|</td>
+        . $p{"description"} . qq|\">| . $p{"description"} . qq|</td>
       <input name=\"new_parts_id_$i\" type=hidden value=\"| . $p{"id"} . qq|\">
     </tr>|);
 
@@ -137,6 +144,9 @@ sub print_part_selection {
 
 sub print_customer_selection {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   form_header();
   set_std_hidden("parts_id", "partnumber", "description");
 
@@ -145,8 +155,7 @@ sub print_customer_selection {
 <table width=100%>
   <tr>
     <th class=listtop colspan=5>|
-      . $locale->text('Select from one of the names below')
-      . qq|</th>
+      . $locale->text('Select from one of the names below') . qq|</th>
   </tr>
   <tr height="5"></tr>
   <tr class=listheading>
@@ -174,11 +183,9 @@ sub print_customer_selection {
       qq|<tr class=listrow$j>
           <td><input name=ndx class=radio type=radio value=$i $checked></td>
           <td><input name=\"new_customer_id_$i\" type=hidden value=\"|
-        . $c{"id"}
-        . qq|\">$c{"customernumber"}</td>
+        . $c{"id"} . qq|\">$c{"customernumber"}</td>
           <td><input name=\"new_customer_name_$i\" type=hidden value=\"|
-        . $c{"name"}
-        . qq|\">$c{"name"}</td>
+        . $c{"name"} . qq|\">$c{"name"}</td>
           <td>$c{"street"}</td>
           <td>$c{"zipcode"}</td>
           <td>$c{"city"}</td>
@@ -200,6 +207,9 @@ sub print_customer_selection {
 
 sub print_license_form {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   print(
     qq|
 <table width=100%>
@@ -211,14 +221,12 @@ sub print_license_form {
       <tr>
         <th align=right>| . $locale->text('Part Number') . qq|</th>
         <td><input name=partnumber value=\"|
-      . quot($form->{"partnumber"})
-      . qq|\"></td>
+      . quot($form->{"partnumber"}) . qq|\"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('Description') . qq|</th>
         <td><input name=description value=\"|
-      . quot($form->{"description"})
-      . qq|\"></td>
+      . quot($form->{"description"}) . qq|\"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('Company Name') . qq|</th>|);
@@ -242,26 +250,23 @@ sub print_license_form {
       <tr>
         <th align=right>| . $locale->text('Comment') . qq|</th>
         <td><input name=comment value=\"|
-      . quot($form->{"comment"})
-      . qq|\"></td>
+      . quot($form->{"comment"}) . qq|\"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('Valid until') . qq|</th>
-        <td><input name=validuntil value=\"|
-      . quot($form->{"validuntil"})
-      . qq|\"></td>
+        <td><input id=validuntil name=validuntil value=\"|
+      . quot($form->{"validuntil"}) . qq|\">
+         <input type="button" name="validuntil" id="trigger_validuntil" value="?"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('Quantity') . qq|</th>
         <td><input name=quantity value=\"|
-      . quot($form->{"quantity"})
-      . qq|\"></td>
+      . quot($form->{"quantity"}) . qq|\"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('License key') . qq|</th>
         <td><input name=licensenumber value=\"|
-      . quot($form->{"licensenumber"})
-      . qq|\"></td>
+      . quot($form->{"licensenumber"}) . qq|\"></td>
       </tr>
       <tr>
         <th align=right>| . $locale->text('Own Product') . qq|</th>
@@ -276,19 +281,24 @@ sub print_license_form {
     print(
       qq|&nbsp;
           <input type=submit name=action value=\"|
-        . $locale->text('Save')
-        . qq|\">\n|);
+        . $locale->text('Save') . qq|\">\n|);
   }
   print(
     qq|
   </tr>
 
-</table>|);
+</table>| .
+    $form->write_trigger(\%myconfig, 1, "validuntil", "BL",
+                         "trigger_validuntil"));
+
   $lxdebug->leave_sub();
 }
 
 sub add {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   if (!$lizenzen) {
     $form->error(
                  $locale->text(
@@ -304,6 +314,9 @@ sub add {
 
 sub do_add {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   $form->{"hidden"} = ["parts_id"];
   form_header();
 
@@ -368,19 +381,25 @@ sub do_add {
 
 sub update {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   do_add();
+
   $lxdebug->leave_sub();
 }
 
 sub continue {
   $lxdebug->enter_sub();
-  &{ $form->{nextsub} };
+  call_sub($form->{"nextsub"});
   $lxdebug->leave_sub();
 }
 
 sub save {
   $lxdebug->enter_sub();
 
+  $auth->assert('license_edit');
+
   ($form->{customername}, $form->{customer_id}) = split /--/,
     $form->{customer};
 
@@ -429,6 +448,7 @@ sub save {
 
     # put callback together
     foreach $key (keys %$form) {
+      next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
 
       # do single escape for Apache 2.0
       $value = $form->escape($form->{$key}, 1);
@@ -451,6 +471,9 @@ sub save {
 
 sub search {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   if (!$lizenzen) {
     $form->error(
                  $locale->text(
@@ -488,12 +511,11 @@ sub search {
       . $locale->text('Expiring in x month(s)')
       . qq|&nbsp;<input size=4 name=expiring_in value="1"><br>
         <input type=checkbox name=show_expired value=1>|
-      . $locale->text('Expired licenses')
-      . qq|</td>
+      . $locale->text('Expired licenses') . qq|</td>
       </tr>
     </table>
   </tr>
-  <tr><td colspan=4><hr size=3 noshade></td></tr>                               
+  <tr><td colspan=4><hr size=3 noshade></td></tr>
 </table>
 
 <input type=hidden name=nextsub value=\"do_search\">
@@ -507,16 +529,14 @@ sub search {
 
 sub do_search {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   LICENSES->search(\%myconfig, $form);
 
   $callback = "";
-  foreach (
-           ("db",          "path",        "login",         "password",
-            "partnumber",  "description", "customer_name", "all",
-            "expiring_in", "show_expired")
-    ) {
-    $callback .= "\&${_}=" . $form->escape($form->{$_}, 1);
-  }
+  map { $callback .= "\&${_}=" . $form->escape($form->{$_}, 1) }
+    qw(db partnumber description customer_name all expiring_in show_expired);
   $details    = $form->{"script"} . "?action=details" . $callback . "\&id=";
   $invdetails = "is.pl?action=edit" . $callback . "\&id=";
   $callback   = $form->{"script"} . "?action=do_search" . $callback;
@@ -563,9 +583,7 @@ sub do_search {
       . $locale->text('Description')
       . qq|</a></th>
         <th class=listtop><a class=listheading href=\"|
-      . $columns{"name"} . "\">"
-      . $locale->text('Company Name')
-      . qq|</a></th>
+      . $columns{"name"} . "\">" . $locale->text('Company Name') . qq|</a></th>
         <th class=listtop><a class=listheading href=\"|
       . $columns{"validuntil"} . "\">"
       . $locale->text('Valid until')
@@ -622,6 +640,9 @@ sub do_search {
 
 sub details {
   $lxdebug->enter_sub();
+
+  $auth->assert('license_edit');
+
   LICENSES->get_license(\%myconfig, $form);
   map(
     { $form->{$_} = $form->{"license"}->{$_}; } keys(%{ $form->{"license"} }));