'.__('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['labels']['biblio'])) { $print_count_biblio = count($_SESSION['labels']['biblio']); } if (isset($_SESSION['labels']['item'])) { $print_count_item = count($_SESSION['labels']['item']); } // loop array foreach ($_POST['itemID'] as $itemID) { if ($print_count == $max_print) { $limit_reach = true; break; } if (stripos($itemID, 'b', 0) !== false) { // Biblio ID $biblioID = str_ireplace('b', '', $itemID); if (isset($_SESSION['labels']['biblio'][$biblioID])) { continue; } $_SESSION['labels']['biblio'][$biblioID] = $biblioID; $print_count_biblio++; } else { // Item ID $itemID = (integer)$itemID; if (isset($_SESSION['labels']['item'][$itemID])) { continue; } $_SESSION['labels']['item'][$itemID] = $itemID; $print_count_item++; } } $print_count = $print_count_item + $print_count_biblio; echo ''; 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')); utility::jsAlert($msg); } else { // update print queue count object 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['labels']); exit(); } // on print action if (isset($_GET['action']) AND $_GET['action'] == 'print') { // check if label session array is available if (!isset($_SESSION['labels']['item']) && !isset($_SESSION['labels']['biblio'])) { utility::jsAlert(__('There is no data to print!')); die(); } // concat item ID $item_ids = ''; if (isset($_SESSION['labels']['item'])) { foreach ($_SESSION['labels']['item'] as $id) { $item_ids .= $id.','; } } // concat biblio ID $biblio_ids = ''; if (isset($_SESSION['labels']['biblio'])) { foreach ($_SESSION['labels']['biblio'] as $id) { $biblio_ids .= $id.','; } } // strip the last comma $item_ids = substr_replace($item_ids, '', -1); $biblio_ids = substr_replace($biblio_ids, '', -1); // SQL criteria if ($item_ids) { $criteria = "i.item_id IN($item_ids)"; } if ($biblio_ids) { $criteria = "b.biblio_id IN($biblio_ids)"; } if ($item_ids && $biblio_ids) { $criteria = "i.item_id IN($item_ids) OR b.biblio_id IN($biblio_ids)"; } // send query to database $biblio_q = $dbs->query('SELECT IF(i.call_number<>\'\', i.call_number, b.call_number) FROM biblio AS b LEFT JOIN item AS i ON b.biblio_id=i.biblio_id WHERE '.$criteria); // echo 'SELECT IF(i.call_number!=\'\', i.call_number, b.call_number) FROM biblio AS b LEFT JOIN item AS i ON b.biblio_id=i.biblio_id WHERE '.$criteria; $label_data_array = array(); while ($biblio_d = $biblio_q->fetch_row()) { if ($biblio_d[0]) { $label_data_array[] = $biblio_d[0]; } } // 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; } // load print settings from database to override value from printed_settings file loadPrintSettings($dbs, 'label'); // chunk label array $chunked_label_arrays = array_chunk($label_data_array, $sysconf['print']['label']['items_per_row']); // 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"; // loop the chunked arrays to row foreach ($chunked_label_arrays as $label_data) { $html_str .= ''."\n"; foreach ($label_data as $label) { $html_str .= ''; } $html_str .= ''."\n"; } $html_str .= '
'; $html_str .= '
'; if ($sysconf['print']['label']['include_header_text']) { $html_str .= '
'.($sysconf['print']['label']['header_text']?$sysconf['print']['label']['header_text']:$sysconf['library_name']).'
'; } // explode label data by space $sliced_label = explode(' ', $label, 5); foreach ($sliced_label as $slice_label_item) { $html_str .= $slice_label_item.'
'; } $html_str .= '
'; $html_str .= '
'."\n"; $html_str .= ''."\n"; $html_str .= ''."\n"; // unset the session unset($_SESSION['labels']); // write to file $print_file_name = 'label_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! Label failed to generate, possibly because '.SB.FLS.' directory is not writable'); } exit(); } /* search form */ ?> setSQLColumn('IF(item.item_id IS NOT NULL, item.item_id, CONCAT(\'b\', index.biblio_id))', 'index.title AS `'.__('Title').'`', 'IF(item.call_number<>\'\', item.call_number, index.call_number) AS `'.__('Call Number').'`'); } } else { require LIB.'biblio_list.inc.php'; // table spec $table_spec = 'biblio LEFT JOIN item ON biblio.biblio_id=item.biblio_id'; if ($can_read) { $datagrid->setSQLColumn('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').'`'); } } $datagrid->setSQLorder('item.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', 'author', 'class', 'callnumber', 'itemcode'); $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'].')'); } // 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')); echo '
'.$msg.' : "'.$_GET['keywords'].'"
'.__('Query took').' '.$datagrid->query_time.' '.__('second(s) to complete').'
'; } echo $datagrid_result; /* main content end */