'.__('You are not authorized to view this section').''); } /* search form */ ?>
'.$array_data[1].' ('.$array_data[2].')'; if ($can_read AND $can_write) { $_output .= ' '; } $_output .= ' '; $_output .= ' '; $count++; return $_output; } // create datagrid $datagrid = new simbio_datagrid(); $datagrid->setSQLColumn('b.biblio_id', 'b.title AS \''.__('Serial Title').'\'', 'fr.frequency AS \'Frequency\''); $datagrid->invisible_fields = array(0, 2); $datagrid->modifyColumnContent(1, 'callback{subscriptionDetail}'); $datagrid->setSQLorder('b.last_update DESC'); // table alias and field relation $tables['bsub'] = array('title', 'isbn_issn'); $tables['mt'] = array('topic'); if (isset($_GET['field']) AND !empty($_GET['field'])) { foreach ($tables as $table_alias=>$fields) { if (!in_array($_GET['field'], $fields)) { // remove unneeded array unset($tables[$table_alias]); } } // check if fields array is empty to prevent SQL error if (!$tables) { $tables['bsub'] = array('title', 'isbn_issn'); $tables['mt'] = array('topic'); } } // set default criteria $criteria = 'bsub.frequency_id>0'; // is there any search if (isset($_GET['keywords']) AND $_GET['keywords']) { $keyword = $dbs->escape_string(trim($_GET['keywords'])); $words = explode(' ', $keyword); if (count($words) > 1) { $concat_sql = ' ('; foreach ($words as $word) { $concat_sql .= '('; foreach ($tables as $table_alias => $fields) { foreach ($fields as $field) { $concat_sql .= $table_alias.'.'.$field." LIKE '%$word%' OR "; } } // remove the last OR $concat_sql = substr_replace($concat_sql, '', -4); $concat_sql .= ') AND'; } // remove the last AND $concat_sql = substr_replace($concat_sql, '', -3); $concat_sql .= ') '; $criteria = $concat_sql; } else { $concat_sql = ''; foreach ($tables as $table_alias => $fields) { foreach ($fields as $field) { $concat_sql .= $table_alias.'.'.$field." LIKE '%$keyword%' OR "; } } // remove the last OR $concat_sql = substr_replace($concat_sql, '', -4); $criteria = $concat_sql; } } // subquery/view string $subquery_str = '(SELECT DISTINCT bsub.biblio_id, bsub.title, bsub.frequency_id, bsub.last_update FROM biblio AS bsub LEFT JOIN biblio_topic AS bt ON bsub.biblio_id = bt.biblio_id LEFT JOIN mst_topic AS mt ON bt.topic_id = mt.topic_id WHERE '.$criteria.')'; // table spec $table_spec = $subquery_str.' AS b LEFT JOIN mst_frequency AS fr ON b.frequency_id=fr.frequency_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;"'; // put the result into variables $datagrid_result = $datagrid->createDataGrid($dbs, $table_spec, 20, false); 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 '