$sql_op = new simbio_dbop($dbs); // check if the item still on loan $loan_q = $dbs->query('SELECT DISTINCT l.item_code, b.title FROM loan AS l LEFT JOIN item AS i ON l.item_code=i.item_code LEFT JOIN biblio AS b ON i.biblio_id=b.biblio_id WHERE i.item_id=' . $id . ' AND l.is_lent=1 AND l.is_return=0'); $loan_d = $loan_q->fetch_row(); // send an alert if the member cant be deleted if ($loan_q->num_rows > 0) { echo '<script type="text/javascript">'; echo 'alert(\'' . __('Item data can not be deleted because still on hold by members') . '\');'; echo 'self.location.href = \'iframe_item_list.php?biblioID=' . $bid . '\';'; echo '</script>'; } else { $collection = utility::collection_load($dbs, $bid); $item = utility::item_load_by_id($dbs, $id); if ($sql_op->delete('item', 'item_id=' . $id)) { utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'] . ' DELETE item data (' . $item['item_code'] . ') with title (' . $collection['title'] . ')'); echo '<script type="text/javascript">'; echo 'alert(\'' . __('Item succesfully removed!') . '\');'; echo 'self.location.href = \'iframe_item_list.php?biblioID=' . $bid . '\';'; echo '</script>'; } else { echo '<script type="text/javascript">'; echo 'alert(\'' . __('Item FAILED to removed!') . '\');'; echo 'self.location.href = \'iframe_item_list.php?biblioID=' . $bid . '\';'; echo '</script>'; } } } // if biblio ID is set