Permalink
Browse files

added current depreciation value calculation queries

  • Loading branch information...
1 parent b2ce9cf commit 550c8b1813345bc820c5d3612575503376d6b0dd Spiros Ioannou committed Nov 18, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 php/reports.php
View
@@ -29,6 +29,8 @@
'allips' => t('List items with defined IPv4 numbers'),
'noinvoice' => t('Items without invoices'),
'nolocation' => t('Items without location'),
+'depreciation3' => t('Item depreciation value 3 years'),
+'depreciation5' => t('Item depreciation value 5 years'),
);
@@ -63,6 +65,29 @@
<?php
switch ($query) {
+
+ case "depreciation5":
+ $sql="select items.id as ID,typedesc as type, agents.title as manufacturer ,model, strftime('%Y-%m-%d', purchasedate,'unixepoch') AS PurchaseDate, ".
+ "purchprice as PurchasePrice, ".
+ " cast( ((strftime('%s','now') - purchasedate)/(60*60*24*30.4)*(purchasedate AND 1)) AS INTEGER) as Months , ".
+ " (purchprice-purchprice/60*cast( ((strftime('%s','now') - purchasedate)/(60*60*24*30.4)*(purchasedate AND 1)) AS INTEGER)) as CurrentValue ".
+ " FROM items,itemtypes,agents ".
+ " WHERE agents.id=manufacturerid AND itemtypes.id=items.itemtypeid ";
+ $editlnk="$scriptname?action=edititem&id";
+ break;
+
+
+ case "depreciation3":
+ $sql="select items.id as ID,typedesc as type, agents.title as manufacturer ,model, strftime('%Y-%m-%d', purchasedate,'unixepoch') AS PurchaseDate, ".
+ "purchprice as PurchasePrice, ".
+ " cast( ((strftime('%s','now') - purchasedate)/(60*60*24*30.4)*(purchasedate AND 1)) AS INTEGER) as Months , ".
+ " (purchprice-purchprice/36*cast( ((strftime('%s','now') - purchasedate)/(60*60*24*30.4)*(purchasedate AND 1)) AS INTEGER)) as CurrentValue ".
+ " FROM items,itemtypes,agents ".
+ " WHERE agents.id=manufacturerid AND itemtypes.id=items.itemtypeid ";
+ $editlnk="$scriptname?action=edititem&id";
+ break;
+
+
case "noinvoice":
$sql="select items.id as ID,typedesc as type, agents.title as manufacturer ,model, strftime('%Y-%m-%d', purchasedate,'unixepoch') AS PurchaseDate".
" FROM items,itemtypes,agents ".

0 comments on commit 550c8b1

Please sign in to comment.