Location: PHPKode > projects > SENAYAN Library Automation > senayan3-stable5/admin/modules/circulation/loan_list.php
<?php

/*

VERSION : 3.0
CODENAME : SENAYAN
AUTHOR :
    Code and Programming : ARIE NUGRAHA (hide@address.com)
    Database Design : HENDRO WICAKSONO (hide@address.com) & WARDIYONO (hide@address.com)

SENAYAN Library Automation System
Copyright (C) 2007

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 (GPL License.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

/* loan list iframe content */

// start the session
session_start();

require '../../../sysconfig.inc.php';
require SIMBIO_BASE_DIR.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
require SIMBIO_BASE_DIR.'simbio_GUI/template_parser/simbio_template_parser.inc.php';
require SIMBIO_BASE_DIR.'simbio_GUI/table/simbio_table.inc.php';
require SIMBIO_BASE_DIR.'simbio_GUI/paging/simbio_paging.inc.php';
require SIMBIO_BASE_DIR.'simbio_DB/simbio_dbop.inc.php';
require SIMBIO_BASE_DIR.'simbio_UTILS/simbio_date.inc.php';
require '../membership/member_base_lib.inc.php';
require '../circulation/circulation_base_lib.inc.php';

// start the output buffering
ob_start();
?>
<!--loan specific javascript functions-->
<script type="text/javascript">
function confirmProcess(intLoanID, strItemCode, strProcess)
{
    if (strProcess == 'return') {
        var confirmBox = confirm('<?php echo lang_mod_circ_common_return_confirmation; ?> ' + strItemCode);
    } else {
        var confirmBox = confirm('<?php echo lang_mod_circ_common_extend_confirmation; ?> ' + strItemCode);
    }

    if (confirmBox) {
        // fill the hidden form value
        document.loanHiddenForm.process.value = strProcess;
        document.loanHiddenForm.loanID.value = intLoanID;
        // submit hidden form
        document.loanHiddenForm.submit();
    }
}
</script>
<!--loan specific javascript functions end-->
<?php
// check if there is member ID
if (isset($_SESSION['memberID'])) {
    $memberID = trim($_SESSION['memberID']);
    $circulation = new circulation($dbs, $memberID);
    $loan_list_query = $dbs->query("SELECT L.loan_id, b.title, i.item_code, L.loan_date, L.due_date, L.return_date, L.renewed FROM loan AS L
        LEFT JOIN item AS i ON L.item_code=i.item_code
        LEFT JOIN mst_coll_type AS ct ON i.coll_type_id=ct.coll_type_id
        LEFT JOIN member AS m ON L.member_id=m.member_id
        LEFT JOIN biblio AS b ON i.biblio_id=b.biblio_id
        WHERE L.is_lent=1 AND L.is_return=0 AND L.member_id='$memberID'");

    // create table object
    $loan_list = new simbio_table();
    $loan_list->table_attr = "align='center' style='width: 100%;' cellpadding='3' cellspacing='0'";
    $loan_list->table_header_attr = 'class="dataListHeader" style="font-weight: bold;"';
    $loan_list->highlight_row = true;
    // table header
    #$headers = array('RETURN', 'EXTEND', 'Item Code', 'Title', 'Loan Date', 'Due Date');
    $headers = array(lang_mod_circ_tblheader_return, lang_mod_circ_tblheader_extend, lang_mod_circ_tblheader_item_code, lang_mod_circ_tblheader_title, lang_mod_circ_tblheader_loan_date, lang_mod_circ_tblheader_due_date);
    $loan_list->setHeader($headers);
    // row number init
    $row = 1;
    while ($loan_list_data = $loan_list_query->fetch_assoc()) {
        // alternate the row color
        $row_class = ($row%2 == 0)?'alterCell':'alterCell2';

        // return link
        $return_link = '<a href="#" onclick="confirmProcess('.$loan_list_data['loan_id'].', \''.$loan_list_data['item_code'].'\', \'return\')" title="'.lang_mod_circ_return_titletext_return.'">'
            .'<img src="'.SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/return.png" border="0" alt="'.lang_mod_circ_return_alttext_return.'" /></a>';
        // extend link
        // check if membership already expired
        if ($_SESSION['is_expire']) {
            $extend_link = '<img src="'.SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/no_extend.png" border="0" alt="'.lang_mod_circ_extend_alttext_no_extend.'" />';
        } else {
            // check if this loan just already renewed
            if ($loan_list_data['return_date'] == date('Y-m-d')) {
                $extend_link = '<img src="'.SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/no_extend.png" border="0" alt="'.lang_mod_circ_extend_alttext_no_extend.'" />';
            } else if (in_array($loan_list_data['loan_id'], $_SESSION['reborrowed'])) {
                $extend_link = '<img src="'.SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/no_extend.png" border="0" alt="'.lang_mod_circ_extend_alttext_no_extend.'" />';
            } else {
                $extend_link = '<a href="#" onclick="confirmProcess('.$loan_list_data['loan_id'].', \''.$loan_list_data['item_code'].'\', \'extend\')" title="'.lang_mod_circ_extend_titletext_extend.'">'
                    .'<img src="'.SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/extend.png" border="0" alt="'.lang_mod_circ_extend_alttext_extend.'" /></a>';
            }
        }
        // renewed flag
        if ($loan_list_data['renewed'] > 0) {
            $loan_list_data['title'] = $loan_list_data['title'].' - <strong style="color: blue;">'.lang_mod_circ_extend_renewal_flag.'</strong>';
        }
        // check for overdue
        $curr_date = date('Y-m-d');
        $overdue = $circulation->countOverdueValue($loan_list_data['loan_id'], $curr_date);
        if ($overdue) {
            $loan_list_data['title'] .= '<div style="color: red; font-weight: bold;">'.lang_mod_circ_common_overdued_for_1.' '.$overdue['days'].' '.lang_mod_circ_common_overdued_for_2.' '.$overdue['value'].'</div>';
        }
        // row colums array
        $fields = array(
            $return_link,
            $extend_link,
            $loan_list_data['item_code'],
            $loan_list_data['title'],
            $loan_list_data['loan_date'],
            $loan_list_data['due_date']
            );

        // append data to table row
        $loan_list->appendTableRow($fields);
        // set the HTML attributes
        $loan_list->setCellAttr($row, null, "valign='top' class='$row_class'");
        $loan_list->setCellAttr($row, 0, "valign='top' align='center' class='$row_class' style='width: 5%;'");
        $loan_list->setCellAttr($row, 1, "valign='top' align='center' class='$row_class' style='width: 5%;'");
        $loan_list->setCellAttr($row, 2, "valign='top' class='$row_class' style='width: 10%;'");
        $loan_list->setCellAttr($row, 3, "valign='top' class='$row_class' style='width: 55%;'");

        $row++;
    }

    // show reservation alert if any
    if (isset($_GET['reserveAlert']) AND !empty($_GET['reserveAlert'])) {
        $reservedItem = trim($_GET['reserveAlert']);
        // get reservation data
        $reserve_q = $dbs->query('SELECT r.member_id, m.member_name
            FROM reserve AS r
            LEFT JOIN member AS m ON r.member_id=m.member_id
            WHERE item_code=\''.$reservedItem.'\' ORDER BY reserve_date DESC');
        $reserve_d = $reserve_q->fetch_row();
        $member = $reserve_d[1].' ('.$reserve_d[0].')';
        $reserve_msg = str_replace(array('{itemCode}', '{member}'), array('<b>'.$reservedItem.'</b>', '<b>'.$member.'</b>'), lang_mod_circ_reserve_alert_after_return);
        echo '<div class="infoBox">'.$reserve_msg.'</div>';
    }
    echo $loan_list->printTable();
    // hidden form for return and extend process
    echo '<form name="loanHiddenForm" method="post" action="circulation_action.php"><input type="hidden" name="process" value="return" /><input type="hidden" name="loanID" value="" /></form>';
}

// get the buffered content
$main_content = ob_get_clean();

// create the template object
$template = new simbio_template_parser(SENAYAN_BASE_DIR.'admin/'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/page_tpl.html');
// page title
$page_title = 'Member Loan List';

// assign content to markers
$template->assign('<!--PAGE_TITLE-->', $page_title);
$template->assign('<!--CSS-->', SENAYAN_WEB_ROOT_DIR.'admin/'.$sysconf['admin_template']['css']);
$template->assign('<!--JS_INCLUDE-->', '<script type="text/javascript" src="'.JS_WEB_ROOT_DIR.'prototype.js"></script>'.
    "\n".'<script type="text/javascript" src="'.JS_WEB_ROOT_DIR.'gui.js"></script>');
$template->assign('<!--MAIN_CONTENT-->', $main_content);

// print out the template
$template->printOut();

?>
Return current item: SENAYAN Library Automation