'.__('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((integer)$_POST['itemID']); } // loop array if (isset($_SESSION['barcodes'])) { $print_count = count($_SESSION['barcodes']); } else { $print_count = 0; } // barcode size $size = 2; // create AJAX request echo ''; echo ''; // update print queue count object sleep(2); 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 { utility::jsAlert(__('Selected items added to print queue')); } exit(); } // clean print queue if (isset($_GET['action']) AND $_GET['action'] == 'clear') { // update print queue count object echo ''; utility::jsAlert(__('Print queue cleared!')); unset($_SESSION['barcodes']); exit(); } // barcode pdf download if (isset($_GET['action']) AND $_GET['action'] == 'print') { // check if label session array is available if (!isset($_SESSION['barcodes'])) { utility::jsAlert(__('There is no data to print!')); die(); } if (count($_SESSION['barcodes']) < 1) { utility::jsAlert(__('There is no data to print!')); die(); } // concat all ID together $item_ids = ''; foreach ($_SESSION['barcodes'] as $id) { $item_ids .= '\''.$id.'\','; } // strip the last comma $item_ids = substr_replace($item_ids, '', -1); // send query to database $item_q = $dbs->query('SELECT b.title, i.item_code FROM item AS i LEFT JOIN biblio AS b ON i.biblio_id=b.biblio_id WHERE i.item_code IN('.$item_ids.')'); $item_data_array = array(); while ($item_d = $item_q->fetch_row()) { if ($item_d[0]) { $item_data_array[] = $item_d; } } // include printed settings configuration file require 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, 'barcode'); // chunk barcode array $chunked_barcode_arrays = array_chunk($item_data_array, $sysconf['print']['barcode']['barcode_items_per_row']); // create html ouput $html_str = ''."\n"; $html_str .= 'Item Barcode 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_barcode_arrays as $barcode_rows) { $html_str .= ''."\n"; foreach ($barcode_rows as $barcode) { $html_str .= ''; } $html_str .= ''."\n"; } $html_str .= '
'; $html_str .= '
'; if ($sysconf['print']['barcode']['barcode_include_header_text']) { $html_str .= '
'.($sysconf['print']['barcode']['barcode_header_text']?$sysconf['print']['barcode']['barcode_header_text']:$sysconf['library_name']).'
'; } // document title $html_str .= '
'; if ($sysconf['print']['barcode']['barcode_cut_title'] && strlen($barcode[0]) > $sysconf['print']['barcode']['barcode_cut_title']) { $html_str .= substr($barcode[0], 0, $sysconf['print']['barcode']['barcode_cut_title']).'...'; } else { $html_str .= $barcode[0]; } $html_str .= '
'; $html_str .= ''; $html_str .= '
'; $html_str .= '
'."\n"; $html_str .= ''."\n"; $html_str .= ''."\n"; // unset the session unset($_SESSION['barcodes']); // write to file $print_file_name = 'item_barcode_gen_print_result_'.strtolower(str_replace(' ', '_', $_SESSION['uname'])).'.html'; $file_write = @file_put_contents(UPLOAD.$print_file_name, $html_str); if ($file_write) { // update print queue count object echo ''; // open result in window echo ''; } else { utility::jsAlert('ERROR! Item barcodes failed to generate, possibly because '.SB.FLS.' directory is not writable'); } exit(); } ?> setSQLColumn('item.item_code', 'item.item_code AS \''.__('Item Code').'\'', 'index.title AS \''.__('Title').'\''); } else { require LIB.'biblio_list.inc.php'; // table spec $table_spec = 'item LEFT JOIN biblio ON item.biblio_id=biblio.biblio_id'; $datagrid->setSQLColumn('item.item_code', 'item.item_code AS \''.__('Item Code').'\'', 'biblio.title AS \''.__('Title').'\''); } $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', 'subject', '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?'); $datagrid->column_width = array('10%', '85%'); // set checkbox action URL $datagrid->chbox_form_URL = $_SERVER['PHP_SELF']; // 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 */