PHP GD 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[] = __('Freetype 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 is currently {num_overdue} library members having overdue. Please check at Circulation module at Overdues 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[] = __('Images 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[] = __('Repository 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[] = __('File upload 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 mysqldump 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 (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]);
while ($rowcheck = $query_of_check->fetch_assoc()) {
if (!(($rowcheck['Msg_type'] == "status") && ($rowcheck['Msg_text'] == "OK"))) {
if ($row[0] != $prevtable) {
$repair .= 'Table '.$row[0].' might need to be repaired.';
}
$prevtable = $row[0];
$is_repaired = true;
}
}
}
if (($is_repaired) && !isset($_POST['do_repair'])) {
echo '';
echo ' ';
}
// if there any warnings
if ($warnings) {
echo '';
echo '
';
foreach ($warnings as $warning_msg) {
echo '- '.$warning_msg.'
';
}
echo '
';
echo '
';
}
// 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 ''.$content_data['Content'].'
';
unset($content_data);
}
} else {
// generate dashboard content
$get_date = '';
$get_loan = '';
$get_return = '';
$get_extends = '';
$start_date = date('Y-m-d'); // set date from TODAY
// get date transaction
$sql_date =
"SELECT
DATE_FORMAT(loan_date,'%d/%m') AS loandate,
loan_date
FROM
loan
WHERE
loan_date BETWEEN DATE_SUB('".$start_date."', INTERVAL 8 DAY) AND '".$start_date."'
GROUP BY
loan_date
ORDER BY
loan_date";
// echo $sql_loan; //for debug purpose only
$set_date = $dbs->query($sql_date);
while ($transc_date = $set_date->fetch_object()) {
// set transaction date
$get_date .= '"'.$transc_date->loandate.'",';
// get latest loan
$sql_loan =
"SELECT
COUNT(loan_date) AS countloan
FROM
loan
WHERE
loan_date = '".$transc_date->loan_date."'
AND is_lent = 1
AND renewed = 0
AND is_return = 0
GROUP BY
loan_date";
$set_loan = $dbs->query($sql_loan);
if($set_loan->num_rows > 0) {
$transc_loan = $set_loan->fetch_object();
$get_loan .= $transc_loan->countloan.',';
} else {
$get_loan = 0;
}
// get latest return
$sql_return =
"SELECT
COUNT(loan_date) AS countloan
FROM
loan
WHERE
loan_date = '".$transc_date->loan_date."'
AND is_lent = 1
AND renewed = 0
AND is_return = 1
GROUP BY
loan_date";
$set_return = $dbs->query($sql_return);
if($set_return->num_rows > 0) {
$transc_return = $set_return->fetch_object();
$get_return .= $transc_return->countloan.',';
} else {
$get_return = 0;
}
// get latest extends
$sql_extends =
"SELECT
COUNT(loan_date) AS countloan
FROM
loan
WHERE
loan_date = '".$transc_date->loan_date."'
AND is_lent = 1
AND renewed = 1
GROUP BY
loan_date";
$set_extends = $dbs->query($sql_extends);
if($set_extends->num_rows > 0) {
$transc_extends = $set_extends->fetch_object();
$get_extends .= $transc_extends->countloan.',';
} else {
$get_extends = 0;
}
}
// return transaction date
$get_date = substr($get_date,0,-1);
$get_loan = substr($get_loan,0,-1);
$get_return = substr($get_return,0,-1);
$get_extends = substr($get_extends,0,-1);
// get total summary
$sql_total_coll = ' SELECT
COUNT(loan_id) AS total
FROM
loan';
$total_coll = $dbs->query($sql_total_coll);
$total = $total_coll->fetch_object();
$get_total = $total->total;
// get loan summary
$sql_loan_coll = ' SELECT
COUNT(loan_id) AS total
FROM
loan
WHERE
is_lent = 1
AND is_return = 0';
$total_loan = $dbs->query($sql_loan_coll);
$loan = $total_loan->fetch_object();
$get_total_loan = $loan->total;
// get return summary
$sql_return_coll = ' SELECT
COUNT(loan_id) AS total
FROM
loan
WHERE
is_lent = 1
AND is_return = 1';
$total_return = $dbs->query($sql_return_coll);
$return = $total_return->fetch_object();
$get_total_return = $return->total;
// get extends summary
$sql_extends_coll = ' SELECT
COUNT(loan_id) AS total
FROM
loan
WHERE
is_lent = 1
AND renewed = 1
AND is_return = 0';
$total_extends = $dbs->query($sql_extends_coll);
$renew = $total_extends->fetch_object();
$get_total_extends = $renew->total;
// get overdue
$sql_overdue_coll = ' SELECT
COUNT(fines_id) AS total
FROM
fines';
$total_overdue = $dbs->query($sql_overdue_coll);
$overdue = $total_overdue->fetch_object();
$get_total_overdue = $overdue->total;
// get titles
$sql_title_coll = ' SELECT
COUNT(biblio_id) AS total
FROM
biblio';
$total_title = $dbs->query($sql_title_coll);
$title = $total_title->fetch_object();
$get_total_title = number_format($title->total,0,'.',',');
// get item
$sql_item_coll = ' SELECT
COUNT(item_id) AS total
FROM
item';
$total_item = $dbs->query($sql_item_coll);
$item = $total_item->fetch_object();
$get_total_item = number_format($item->total,0,'.',',');
$get_total_available = $item->total - $get_total_loan;
$get_total_available = number_format($get_total_available,0,'.',',');
?>