sumber: di sini
Secara default SLIMS memberikan fasilitas kartu anggota dengan gambar yang terkesan biasa. Agar tampilan kartu anggota lebih baik, caranya adalah sebagai berikut:
1. Modifikasi file member_card_generator.php (file ini berada di folder \admin\modules\membership\)
2. Edit file tersebut dengan source di bawah ini:
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*//* Member card print */
// main system configuration
require ‘../../../sysconfig.inc.php’;
// start the session
require SENAYAN_BASE_DIR.’admin/default/session.inc.php’;
require SENAYAN_BASE_DIR.’admin/default/session_check.inc.php’;
require SIMBIO_BASE_DIR.’simbio_GUI/table/simbio_table.inc.php’;
require SIMBIO_BASE_DIR.’simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php’;
require SIMBIO_BASE_DIR.’simbio_GUI/paging/simbio_paging.inc.php’;
require SIMBIO_BASE_DIR.’simbio_DB/datagrid/simbio_dbgrid.inc.php’;
require SIMBIO_BASE_DIR.’simbio_DB/simbio_dbop.inc.php’;// privileges checking
$can_read = utility::havePrivilege(‘membership’, ‘r’);if (!$can_read) {
die(‘You dont have enough privileges to view this section’);
}// local settings
$max_print = 10;// clean print queue
if (isset($_GET['action']) AND $_GET['action'] == ‘clear’) {
// update print queue count object
echo ‘’;
utility::jsAlert(__(‘Print queue cleared!’));
unset($_SESSION['card']);
exit();
}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']);
}
// loop array
if (isset($_SESSION['card'])) {
$print_count = count($_SESSION['card']);
} else {
$print_count = 0;
}
// card size
$size = 2;
// create AJAX request
echo ‘’;
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’)); //mfc
utility::jsAlert($msg);
} else {
// update print queue count object
echo ‘’;
utility::jsAlert(__(‘Selected items added to print queue’));
}
exit();
}// card pdf download
if (isset($_GET['action']) AND $_GET['action'] == ‘print’) {
// check if label session array is available
if (!isset($_SESSION['card'])) {
utility::jsAlert(__(‘There is no data to print!’));
die();
}
if (count($_SESSION['card']) < 1) {
utility::jsAlert(__(‘There is no data to print!’));
die();
}
// concat all ID together
$member_ids = ”;
foreach ($_SESSION['card'] as $id) {
$member_ids .= ‘\”.$id.’\’,’;
}
// strip the last comma
$member_ids = substr_replace($member_ids, ”, -1);
// send query to database
$member_q = $dbs->query(‘SELECT m.member_name, m.member_id, m.birth_date, m.member_image, mt.member_type_name FROM member AS m
LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id
WHERE m.member_id IN(‘.$member_ids.’)’);
$member_datas = array();
while ($member_d = $member_q->fetch_assoc()) {
if ($member_d['member_id']) {
$member_datas[] = $member_d;
}
}// include printed settings configuration file
’.”\n”; // loop the chunked arrays to row foreach ($chunked_card_arrays as $card_rows) { $html_str .= ‘’.”\n”; foreach ($card_rows as $card) { $html_str .= ‘’; } $html_str .= ‘’.”\n”; } $html_str .= ‘
include SENAYAN_BASE_DIR.’admin’.DIRECTORY_SEPARATOR.’admin_template’.DIRECTORY_SEPARATOR.’printed_settings.inc.php’;
// check for custom template settings
$custom_settings = SENAYAN_BASE_DIR.’admin’.DIRECTORY_SEPARATOR.$sysconf['admin_template']['dir'].DIRECTORY_SEPARATOR.$sysconf['template']['theme'].DIRECTORY_SEPARATOR.’printed_settings.inc.php’;
if (file_exists($custom_settings)) {
include $custom_settings;
}
// chunk cards array
$chunked_card_arrays = array_chunk($member_datas, $card_items_per_row);
// create html ouput
$html_str = ‘’.”\n”;
$html_str .= ‘Member card 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 .= ‘’;’;
if (trim($card_header_text) != ”) { $html_str .= ‘’; }
// if (trim($card_header_text) != ”) { $html_str .= ‘’.$card_header_text.’’; }
$html_str .= ‘
’;
$html_str .= ‘
’;
$html_str .= ‘’;’;
$html_str .= ‘’;
// $html_str .= ‘’;
$html_str .= ‘
$html_str .= ‘’;’;
$html_str .= ‘’.( $card_include_field_label?__(‘Member ID’).’ : ‘:” ).’’.$card['member_id'].’’;
$html_str .= ‘’.( $card_include_field_label?__(‘Member Name’).’ : ‘:” ).’’.$card['member_name'].’’;
$html_str .= ‘’.( $card_include_field_label?__(‘Membership Type’).’ : ‘:” ).’’.$card['member_type_name'].’’;$html_str .= ‘
’;
// $html_str .= ‘’;
$html_str .= ‘
$html_str .= ‘
$html_str .= ‘
$html_str .= ‘’.”\n”;
$html_str .= ‘’.”\n”;
// unset the session
unset($_SESSION['card']);
// write to file
$print_file_name = ‘member_card_gen_print_result_’.strtolower(str_replace(‘ ‘, ‘_’, $_SESSION['uname'])).’.html’;
$file_write = @file_put_contents(FILES_UPLOAD_DIR.$print_file_name, $html_str);
if ($file_write) {
// update print queue count object
echo ‘’;
// open result in window
echo ‘’;
} else { utility::jsAlert(‘ERROR! Cards failed to generate, possibly because ‘.SENAYAN_BASE_DIR.FILES_DIR.’ directory is not writable’); }
exit();
}?>
/* search form end */
/* ITEM LIST */
// table spec
$table_spec = ‘member AS m
LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id’;
// create datagrid
$datagrid = new simbio_datagrid();
$datagrid->setSQLColumn(‘m.member_id’,
‘m.member_id AS \”.__(‘Member ID’).’\”,
‘m.member_name AS \”.__(‘Member Name’).’\”,
‘mt.member_type_name AS \”.__(‘Membership Type’).’\”);
$datagrid->setSQLorder(‘m.last_update DESC’);
// 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 .= ” (m.member_id LIKE ‘%$word%’ OR m.member_name LIKE ‘%$word%’”;
}
// remove the last AND
$concat_sql = substr_replace($concat_sql, ”, -3);
$concat_sql .= ‘) ‘;
$datagrid->setSQLCriteria($concat_sql);
} else {
$datagrid->setSQLCriteria(“m.member_id LIKE ‘%$keyword%’ OR m.member_name LIKE ‘%$keyword%’”);
}
}
// 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%’, ’70%’, ’15%’);
// 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']) {
echo ‘’.__(‘Found’).’ ‘.$datagrid->num_rows.’ ‘.__(‘from your search with keyword’).’: “‘.$_GET['keywords'].’”’; //mfc
}
echo $datagrid_result;
/* main content end */?>
3. Buat desain kartu anggota berukuran 468×237 px menggunakan corel draw, adobe photoshop atau yang lainnya, kemudian save dengan nama card.png (ingat, format file harus *.png untuk menyesuaikan script di atas).
4. Simpan file card.png tersebut di folder files.
5. Semoga berhasil.
Posting Komentar