'.__('You don\'t have enough privileges to access this area!').''); } /* collection statistic */ $table = new simbio_table(); $table->table_attr = 'align="center" class="border" cellpadding="5" cellspacing="0"'; // total number of titles $stat_query = $dbs->query('SELECT COUNT(biblio_id) FROM biblio'); $stat_data = $stat_query->fetch_row(); $collection_stat[__('Total Titles')] = $stat_data[0].' (including titles that still don\'t have items yet)'; // total number of titles $stat_query = $dbs->query('SELECT DISTINCT biblio.biblio_id FROM biblio INNER JOIN item ON biblio.biblio_id = item.biblio_id'); $stat_data = $stat_query->num_rows; $collection_stat[__('Total Titles with items')] = $stat_data.' (only titles that have items)'; // total number of items $stat_query = $dbs->query('SELECT item.item_code FROM item,biblio WHERE item.biblio_id=biblio.biblio_id'); $stat_data = $stat_query->num_rows; $collection_stat[__('Total Items/Copies')] = $stat_data; // total number of checkout items $stat_query = $dbs->query('SELECT COUNT(item_id) FROM item AS i LEFT JOIN loan AS l ON i.item_code=l.item_code WHERE is_lent=1 AND is_return=0'); $stat_data = $stat_query->fetch_row(); $collection_stat[__('Total Checkout Items')] = $stat_data[0]; // total number of items in library $collection_stat[__('Total Items In Library')] = $collection_stat[__('Total Items/Copies')]-$collection_stat[__('Total Checkout Items')]; // total titles by GMD/medium $stat_query = $dbs->query('SELECT gmd_name, COUNT(biblio_id) AS total_titles FROM `biblio` AS b INNER JOIN mst_gmd AS gmd ON b.gmd_id = gmd.gmd_id GROUP BY b.gmd_id HAVING total_titles>0 ORDER BY COUNT(biblio_id) DESC'); $stat_data = ''; while ($data = $stat_query->fetch_row()) { $stat_data .= ''.$data[0].' : '.$data[1]; $stat_data .= ', '; } $collection_stat[__('Total Titles By Medium/GMD')] = $stat_data; // total items by Collection Type $stat_query = $dbs->query('SELECT coll_type_name, COUNT(item_id) AS total_items FROM `item` AS i INNER JOIN mst_coll_type AS ct ON i.coll_type_id = ct.coll_type_id GROUP BY i.coll_type_id HAVING total_items >0 ORDER BY COUNT(item_id) DESC'); $stat_data = ''; while ($data = $stat_query->fetch_row()) { $stat_data .= ''.$data[0].' : '.$data[1]; $stat_data .= ', '; } $collection_stat[__('Total Items By Collection Type')] = $stat_data; // popular titles $stat_query = $dbs->query('SELECT b.title,l.item_code,COUNT(l.loan_id) AS total_loans 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 GROUP BY b.biblio_id ORDER BY COUNT(l.loan_id) DESC LIMIT 10'); $stat_data = ''; $collection_stat[__('10 Most Popular Titles')] = $stat_data; // table header $table->setHeader(array(__('Collection Statistic Summary'))); $table->table_header_attr = 'class="dataListHeader"'; $table->setCellAttr(0, 0, 'colspan="3"'); // initial row count $row = 1; foreach ($collection_stat as $headings=>$stat_data) { $table->appendTableRow(array($headings, ':', $stat_data)); // set cell attribute $table->setCellAttr($row, 0, 'class="alterCell" valign="top" style="width: 170px;"'); $table->setCellAttr($row, 1, 'class="alterCell" valign="top" style="width: 1%;"'); $table->setCellAttr($row, 2, 'class="alterCell2" valign="top" style="width: auto;"'); // add row count $row++; } // if we are in print mode if (isset($_GET['print'])) { // html strings $html_str = ''; $html_str .= ''.$sysconf['library_name'].' Membership General Statistic Report'; $html_str .= ''."\n"; $html_str .= ''; $html_str .= ''."\n"; $html_str .= '

'.$sysconf['library_name'].' - '.__('Collection Statistic Report').'

'; $html_str .= '
'; $html_str .= $table->printTable(); $html_str .= ''."\n"; $html_str .= ''; // write to file $file_write = @file_put_contents(REPBS.'biblio_stat_print_result.html', $html_str); if ($file_write) { // open result in new window echo ''; } else { utility::jsAlert('ERROR! Loan statistic report failed to generate, possibly because '.REPBS.' directory is not writable'); } exit(); } ?> printTable(); /* collection statistic end */