In mã vạch trong khoảng ID mã vạch trên phần mềm SlimS

 In mã vạch trong khoảng ID mã vạch trên phần mềm SlimS

Mặc định chức năng in mã vạch trong phần mềm quản lý thư viện SlimS cho phép người dùng in theo nhan đề; tác giả; chủ đề; mã vạch bằng cách tìm kiếm. Tuy nhiên nếu bạn muốn in mã vạch bắt đầu từ ID mã vạch bao nhiêu đến ID mã vạch bao nhiêu thì bạn có thể làm như sau:

- Lưu ý: BlogITCode sẽ hướng dẫn tạo bộ lọc để in mã vạch trong khoảng ID (bắt đầu từ ID mã vạch đến ID mã vạch), mà không phải trong khoảng mã vạch vì có thể mỗi nhan đề sẽ có những kiểu mã hóa cấu trúc mã vạch khác nhau nên dẫn đến kết quả dữ liệu xuất ra không chính xác.

- Như một thói quyen, bạn nên sao lưu dữ liệu trước khi thực hiện;

- File chỉnh sửa liên quan đến chức năng in mã vạch là item_barcode_generator.php (\slims\admin\modules\bibliography\);

* B1: Đầu tiên cần hiển thị ID mã vạch ở bảng hiển thị thông tin tài liệu

+ Tìm đoạn code sau

if ($sysconf['index']['type'] == 'index' || ($sysconf['index']['type'] == 'sphinx' && file_exists(LIB.'sphinx/sphinxapi.php'))) {

  if ($sysconf['index']['type'] == 'sphinx') {

    require LIB.'sphinx/sphinxapi.php';

    require LIB.'biblio_list_sphinx.inc.php';

  } else {

    require LIB.'biblio_list_index.inc.php';

  }

  // table spec

  $table_spec = 'item LEFT JOIN search_biblio AS `index` ON item.biblio_id=`index`.biblio_id';

  $datagrid->setSQLColumn('item.item_code',

    'item.item_id AS \''.__('ID').'\'',

    '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_id AS \''.__('ID').'\'',

    'item.item_code AS \''.__('Item Code').'\'',

    'biblio.title AS \''.__('Title').'\'');

}

$datagrid->setSQLorder('item.last_update DESC');

+ Sửa lại thành:

if ($sysconf['index']['type'] == 'index' || ($sysconf['index']['type'] == 'sphinx' && file_exists(LIB.'sphinx/sphinxapi.php'))) {

  if ($sysconf['index']['type'] == 'sphinx') {

    require LIB.'sphinx/sphinxapi.php';

    require LIB.'biblio_list_sphinx.inc.php';

  } else {

    require LIB.'biblio_list_index.inc.php';

  }

  // table spec

  $table_spec = 'item LEFT JOIN search_biblio AS `index` ON item.biblio_id=`index`.biblio_id';

  $datagrid->setSQLColumn('item.item_code',

    'item.item_id AS \''.__('ID').'\'',

    '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_id AS \''.__('ID').'\'',

    'item.item_code AS \''.__('Item Code').'\'',

    'biblio.title AS \''.__('Title').'\'');

}

$datagrid->setSQLorder('item.item_id DESC');

+ Tìm tiếp đoạn code sau:

$datagrid->column_width = array('10%', '85%');

+ Sửa lại thành:

$datagrid->column_width = array('5%','10%','85%');

In mã vạch trong khoảng ID mã vạch trên phần mềm SlimS


* B2: Tiếp theo tạo form nhập ID mã vạch 

+ Tìm đoạn code sau:

 <form name="search" action="<?php echo MWB; ?>bibliography/item_barcode_generator.php" id="search" method="get" class="form-inline"><?php echo __('Search'); ?> 

    <input type="text" name="keywords" class="form-control col-md-3" />

<input type="submit" id="doSearch" value="<?php echo __('Search'); ?>" class="btn btn-default" />

    </form>

+ Sửa lại thành:

<form name="search" action="<?php echo MWB; ?>bibliography/item_barcode_generator.php" id="search" method="get" class="form-inline"><?php echo __('Search'); ?> 

    <input type="text" name="keywords" class="form-control col-md-3" />

<input type="text" name="startItem" placeholder="ID bắt đầu" class="form-control col-md-2" />

<input type="text" name="untilItem" placeholder="ID kết thúc" class="form-control col-md-2" />

<input type="submit" id="doSearch" value="<?php echo __('Search'); ?>" class="btn btn-default" />

    </form>

* B3: Xử lý câu lện truy vấn theo điều kiện

+ Tìm đoạn code sau:

// is there any search

if (isset($_GET['keywords']) AND $_GET['keywords']) {

  $keywords = utility::filterData('keywords', 'get', true, true, true);

  $searchable_fields = array('title', 'author', 'subject', 'itemcode');

  $search_str = $keywords;

  // 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'].')');

}

+  Sửa lại thành:

if (isset($_GET['keywords']) AND $_GET['keywords']) {

  $keywords = utility::filterData('keywords', 'get', true, true, true);

  $searchable_fields = array('title', 'author', 'subject', 'itemcode');

  $search_str = $keywords;

  // if no qualifier in fields

  if (!preg_match('@[a-z]+\s*=\s*@i', $keywords)) {

    $search_str = '';

    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);

}

// Khoi tao them du lieu truy van

$str_criteria = 'item.item_code IS NOT NULL';

if ((isset($_GET['startItem']) && $_GET['startItem'] != '' )&& (isset($_GET['untilItem']) && $_GET['untilItem'] != '' )) {

        $startItem = $dbs->escape_string($_GET['startItem']);

$untilItem = $dbs->escape_string($_GET['untilItem']);

$str_criteria .= ' AND item.item_id BETWEEN ' . $startItem . ' AND ' . $untilItem;

}

// Ket thuc du lieu truy van

if (isset($criteria)) {

    $str_criteria .= ' AND (' . $criteria['sql_criteria'] . ')';

}

$datagrid->setSQLCriteria($str_criteria);

+ Tìm tiếp đoạn code:

if (isset($_GET['keywords']) AND $_GET['keywords']) {

  $msg = str_replace('{result->num_rows}', $datagrid->num_rows, __('Found <strong>{result->num_rows}</strong> from your keywords'));

  echo '<div class="infoBox">'.$msg.' : "'.htmlspecialchars($_GET['keywords']).'"<div>'.__('Query took').' <b>'.$datagrid->query_time.'</b> '.__('second(s) to complete').'</div></div>';

}

+ Thêm dưới nó đoạn code sau:

if (isset($_GET['startItem']) AND $_GET['startItem'] && isset($_GET['startItem']) AND $_GET['startItem']) {

  $msg = str_replace('{result->num_rows}', $datagrid->num_rows, __('Found <strong>{result->num_rows}</strong> from ID item'));

  echo '<div class="infoBox">'.$msg.' : "'.htmlspecialchars($_GET['startItem']). ' to '. htmlspecialchars($_GET['untilItem']).'"<div>'.__('Query took').' <b>'.$datagrid->query_time.'</b> '.__('second(s) to complete').'</div></div>';

}

- Lưu lại file và xem kết quả;

In mã vạch trong khoảng ID mã vạch trên phần mềm SlimS

- Chúc các bạn thành công;

- Bạn có thể tải về file mẫu theo link chia sẻ bên dưới


Previous Post Next Post