Bei Dienstleistungen auch den Einkaufspreis parsen, wenn auf "Erneuern" gedrückt...
[kivitendo-erp.git] / bin / mozilla / ic.pl
index df330d3..7ecd3a2 100644 (file)
@@ -397,7 +397,6 @@ $jsscript
   $lxdebug->leave_sub();
 }    #end search()
 
-
 sub search_update_prices {
   $lxdebug->enter_sub();
 
@@ -2056,7 +2055,9 @@ sub parts_subtotal {
 
 sub edit {
   $lxdebug->enter_sub();
-
+  # show history button
+  $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
+  #/show hhistory button
   IC->get_part(\%myconfig, \%$form);
 
   $form->{"original_partnumber"} = $form->{"partnumber"};
@@ -2714,9 +2715,26 @@ sub form_footer {
     }
   }
 
+  if (!$form->{previousform}) {
+    if ($form->{menubar}) {
+      require "$form->{path}/menu.pl";
+      &menubar;
+    }
+  }
+# button for saving history
+  if($form->{id} ne "") {
+       print qq|
+               <input type=button class=submit onclick=set_history_window(|
+               . $form->{id} 
+               . qq|); name=history id=history value=|
+               . $locale->text('history') 
+               . qq|>|;
+  }
+# /button for saving history
   print qq|
 
 </form>
+
 <script type="text/javascript" src="js/wz_tooltip.js"></script>
 
 </body>
@@ -2982,8 +3000,8 @@ sub update {
   }
 
   if ($form->{item} eq 'service') {
-    map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-      qw(sellprice listprice);
+    map({ $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
+        qw(sellprice listprice lastcost));
     &form_header;
     &price_row;
     &form_footer;
@@ -3006,7 +3024,7 @@ sub save {
       $locale->text(
         "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
       ))
-      if ($form->{onhand});
+      if ($form->{onhand} * 1);
   }
 
   if (!$form->{buchungsgruppen_id}) {
@@ -3032,6 +3050,12 @@ sub save {
   if ($rc == 3) {
     $form->error($locale->text('Partnumber not unique!'));
   }
+  # saving the history
+  if(!exists $form->{addition}) {
+       $form->{addition} = "SAVED";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history
   $parts_id = $form->{id};
 
   # load previous variables
@@ -3148,19 +3172,29 @@ sub save {
 sub save_as_new {
   $lxdebug->enter_sub();
 
+  # saving the history
+  if(!exists $form->{addition}) {
+       $form->{addition} = "SAVED AS NEW";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history
   $form->{id} = 0;
   if ($form->{"original_partnumber"} &&
       ($form->{"partnumber"} eq $form->{"original_partnumber"})) {
     $form->{partnumber} = "";
   }
   &save;
-
   $lxdebug->leave_sub();
 }
 
 sub delete {
   $lxdebug->enter_sub();
-
+  # saving the history
+  if(!exists $form->{addition}) {
+       $form->{addition} = "DELETED";
+       $form->save_history($form->dbconnect(\%myconfig));
+  }
+  # /saving the history
   $rc = IC->delete(\%myconfig, \%$form);
 
   # redirect
@@ -3170,181 +3204,6 @@ sub delete {
   $lxdebug->leave_sub();
 }
 
-sub stock_assembly {
-  $lxdebug->enter_sub();
-
-  $form->{title} = $locale->text('Stock Assembly');
-
-  $form->header;
-
-  print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width="100%">
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr valign=top>
-    <td>
-      <table>
-        <tr>
-          <th align="right" nowrap="true">|
-    . $locale->text('Part Number') . qq|</th>
-          <td><input name=partnumber size=20></td>
-          <td>&nbsp;</td>
-        </tr>
-        <tr>
-          <th align="right" nowrap="true">|
-    . $locale->text('Part Description') . qq|</th>
-          <td><input name=description size=40></td>
-        </tr>
-      </table>
-    </td>
-  </tr>
-  <tr><td><hr size=3 noshade></td></tr>
-</table>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
-<input type=hidden name=nextsub value=list_assemblies>
-
-<br>
-<input class=submit type=submit name=action value="|
-    . $locale->text('Continue') . qq|">
-</form>
-
-</body>
-</html>
-|;
-
-  $lxdebug->leave_sub();
-}
-
-sub list_assemblies {
-  $lxdebug->enter_sub();
-
-  IC->retrieve_assemblies(\%myconfig, \%$form);
-
-  $column_header{partnumber} =
-    qq|<th class=listheading>| . $locale->text('Part Number') . qq|</th>|;
-  $column_header{description} =
-    qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
-  $column_header{bin} =
-    qq|<th class=listheading>| . $locale->text('Bin') . qq|</th>|;
-  $column_header{onhand} =
-    qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
-  $column_header{rop} =
-    qq|<th class=listheading>| . $locale->text('ROP') . qq|</th>|;
-  $column_header{stock} =
-    qq|<th class=listheading>| . $locale->text('Add') . qq|</th>|;
-
-  @column_index = (qw(partnumber description bin onhand rop stock));
-
-  $form->{title} = $locale->text('Stock Assembly');
-
-  $form->{callback} =
-    "$form->{script}?action=stock_assembly&path=$form->{path}&login=$form->{login}&password=$form->{password}";
-
-  $form->header;
-
-  $colspan = $#column_index + 1;
-
-  print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
-  <tr>
-    <th class=listtop colspan=$colspan>$form->{title}</th>
-  </tr>
-  <tr size=5></tr>
-  <tr class=listheading>|;
-
-  map { print "\n$column_header{$_}" } @column_index;
-
-  print qq|
-  </tr>
-|;
-
-  $i = 1;
-  foreach $ref (@{ $form->{assembly_items} }) {
-
-    map { $ref->{$_} =~ s/\"/&quot;/g } qw(partnumber description);
-
-    $column_data{partnumber}  = qq|<td width=20%>$ref->{partnumber}</td>|;
-    $column_data{description} =
-      qq|<td width=50%>$ref->{description}&nbsp;</td>|;
-    $column_data{bin}    = qq|<td>$ref->{bin}&nbsp;</td>|;
-    $column_data{onhand} =
-        qq|<td align=right>|
-      . $form->format_amount(\%myconfig, $ref->{onhand})
-      . qq|</td>|;
-    $column_data{rop} =
-        qq|<td align=right>|
-      . $form->format_amount(\%myconfig, $ref->{rop})
-      . qq|</td>|;
-    $column_data{stock} = qq|<td width=10%><input name="qty_$i" size=10></td>|;
-
-    $j++;
-    $j %= 2;
-    print
-      qq|<tr class=listrow$j><input name="id_$i" type=hidden value=$ref->{id}>\n|;
-
-    map { print "\n$column_data{$_}" } @column_index;
-
-    print qq|
-    </tr>
-|;
-
-    $i++;
-
-  }
-
-  $i--;
-  print qq|
-  <tr>
-    <td colspan=6><hr size=3 noshade>
-  </tr>
-</table>
-<input name=rowcount type=hidden value="$i">
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=nextsub value=restock_assemblies>
-
-<br>
-<input class=submit type=submit name=action value="|
-    . $locale->text('Continue') . qq|">
-
-</form>
-
-</body>
-</html>
-|;
-
-  $lxdebug->leave_sub();
-}
-
-sub restock_assemblies {
-  $lxdebug->enter_sub();
-
-  $form->redirect($locale->text('Assemblies restocked!'))
-    if (IC->restock_assemblies(\%myconfig, \%$form));
-  $form->error($locale->text('Cannot stock assemblies!'));
-
-  $lxdebug->leave_sub();
-}
-
 sub price_row {
   $lxdebug->enter_sub();
 
@@ -3378,7 +3237,6 @@ sub price_row {
   $lxdebug->leave_sub();
 }
 
-
 sub parts_language_selection {
   $lxdebug->enter_sub();