pesan error pada beranda admin slims
index.php:207 GET /index.php?p=api/biblio/total/all 500 (Internal Server Error)
getTotal @ index.php:207
(anonymous) @ index.php:212
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
index.php:207 GET /index.php?p=api/item/total/all 500 (Internal Server Error)
getTotal @ index.php:207
(anonymous) @ index.php:213
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
index.php:207 GET /index.php?p=api/item/total/lent 500 (Internal Server Error)
getTotal @ index.php:207
(anonymous) @ index.php:214
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
index.php:207 GET /index.php?p=api/item/total/available 500 (Internal Server Error)
getTotal @ index.php:207
(anonymous) @ index.php:215
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
index.php:218 GET /index.php?p=api/loan/summary 500 (Internal Server Error)
(anonymous) @ index.php:218
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
index.php:279 GET /index.php?p=api/loan/getdate/2025-11-04 500 (Internal Server Error)
(anonymous) @ index.php:279
j @ jquery.js:2
fireWith @ jquery.js:2
ready @ jquery.js:2
I @ jquery.js:2
VM2082:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
VM2083:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
VM2084:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
VM2085:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
VM2086:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
VM2087:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Solusinnya yaitu membuat kode baru dengan metode query database, ini akan membuat sedikit lama jika database anda besar.
kode berada di /admin/default/home.php
<?php
/**
*
* Copyright (C) 2007,2008 Arie Nugraha (dicarve@yahoo.com)
*
* 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
*
* some patches by hendro
*/
use SLiMS\DB;
// key to authenticate
if (!defined('INDEX_AUTH')) {
define('INDEX_AUTH', '1');
}
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
include_once '../../sysconfig.inc.php';
}
?>
<div class="menuBox adminHome">
<div class="menuBoxInner">
<div class="per_title">
<h2><?php echo __('Library Administration'); ?></h2>
</div>
</div>
</div>
<div id="backupProccess" style="display: none">
<div class="alert alert-info">
<strong><?= __('Database backup process is running, please wait') ?></strong>
</div>
</div>
<div class="contentDesc">
<div class="container-fluid">
<div id="alert-new-version" class="alert alert-info border-0 mt-3 hidden">
<strong>News!</strong> New version of SLiMS (<code id="new_version"></code>) available to <a class="notAJAX"
target="_blank"
href="https://github.com/slims/slims9_bulian/releases/latest">download</a>.
</div>
<?php
// generate warning messages
$warnings = array();
// check GD extension
if (!extension_loaded('gd')) {
$warnings[] = __('<strong>PHP GD</strong> extension is not installed. Please install it or application won\'t be able to create image thumbnail and barcode.');
} else {
// check GD Freetype
if (!function_exists('imagettftext')) {
$warnings[] = __('<strong>Freetype</strong> support is not enabled in PHP GD extension. Rebuild PHP GD extension with Freetype support or application won\'t be able to create barcode.');
}
}
// check for overdue
$overdue_q = $dbs->query('SELECT COUNT(loan_id) FROM loan AS l WHERE (l.is_lent=1 AND l.is_return=0 AND TO_DAYS(due_date) < TO_DAYS(\'' . date('Y-m-d') . '\')) GROUP BY member_id');
$num_overdue = $overdue_q->num_rows;
if ($num_overdue > 0) {
$warnings[] = str_replace('{num_overdue}', $num_overdue, __('There are currently <strong>{num_overdue}</strong> library members having overdue. Please check at <b>Circulation</b> module at <b>Overdues</b> section for more detail')); //mfc
$overdue_q->free_result();
}
// check if images dir is writable or not
if (!is_writable(IMGBS) OR !is_writable(IMGBS . 'barcodes') OR !is_writable(IMGBS . 'persons') OR !is_writable(IMGBS . 'docs')) {
$warnings[] = __('<strong>Images</strong> directory and directories under it is not writable. Make sure it is writable by changing its permission or you won\'t be able to upload any images and create barcodes');
}
// check if file repository dir is writable or not
if (!is_writable(REPOBS)) {
$warnings[] = __('<strong>Repository</strong> directory is not writable. Make sure it is writable (and all directories under it) by changing its permission or you won\'t be able to upload any bibliographic attachments.');
}
// check if file upload dir is writable or not
if (!is_writable(UPLOAD)) {
$warnings[] = __('<strong>File upload</strong> directory is not writable. Make sure it is writable (and all directories under it) by changing its permission or you won\'t be able to upload any file, create report files and create database backups.');
}
// check mysqldump
//if (!file_exists($sysconf['mysqldump'])) {
// $warnings[] = __('The PATH for <strong>mysqldump</strong> program is not right! Please check configuration file or you won\'t be able to do any database backups.');
//}
// check installer directory
if (is_dir('../install/')) {
$warnings[] = __('Installer folder is still exist inside your server. Please remove it or rename to another name for security reason.');
}
// check need to be repaired mysql database
$query_of_tables = $dbs->query('SHOW TABLES');
$num_of_tables = $query_of_tables->num_rows;
$prevtable = '';
$repair = '';
$is_repaired = false;
if ($_SESSION['uid'] === '1') {
$warnings[] = __('<strong><i>You are logged in as Super User. With great power comes great responsibility.</i></strong>');
if (isset ($_POST['do_repair'])) {
if ($_POST['do_repair'] == 1) {
while ($row = $query_of_tables->fetch_row()) {
$sql_of_repair = 'REPAIR TABLE ' . $row[0];
$query_of_repair = $dbs->query($sql_of_repair);
}
}
}
while ($row = $query_of_tables->fetch_row()) {
$query_of_check = $dbs->query('CHECK TABLE `' . $row[0] . '`');
if ($query_of_check) {
while ($rowcheck = $query_of_check->fetch_assoc()) {
if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) {
if ($row[0] != $prevtable) {
$repair .= '<li>' . __('Table') . ' ' . $row[0] . ' ' . __('might need to be repaired.') . '</li>';
}
$prevtable = $row[0];
$is_repaired = true;
}
}
}
}
if (($is_repaired) && !isset($_POST['do_repair'])) {
echo '<div class="message">';
echo '<ul>';
echo $repair;
echo '</ul>';
echo '</div>';
echo ' <form method="POST" style="margin:0 10px;">
<input type="hidden" name="do_repair" value="1">
<input type="submit" value="' . __('Click Here To Repair The Tables') . '" class="button btn btn-block btn-default">
</form>';
}
}
if (utility::havePrivilege('system', 'r') && utility::havePrivilege('system', 'w'))
{
// info
$backupConfigStatus = config('database_backup.reminder') || config('database_backup.auto');
$backupIsNoAuto = config('database_backup.reminder') && !config('database_backup.auto');
$alreadyBackup = DB::hasBackup(by: DB::BACKUP_BASED_ON_DAY);
if ($alreadyBackup === false && $backupConfigStatus)
$_SESSION['token'] = utility::createRandomString(32);
if ($alreadyBackup === false && $is_repaired === false && $backupIsNoAuto === true) {
echo '<div class="alert alert-info border-0 mt-3">';
echo '<span>' . __('It looks like today you haven\'t backup your database.') .
'. <a href="'.MWB.'system/backup_proc.php" id="backupproc" class="notAJAX btn btn-primary">' . __('Backup Now') . '</a>' .
'</span>';
echo '</div>';
}
}
// if there any warnings
if ($warnings) {
echo '<div class="alert alert-warning border-0 mt-3">';
foreach ($warnings as $warning_msg) {
echo '<div>' . $warning_msg . '</div>';
}
echo '</div>';
}
// admin page content
if ($sysconf['admin_home']['mode'] == 'default') {
require LIB . 'content.inc.php';
$content = new content();
$content_data = $content->get($dbs, 'adminhome');
if ($content_data) {
echo '<div class="contentDesc">' . $content_data['Content'] . '</div>';
unset($content_data);
}
} else {
$start_date = date('Y-m-d');
// Query langsung untuk statistik
// Total koleksi (biblio)
$biblio_total_query = $dbs->query('SELECT COUNT(biblio_id) FROM biblio');
$biblio_total_all = $biblio_total_query->fetch_row()[0]??0;
// Total item
$item_total_query = $dbs->query('SELECT COUNT(item_id) FROM item');
$item_total_all = $item_total_query->fetch_row()[0]??0;
// Total item yang dipinjam
$item_lent_query = $dbs->query('SELECT COUNT(item_code) FROM loan WHERE is_lent=1 AND is_return=0');
$item_total_lent = $item_lent_query->fetch_row()[0]??0;
// Total item tersedia
$item_total_available = $item_total_all - $item_total_lent;
// Statistik peminjaman untuk hari ini
$loan_summary_query = $dbs->query("
SELECT
COUNT(*) as total,
SUM(CASE WHEN is_lent=1 AND is_return=0 THEN 1 ELSE 0 END) as new_loans,
SUM(CASE WHEN is_return=1 THEN 1 ELSE 0 END) as returns,
SUM(CASE WHEN renewed>0 THEN 1 ELSE 0 END) as extends,
SUM(CASE WHEN is_lent=1 AND is_return=0 AND TO_DAYS(due_date) < TO_DAYS('" . date('Y-m-d') . "') THEN 1 ELSE 0 END) as overdue
FROM loan
WHERE DATE(loan_date) = '" . date('Y-m-d') . "'
");
$loan_summary = $loan_summary_query->fetch_assoc();
// Data untuk chart (7 hari terakhir)
$chart_labels = array();
$loan_data = array();
$return_data = array();
$extend_data = array();
for ($i = 6; $i >= 0; $i--) {
$date = date('Y-m-d', strtotime("-$i days"));
$chart_labels[] = date('d M', strtotime($date));
// Loan data - peminjaman baru pada tanggal tersebut
$loan_day_query = $dbs->query("
SELECT COUNT(*) as count FROM loan
WHERE DATE(loan_date) = '$date' AND is_lent=1
");
$loan_day = $loan_day_query->fetch_assoc();
$loan_data[] = $loan_day['count']??0;
// Return data - pengembalian pada tanggal tersebut
$return_day_query = $dbs->query("
SELECT COUNT(*) as count FROM loan
WHERE DATE(return_date) = '$date' AND is_return=1
");
$return_day = $return_day_query->fetch_assoc();
$return_data[] = $return_day['count']??0;
// Extend data - perpanjangan (dilihat dari renewed > 0 dan loan_date pada tanggal tersebut)
$extend_day_query = $dbs->query("
SELECT COUNT(*) as count FROM loan
WHERE DATE(loan_date) = '$date' AND renewed > 0
");
$extend_day = $extend_day_query->fetch_assoc();
$extend_data[] = $extend_day['count']??0;
}
?>
<div class="row">
<div class="col-xs-6 col-md-3 col-lg-3">
<div class="card border-0">
<div class="card-body">
<div class="s-widget-icon"><i class="fa fa-bookmark"></i></div>
<div class="s-widget-value biblio_total_all"><?php echo number_format($biblio_total_all, 0, ',', '.'); ?></div>
<div class="s-widget-title"><?php echo __('Total of Collections') ?></div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3 col-lg-3">
<div class="card border-0">
<div class="card-body">
<div class="s-widget-icon"><i class="fa fa-barcode"></i></div>
<div class="s-widget-value item_total_all"><?php echo number_format($item_total_all, 0, ',', '.'); ?></div>
<div class="s-widget-title"><?php echo __('Total of Items') ?></div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3 col-lg-3">
<div class="card border-0">
<div class="card-body">
<div class="s-widget-icon"><i class="fa fa-archive"></i></div>
<div class="s-widget-value item_total_lent"><?php echo number_format($item_total_lent, 0, ',', '.'); ?></div>
<div class="s-widget-title"><?php echo __('Lent') ?></div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3 col-lg-3">
<div class="card border-0">
<div class="card-body">
<div class="s-widget-icon"><i class="fa fa-check"></i></div>
<div class="s-widget-value item_total_available"><?php echo number_format($item_total_available, 0, ',', '.'); ?></div>
<div class="s-widget-title"><?php echo __('Available') ?></div>
</div>
</div>
</div>
</div>
<div class="row mt-3">
<div class="col col-md-8 s-dashboard">
<div class="card border-0">
<div class="card-body">
<h5 class="card-title"><?php echo __('Latest Transactions') ?></h5>
<canvas id="line-chartjs" height="294"></canvas>
<div class="s-dashboard-legend">
<i class="fa fa-square" style="color:#F4CC17;"></i> <?php echo __('Loan') ?>
<i class="fa fa-square" style="color:#459CBD;"></i> <?php echo __('Return') ?>
<i class="fa fa-square" style="color:#5D45BD;"></i> <?php echo __('Extend') ?>
</div>
</div>
</div>
</div>
<div class="col col-md-4 s-dashboard">
<div class="card border-0">
<div class="card-body">
<h5 class="card-title"><?php echo __('Summary') ?></h5>
<div class="s-chart">
<canvas id="radar-chartjs" width="175" height="175"></canvas>
</div>
<table class="table">
<tr>
<td class="text-left"><i class="fa fa-square"
style="color:#f2f2f2;"></i> <?php echo __('Total') ?>
</td>
<td class="text-right loan_total"><?php echo number_format($loan_summary['total']??0, 0, ',', '.'); ?></td>
</tr>
<tr>
<td class="text-left"><i class="fa fa-square"
style="color:#337AB7;"></i> <?php echo __('New') ?>
</td>
<td class="text-right loan_new"><?php echo number_format($loan_summary['new_loans']??0, 0, ',', '.'); ?></td>
</tr>
<tr>
<td class="text-left"><i class="fa fa-square"
style="color:#06B1CD;"></i> <?php echo __('Return') ?>
</td>
<td class="text-right loan_return"><?php echo number_format($loan_summary['returns']??0, 0, ',', '.'); ?></td>
</tr>
<tr>
<td class="text-left"><i class="fa fa-square"
style="color:#4AC49B;"></i> <?php echo __('Extends') ?>
</td>
<td class="text-right loan_extend"><?php echo number_format($loan_summary['extends']??0, 0, ',', '.'); ?></td>
</tr>
<tr>
<td class="text-left"><i class="fa fa-square"
style="color:#F4CC17;"></i> <?php echo __('Overdue') ?>
</td>
<td class="text-right loan_overdue"><?php echo number_format($loan_summary['overdue']??0, 0, ',', '.'); ?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="<?php echo JWB ?>chartjs/Chart.min.js"></script>
<script>
$(function () {
// Data untuk chart summary (doughnut)
let summaryData = [
{
value: <?php echo $loan_summary['total']??0; ?>,
color: "#f2f2f2",
label: "<?php echo __('Total'); ?>"
},
{
value: <?php echo $loan_summary['new_loans']??0; ?>,
color: "#337AB7",
label: "<?php echo __('Loan'); ?>"
},
{
value: <?php echo $loan_summary['returns']??0; ?>,
color: "#06B1CD",
label: "<?php echo __('Return'); ?>"
},
{
value: <?php echo $loan_summary['extends']??0; ?>,
color: "#4AC49B",
label: "<?php echo __('Extend'); ?>"
},
{
value: <?php echo $loan_summary['overdue']??0; ?>,
color: "#F4CC17",
label: "<?php echo __('Overdue'); ?>"
}
];
// Render doughnut chart
let r = $('#radar-chartjs');
let container = $(r).parent();
let rt = r.get(0).getContext("2d");
$(window).resize(respondCanvas);
function respondCanvas() {
r.attr('width', $(container).width());
r.attr('height', $(container).height());
let myChart = new Chart(rt).Doughnut(summaryData, {
animation: false,
segmentStrokeWidth: 1
});
}
respondCanvas();
// Data untuk line chart (7 hari terakhir)
let lineChartData = {
labels: <?php echo json_encode($chart_labels); ?>,
datasets: [
{
fillColor: '#F4CC17',
highlightFill: '#F4CC17',
data: <?php echo json_encode($loan_data); ?>
},
{
fillColor: '#459CBD',
highlightFill: '#459CBD',
data: <?php echo json_encode($return_data); ?>
},
{
fillColor: '#5D45BD',
highlightFill: '#5D45BD',
data: <?php echo json_encode($extend_data); ?>
}
]
};
// Render bar chart
let c = $('#line-chartjs');
let container2 = $(c).parent();
let ct = c.get(0).getContext("2d");
$(window).resize(respondCanvas2);
function respondCanvas2() {
c.attr('width', $(container2).width());
c.attr('height', $(container2).height());
new Chart(ct).Bar(lineChartData, {
barShowStroke: false,
barDatasetSpacing: 4,
animation: {
onProgress: function(animation) {
progress.value = animation.animationObject.currentStep / animation.animationObject.numSteps;
}
}
});
}
respondCanvas2();
});
<?php if (utility::havePrivilege('system', 'r') && utility::havePrivilege('system', 'w')): ?>
<?php if (config('database_backup.reminder') && !config('database_backup.auto')): ?>
// Backup process
$('#backupproc').click(function(e) {
e.preventDefault()
let currentLabel = $(this).html()
$(this).removeClass('btn-primary').addClass('btn-secondary disabled')
$(this).html('<?= __('Please wait') ?>')
backupDatabase($(this).attr('href'), function(result) {
if (result.status) {
window.location.href = '<?= $_SERVER['PHP_SELF'] ?>'
} else {
$(this).html(currentLabel)
console.error(result.message)
window.toastr.error(result.message, '<?= __('Error') ?>')
}
})
})
<?php endif; ?>
function backupDatabase(href, callback) {
$.post(href, {start:true,tkn:'<?= $_SESSION['token']??'' ?>',verbose:'no',response:'json'}, function(result, status, post){
var result = JSON.parse(result)
callback(result)
});
}
<?php if (!$is_repaired && !$alreadyBackup && config('database_backup.auto')): ?>
$('.contentDesc').slideUp();
$('#backupProccess').slideDown();
backupDatabase('<?= MWB.'system/backup_proc.php' ?>', function(result) {
if (result.status) {
window.location.href = '<?= $_SERVER['PHP_SELF'] ?>'
} else {
$(this).html(currentLabel)
console.error(result.message)
window.toastr.error(result.message, '<?= __('Error') ?>')
}
})
<?php endif; ?>
<?php endif; ?>
<?php if ((int) $_SESSION['uid'] === 1) : ?>
// get lastest release
fetch('https://api.github.com/repos/slims/slims9_bulian/releases/latest')
.then(res => res.json())
.then(res => {
if (res.tag_name > '<?= SENAYAN_VERSION_TAG; ?>') {
$('#new_version').text(res.tag_name);
$('#alert-new-version').removeClass('hidden');
$('#alert-new-version a').attr('href', res.html_url)
}
})
<?php endif; ?>
</script>
<?php } ?>