-
-
-
- ';
- else printf('
', $item['amount']);
- ?>
+
-
-
-
-
+
- document.querySelector('#categoryDropdown').addEventListener('change', function(evt) {
- if (evt.target.value === '-1') {
- document.querySelector('#category').value = ''
- return
- }
- document.querySelector('#category').value = evt.target.value;
- })
-
-
\ No newline at end of file
diff --git a/inventory.php b/inventory.php
index bfa281c..8dcdb5b 100644
--- a/inventory.php
+++ b/inventory.php
@@ -1,255 +1,263 @@
-
-
-
+
-
+
+
+
+
intVal($subCategoryDB['amount']) - intVal($item['amount'])), 'id=%d', $subCategoryDB['id']);
- }
+ if ($subCategoryDB != NULL) {
+ DB::update('subCategories', array('amount' => intVal($subCategoryDB['amount']) - intVal($item['amount'])), 'id=%d', $subCategoryDB['id']);
}
}
-
- $headCategory = DB::queryFirstRow('SELECT amount FROM headCategories WHERE id=%d', $item['headcategory']);
- DB::update('storages', array('amount' => intVal($storage['amount']) - intVal($item['amount'])), 'id=%d', $item['storageid']);
- DB::update('headCategories', array('amount' => intVal($headCategory['amount']) - intVal($item['amount'])), 'id=%d', $item['headcategory']);
- DB::query('DELETE FROM items WHERE id=%d', $_POST['remove']);
- } else if (isset($_POST['removeStorage']) && !empty($_POST['removeStorage'])) {
- DB::update('items', array('storageid' => 0), 'storageid=%d', $_POST['removeStorage']);
- DB::query('DELETE FROM storages WHERE id=%d', $_POST['removeStorage']);
}
+
+ $headCategory = DB::queryFirstRow('SELECT amount FROM headCategories WHERE id=%d', $item['headcategory']);
+ DB::update('storages', array('amount' => intVal($storage['amount']) - intVal($item['amount'])), 'id=%d', $item['storageid']);
+ DB::update('headCategories', array('amount' => intVal($headCategory['amount']) - intVal($item['amount'])), 'id=%d', $item['headcategory']);
+ DB::query('DELETE FROM items WHERE id=%d', $_POST['remove']);
+ } else if (isset($_POST['removeStorage']) && !empty($_POST['removeStorage'])) {
+ DB::update('items', array('storageid' => 0), 'storageid=%d', $_POST['removeStorage']);
+ DB::query('DELETE FROM storages WHERE id=%d', $_POST['removeStorage']);
}
- ?>
-
';
- } else if (isset($_GET['subcategory']) && !empty($_GET['subcategory'])) {
- $categoryId = intVal($_GET['subcategory']);
- $category = DB::queryFirstRow('SELECT id, name, amount from subCategories WHERE id=%d', $categoryId);
- $items = DB::query('SELECT * FROM items WHERE subCategories LIKE %s', ('%,' . $categoryId . ',%'));
-
- $itemCount = 0;
- foreach ($items as $item) $itemCount += intVal($item['amount']);
+ $success = FALSE;
+ if (isset($_GET['storageid']) && !empty($_GET['storageid']) && !isset($_GET['itemid'])) {
+ $storeId = intVal($_GET['storageid']);
+ $storages = DB::query('SELECT id, label, amount FROM storages ORDER BY label ASC');
+ $store = DB::queryFirstRow('SELECT id, label, amount FROM storages WHERE id=%d', $storeId);
+ $items = DB::query('SELECT * FROM items WHERE storageid=%d', $storeId);
+
+ addHeadColumns($store);
+
+ if ($items != null) foreach ($items as $item) {
+ addItem($item, $storages);
+ } else echo '
Keine Gegenstände gefunden. ';
+
+ echo '
';
+ } else if (isset($_GET['subcategory']) && !empty($_GET['subcategory'])) {
+ $categoryId = intVal($_GET['subcategory']);
+ $category = DB::queryFirstRow('SELECT id, name, amount from subCategories WHERE id=%d', $categoryId);
+ $items = DB::query('SELECT * FROM items WHERE subCategories LIKE %s', ('%,' . $categoryId . ',%'));
+
+ $itemCount = 0;
+ foreach ($items as $item) $itemCount += intVal($item['amount']);
+
+ printf('
%s (%d %s, %d %s) ', $category['name'], DB::affectedRows(), DB::affectedRows() == 1 ? 'Position' : 'Positionen', $itemCount, $itemCount == 1 ? getText('Gegenstand') : gettext('Gegenstände'));
+ $storages = DB::query('SELECT id, label FROM storages ORDER BY label ASC');
+
+ echo '' . gettext('Gruppe') . ' ' . gettext('Bezeichnung') . ' ' . gettext('Anzahl') . ' ' . gettext('Bemerkung') . ' ' . gettext('Lagerplatz') . ' ' . gettext('Unterkategorien') . ' ' . gettext('Aktionen') . ' ';
+ if ($items != null) foreach ($items as $item) {
+ addItemStore($item, $storages);
+ } else echo '' . gettext('Keine Gegenstände gefunden.') . ' ';
+
+ echo '';
+ } else if (isset($_GET['storageid']) && !empty($_GET['storageid']) && isset($_GET['itemid']) && !empty($_GET['itemid'])) {
+ $storeId = intVal($_GET['storageid']);
+ $itemId = intVal($_GET['itemid']);
+
+ $item = DB::queryFirstRow('SELECT id, amount, storageid FROM items WHERE id=%d', $itemId);
+ if ($item['storageid'] == $storeId) {
+ header("location: inventory.php");
+ die();
+ }
- printf('
%s (%d %s, %d %s) ', $category['name'], DB::affectedRows(), DB::affectedRows() == 1 ? 'Position' : 'Positionen', $itemCount, $itemCount == 1 ? getText('Gegenstand') : gettext('Gegenstände'));
- $storages = DB::query('SELECT id, label FROM storages ORDER BY label ASC');
+ if ($storeId != NULL) {
+ $previousStorage = DB::queryFirstRow('SELECT id, amount FROM storages WHERE id=%d', $item['storageid']);
+ DB::update('storages', array('amount' => intVal($previousStorage['amount']) - intVal($item['amount'])), 'id=%d', $previousStorage['id']);
+ }
- echo '' . gettext('Gruppe') . ' ' . gettext('Bezeichnung') . ' ' . gettext('Anzahl') . ' ' . gettext('Bemerkung') . ' ' . gettext('Lagerplatz') . ' ' . gettext('Unterkategorien') . ' ' . gettext('Aktionen') . ' ';
- if ($items != null) foreach($items as $item) { addItemStore($item, $storages); }
- else echo '' . gettext('Keine Gegenstände gefunden.') . ' ';
+ $storage = DB::queryFirstRow('SELECT id, amount FROM storages WHERE id=%d', $storeId);
+ DB::update('storages', array('amount' => intVal($storage['amount']) + intVal($item['amount'])), 'id=%d', $storage['id']);
+ DB::update('items', array('storageid' => $storage['id']), 'id=%d', $item['id']);
+ header("location: inventory.php");
+ die();
+ } else if (isset($_GET['searchValue']) && !empty($_GET['searchValue'])) {
+ $searchValue = $_GET['searchValue'];
+
+ $storages = DB::query('SELECT id, label, amount FROM storages');
+ $headCategories = DB::query('SELECT id, name FROM headCategories');
+ $subCategories = DB::query('SELECT id, name FROM subCategories');
+
+ $foundData = FALSE;
+
+ $existingItemIds = array();
+ foreach ($storages as $store) {
+ $hasHeader = FALSE;
+ $hasItems = FALSE;
+
+ if ($headCategories != null) {
+ foreach ($headCategories as $headCategory) {
+ if (stripos($headCategory['name'], $searchValue) !== FALSE) $items = DB::query('SELECT * FROM items WHERE storageid=%d', $store['id']);
+ else $items = DB::query('SELECT * FROM items WHERE storageid=%d AND (label LIKE %ss OR comment LIKE %ss OR serialnumber LIKE %ss)', $store['id'], $searchValue, $searchValue, $searchValue);
+
+ if ($items != null) {
+ if (!$hasHeader) {
+ addHeadColumnsPositions($store);
+ $hasHeader = TRUE;
+ }
- echo '';
- } else if (isset($_GET['storageid']) && !empty($_GET['storageid']) && isset($_GET['itemid']) && !empty($_GET['itemid'])) {
- $storeId = intVal($_GET['storageid']);
- $itemId = intVal($_GET['itemid']);
-
- $item = DB::queryFirstRow('SELECT id, amount, storageid FROM items WHERE id=%d', $itemId);
- if ($item['storageid'] == $storeId) {
- header("location: inventory.php");
- die();
- }
+ foreach ($items as $item) if (!in_array($item['id'], $existingItemIds)) {
+ addItem($item, $storages);
+ $existingItemIds[] = $item['id'];
+ }
- if ($storeId != NULL) {
- $previousStorage = DB::queryFirstRow('SELECT id, amount FROM storages WHERE id=%d', $item['storageid']);
- DB::update('storages', array('amount' => intVal($previousStorage['amount']) - intVal($item['amount'])), 'id=%d', $previousStorage['id']);
+ $hasItems = TRUE;
+ $foundData = TRUE;
+ }
+ }
}
- $storage = DB::queryFirstRow('SELECT id, amount FROM storages WHERE id=%d', $storeId);
- DB::update('storages', array('amount' => intVal($storage['amount']) + intVal($item['amount'])), 'id=%d', $storage['id']);
- DB::update('items', array('storageid' => $storage['id']), 'id=%d', $item['id']);
- header("location: inventory.php");
- die();
- } else if (isset($_GET['searchValue']) && !empty($_GET['searchValue'])) {
- $searchValue = $_GET['searchValue'];
-
- $storages = DB::query('SELECT id, label, amount FROM storages');
- $headCategories = DB::query('SELECT id, name FROM headCategories');
- $subCategories = DB::query('SELECT id, name FROM subCategories');
+ if ($subCategories != null) {
+ foreach ($subCategories as $subCategory) {
+ if (stripos($subCategory['name'], $searchValue) !== FALSE) $items = DB::query('SELECT * FROM items WHERE storageid=%d AND subcategories LIKE %s', $store['id'], ('%,' . $subCategory['id'] . ',%'));
+ else $items = DB::query('SELECT * FROM items WHERE storageid=%d AND subcategories LIKE %s AND (label LIKE %ss OR comment LIKE %ss OR serialnumber LIKE %ss)', $store['id'], ('%,' . $subCategory['id'] . ',%'), $searchValue, $searchValue, $searchValue, ($searchValue . '%'));
- $foundData = FALSE;
+ if ($items != null) {
+ if (!$hasHeader) {
+ addHeadColumnsPositions($store);
+ $hasHeader = TRUE;
+ }
- $existingItemIds = array();
- foreach ($storages as $store) {
- $hasHeader = FALSE;
- $hasItems = FALSE;
-
- if ($headCategories != null) {
- foreach ($headCategories as $headCategory) {
- if (stripos($headCategory['name'], $searchValue) !== FALSE) $items = DB::query('SELECT * FROM items WHERE storageid=%d', $store['id']);
- else $items = DB::query('SELECT * FROM items WHERE storageid=%d AND (label LIKE %ss OR comment LIKE %ss OR serialnumber LIKE %ss)', $store['id'], $searchValue, $searchValue, $searchValue);
-
- if ($items != null) {
- if (!$hasHeader) {
- addHeadColumnsPositions($store);
- $hasHeader = TRUE;
- }
-
- foreach($items as $item) if (!in_array($item['id'], $existingItemIds)) {
- addItem($item, $storages);
- $existingItemIds[] = $item['id'];
- }
-
- $hasItems = TRUE;
- $foundData = TRUE;
+ foreach ($items as $item) if (!in_array($item['id'], $existingItemIds)) {
+ $existingItemIds[] = $item['id'];
+ addItem($item, $storages);
}
+
+ $hasItems = TRUE;
+ $foundData = TRUE;
}
}
+ }
- if ($subCategories != null) {
- foreach ($subCategories as $subCategory) {
- if (stripos($subCategory['name'], $searchValue) !== FALSE) $items = DB::query('SELECT * FROM items WHERE storageid=%d AND subcategories LIKE %s', $store['id'], ('%,' . $subCategory['id'] . ',%'));
- else $items = DB::query('SELECT * FROM items WHERE storageid=%d AND subcategories LIKE %s AND (label LIKE %ss OR comment LIKE %ss OR serialnumber LIKE %ss)', $store['id'], ('%,' . $subCategory['id'] . ',%'), $searchValue, $searchValue, $searchValue, ($searchValue . '%'));
+ if ($foundData) echo '
';
+ }
- if ($items != null) {
- if (!$hasHeader) {
- addHeadColumnsPositions($store);
- $hasHeader = TRUE;
- }
+ if (!$foundData) {
+ echo '