"") {
return $first . " " . $last;
} else {
return $last;
}
}
}
// privileges checking
$can_read = utility::havePrivilege('bibliography', 'r');
if (!$can_read) {
die('
'.__('You are not authorized to view this section').'
');
}
$max_print = 50;
/* RECORD OPERATION */
if (isset($_POST['itemID']) AND !empty($_POST['itemID']) AND isset($_POST['itemAction'])) {
if (!$can_read) {
die();
}
if (!is_array($_POST['itemID'])) {
// make an array
$_POST['itemID'] = array($_POST['itemID']);
}
/* LABEL SESSION ADDING PROCESS */
$print_count = 0;
if (isset($_SESSION['cards']['item'])) {
$print_count += count($_SESSION['cards']['item']);
}
// loop array
foreach ($_POST['itemID'] as $itemID) {
if ($print_count == $max_print) {
$limit_reach = true;
break;
}
$itemID = (integer)$itemID;
if (isset($_SESSION['cards'][$itemID])) {
continue;
}
$_SESSION['cards']['item'][$itemID] = $itemID;
$print_count++;
}
if (isset($limit_reach)) {
$msg = str_replace('{max_print}', $max_print, __('Selected items NOT ADDED to print queue. Only {max_print} can be printed at once')); //mfc
utility::jsAlert($msg);
} else {
// update print queue count object
echo '';
utility::jsAlert(__('Selected items added to print queue'));
}
exit();
}
// clean print queue
if (isset($_GET['action']) AND $_GET['action'] == 'clear') {
utility::jsAlert(__('Print queue cleared!'));
echo '';
unset($_SESSION['cards']);
exit();
}
// on print action
if (isset($_GET['action']) AND $_GET['action'] == 'print') {
// check if label session array is available
if (!isset($_SESSION['cards']['item']) && !isset($_SESSION['cards']['biblio'])) {
utility::jsAlert(__('There is no data to print!'));
die();
}
// concat item ID
$item_ids = '';
if (isset($_SESSION['cards']['item'])) {
foreach ($_SESSION['cards']['item'] as $id) {
$item_ids .= $id.',';
}
}
// strip the last comma
$item_ids = substr_replace($item_ids, '', -1);
$criteria = "b.biblio_id IN($item_ids)";
$biblio_q = $dbs->query('SELECT b.biblio_id, b.title as title, b.call_number, b.sor,
CONCAT(\'[\', g.gmd_name, \'].\') as gmd,
CONCAT(b.edition, \'.\') as edition, b.isbn_issn,
CONCAT(pp.place_name, \' : \', p.publisher_name, \', \', b.publish_year, \'.\') as publisher,
CONCAT(b.collation, \'.\') as physic,
CONCAT(b.series_title, \'.\') as series
FROM biblio as b
LEFT JOIN mst_gmd as g on b.gmd_id = g.gmd_id
LEFT JOIN mst_publisher as p on b.publisher_id = p.publisher_id
LEFT JOIN mst_place as pp on b.publish_place_id = pp.place_id
WHERE '.$criteria);
$katalog = "";
$item = 0;
while ($biblio_d = $biblio_q->fetch_array()) {
$tajuk[] = " ";
$tajuk[] = $biblio_d['title'];
// author
$author_q = $dbs->query('SELECT a.author_name
FROM biblio_author as ba
LEFT JOIN mst_author as a on ba.author_id = a.author_id
WHERE ba.biblio_id = '. $biblio_d['biblio_id']);
$biblio_d['author'] = "";
$i = 0;
while ($author_d = $author_q->fetch_row()) {
$biblio_d['author'] .= reverseAuthor($author_d[0]) . ', ';
$i += 1;
if ($i == 1) { $mainauthor = $author_d[0]; }
if ($i > 1) { $tajuk[] = $author_d[0]; }
if ($i >= 3) { break; }
}
// strip the last comma
if ($biblio_d['sor'] <> "") {
$biblio_d['author'] = $biblio_d['sor'];
} else {
$biblio_d['author'] = substr_replace($biblio_d['author'], '', -2);
}
// subject
$subject_q = $dbs->query('SELECT t.topic
FROM biblio_topic as bt
LEFT JOIN mst_topic as t on bt.topic_id = t.topic_id
WHERE bt.biblio_id = '. $biblio_d['biblio_id']);
$biblio_d['subject'] = "";
$i = 0;
while ($subject_d = $subject_q->fetch_row()) {
$biblio_d['subject'] .= $subject_d[0]. '; ';
$tajuk[] = $subject_d[0];
$i += 1;
if ($i >= 3) { break; }
}
$biblio_d['subject'] = substr_replace($biblio_d['subject'], '', -2);
// explode label data by space
$sliced_label = explode(' ', $biblio_d['call_number'], 5);
if (count($sliced_label) < 3) {
for ($i=count($sliced_label); $i<3; ++$i) {
$sliced_label[$i]= " ";
}
}
// number of copy
$number_q = $dbs->query('SELECT count(item_id)
FROM item
WHERE biblio_id = '. $biblio_d['biblio_id']. ' GROUP BY biblio_id');
$biblio_d['copies'] = " ";
while ($number_d = $number_q->fetch_row()) {
$biblio_d['copies'] = $number_d[0] ." " . __('Copies');
}
for ($i=0; $i < count($tajuk); $i++)
{
/* check for break page */
if($item % 3 == 0 AND $item != 0)
{
$set_break = ' style="page-break-before:always;" ';
} else {
$set_break = '';
}
$katalog .= "
| ";
if (strlen($tajuk[$i]) > 60) {
$katalog .= substr($tajuk[$i], 0,60)."...";
} else {
$katalog .= $tajuk[$i];
}
$katalog .=" |
".$sliced_label[0]." |
".$sliced_label[1]." | ".$mainauthor." |
".$sliced_label[2]." | ".$biblio_d['title']." / ".$biblio_d['author'].". -- ".$biblio_d['edition']." |
| ".$biblio_d['publisher']." |
| |
| ".$biblio_d['physic']."-- ".$biblio_d['series'].". |
| ISBN ".$biblio_d['isbn_issn'].". |
| |
| ".$biblio_d['subject'].". |
| |
| ".$biblio_d['copies']." | |
|
\n";
$item++;
}
unset($tajuk);
unset($sliced_label);
}
/*
// include printed settings configuration file
include SB.'admin'.DS.'admin_template'.DS.'printed_settings.inc.php';
// check for custom template settings
$custom_settings = SB.'admin'.DS.$sysconf['admin_template']['dir'].DS.$sysconf['template']['theme'].DS.'printed_settings.inc.php';
if (file_exists($custom_settings)) {
include $custom_settings;
}
*/
// create html ouput of images
$html_str = ''."\n";
$html_str .= 'Document Label Print Result'."\n";
$html_str .= '';
$html_str .= '';
$html_str .= ''."\n";
$html_str .= ''."\n";
$html_str .= ''."\n";
$html_str .= 'Print Again'."\n";
$html_str .= ''."\n";
$html_str .= $katalog;
$html_str .= '
'."\n";
$html_str .= ''."\n";
$html_str .= ''."\n";
// unset the session
unset($_SESSION['cards']);
// write to file
$print_file_name = 'catalog_print_result_'.strtolower(str_replace(' ', '_', $_SESSION['uname'])).'.html';
$file_write = @file_put_contents(UPLOAD.$print_file_name, $html_str);
if ($file_write) {
echo '';
// open result in new window
echo '';
} else { utility::jsAlert('ERROR! Catalog card failed to generate, possibly because '.SB.FLS.' directory is not writable'); }
exit();
}
/* search form */
?>
setSQLColumn('index.biblio_id, index.title as '.__('Title').', index.author as '.__('Author'));
}
// SELECT IF(item.item_id IS NOT NULL, item.item_id, CONCAT('b', biblio.biblio_id)), biblio.title AS Title, IF(item.call_number<>'', item.call_number, biblio.call_number) AS 'Call Number'
// FROM search_biblio AS `index` LEFT JOIN `item` ON `index`.biblio_id=`item`.biblio_id
} else {
require LIB.'biblio_list.inc.php';
// table spec
$table_spec = 'biblio LEFT JOIN item as i ON biblio.biblio_id=i.biblio_id';
if ($can_read) {
$datagrid->setSQLColumn('biblio.biblio_id, biblio.title, COUNT(i.item_id) as '.__('Item'));
}
// SELECT IF(item.item_id IS NOT NULL, item.item_id, CONCAT('b', biblio.biblio_id)), biblio.title AS 'Title', IF(item.call_number<>'', item.call_number, biblio.call_number) AS 'Call Number'
// FROM biblio LEFT JOIN item ON biblio.biblio_id=item.biblio_id
}
$datagrid->setSQLorder('biblio.last_update DESC');
// is there any search
if (isset($_GET['keywords']) AND $_GET['keywords']) {
$keywords = $dbs->escape_string(trim($_GET['keywords']));
$searchable_fields = array('title', 'class', 'callnumber');
$search_str = '';
// if no qualifier in fields
if (!preg_match('@[a-z]+\s*=\s*@i', $keywords)) {
foreach ($searchable_fields as $search_field) {
$search_str .= $search_field.'='.$keywords.' OR ';
}
} else {
$search_str = $keywords;
}
$biblio_list = new biblio_list($dbs, 20);
$criteria = $biblio_list->setSQLcriteria($search_str);
}
if (isset($criteria)) {
$datagrid->setSQLcriteria('('.$criteria['sql_criteria'].')');
}
$datagrid->sql_group_by = "biblio.biblio_id";
// set table and table header attributes
$datagrid->table_attr = 'align="center" id="dataList" cellpadding="5" cellspacing="0"';
$datagrid->table_header_attr = 'class="dataListHeader" style="font-weight: bold;"';
// edit and checkbox property
$datagrid->edit_property = false;
$datagrid->chbox_property = array('itemID', __('Add'));
$datagrid->chbox_action_button = __('Add To Print Queue');
$datagrid->chbox_confirm_msg = __('Add to print queue?');
// set delete proccess URL
$datagrid->chbox_form_URL = $_SERVER['PHP_SELF'];
$datagrid->column_width = array(0 => '75%', 1 => '20%');
// put the result into variables
$datagrid_result = $datagrid->createDataGrid($dbs, $table_spec, 20, $can_read);
if (isset($_GET['keywords']) AND $_GET['keywords']) {
$msg = str_replace('{result->num_rows}', $datagrid->num_rows, __('Found {result->num_rows} from your keywords')); //mfc
echo ''.$msg.' : "'.$_GET['keywords'].'"
'.__('Query took').' '.$datagrid->query_time.' '.__('second(s) to complete').'
'; //mfc
}
echo $datagrid_result;
/* main content end */