Location: PHPKode > projects > SENAYAN Library Automation > senayan3-stable5/admin/modules/bibliography/pop_topic.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

*/

/* Biblio Topic Adding Pop Windows */

// start the session
session_start();

require '../../../sysconfig.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/form_maker/simbio_form_table.inc.php';
require SIMBIO_BASE_DIR.'simbio_DB/simbio_dbop.inc.php';

// create the template object
$template = new simbio_template_parser('../../'.$sysconf['admin_template']['dir'].'/'.$sysconf['admin_template']['theme'].'/page_tpl.html');
// page title
$page_title = 'Topics List';
// check for biblioID in url
$biblioID = 0;
if (isset($_GET['biblioID']) AND $_GET['biblioID']) {
    $biblioID = (integer)$_GET['biblioID'];
}

// start the output buffer
ob_start();
/* main content */
// biblio topic save proccess
if (isset($_POST['save'])) {
    // create new sql op object
    $sql_op = new simbio_dbop($dbs);
    // check if biblioID POST var exists
    if (isset($_POST['biblioID']) AND !empty($_POST['biblioID'])) {
        $data['biblio_id'] = (integer)$_POST['biblioID'];
        // check if the topic select list is empty or not
        if (!empty($_POST['topicID'])) {
            $data['topic_id'] = $_POST['topicID'];
        } else if (!empty($_POST['search_str']) AND empty($_POST['topicID'])) {
            // adding new topic
            $topic_data['topic'] = trim($dbs->escape_string(strip_tags($_POST['search_str'])));
            $topic_data['input_date'] = date('Y-m-d');
            $topic_data['last_update'] = date('Y-m-d');
            // insert new topic to topic master table
            $sql_op->insert('mst_topic', $topic_data);
            // put last inserted ID
            $data['topic_id'] = $sql_op->insert_id;
        }
        $data['level'] = intval($_POST['level']);

        if ($sql_op->insert('biblio_topic', $data)) {
            echo '<script type="text/javascript">';
            echo 'alert(\'Topic succesfully updated!\');';
            echo 'opener.setIframeContent(\'topicIframe\', \''.MODULES_WEB_ROOT_DIR.'bibliography/iframe_topic.php?biblioID='.$data['biblio_id'].'\');';
            echo '</script>';
        } else {
            utility::jsAlert(lang_mod_biblio_topic_added_fail."\n".$sql_op->error);
        }
    } else {
        if (!empty($_POST['topicID'])) {
            // add to current session
            $_SESSION['biblioTopic'][$_POST['topicID']] = array($_POST['topicID'], intval($_POST['level']));
        } else if (!empty($_POST['search_str']) AND empty($_POST['topicID'])) {
            // adding new topic
            $topic_data['topic'] = trim($dbs->escape_string(strip_tags($_POST['search_str'])));
            $topic_data['input_date'] = date('Y-m-d');
            $topic_data['last_update'] = date('Y-m-d');
            // insert new topic to topic master table
            $sql_op->insert('mst_topic', $topic_data);
            $last_id = $sql_op->insert_id;
            $_SESSION['biblioTopic'][$last_id] = array($last_id, intval($_POST['level']));
        }

        echo '<script type="text/javascript">';
        echo 'alert(\''.lang_mod_biblio_topic_added_ok.'\');';
        echo 'opener.setIframeContent(\'topicIframe\', \''.MODULES_WEB_ROOT_DIR.'bibliography/iframe_topic.php\');';
        echo '</script>';
    }
}

?>

<table style='width: 100%' cellpadding='5' cellspacing='0'>
<form name='mainForm' action="pop_topic.php?biblioID=<?php echo $biblioID; ?>" method='post'>
<tr>
    <td class='alterCell'>
    <strong><?php echo lang_mod_biblio_topic_form_title; ?></strong>
    <hr />
    <form name='searchTopic' method='post' style='display: inline;'>
    <?php
    $ajax_exp = "ajaxFillSelect('../../AJAX_lookup_handler.php', 'mst_topic', 'topic_id:topic', 'topicID', $('search_str').getValue())";
    ?>
    <?php echo lang_mod_biblio_topic_form_keyword; ?> : <input type="text" name="search_str" id="search_str" style="width: 50%;" onkeyup="<?php echo $ajax_exp; ?>" />
    <select name="level" style="width: 30%;"><?php
    foreach ($sysconf['authority_level'] as $level_id => $level) {
        if ($level == 'Primary' OR $level == 'Additional') {
            echo '<option value="'.$level_id.'">'.$level.'</option>';
        }
    } ?></select>
    </td>
</tr>
<tr>
<td valign='top' class='alterCell2'>
<select name="topicID" id="topicID" size="5" style="width: 100%;"><option value="0"><?php echo lang_mod_biblio_topic_form_search; ?></option></select>
<?php
if ($biblioID) {
    echo '<input type="hidden" name="biblioID" value="'.$biblioID.'" />';
}
?>
<input type="submit" name="save" value="<?php echo lang_mod_biblio_topic_insert_to_biblio; ?>" style="margin-top: 5px;" />
</td>
</tr>
</form>
</table>

<?php
/* main content end */
$main_content = ob_get_clean();
$js_include = '<script type="text/javascript" src="'.JS_WEB_ROOT_DIR.'prototype.js"></script>'
    ."\n".'<script type="text/javascript" src="'.JS_WEB_ROOT_DIR.'form.js"></script>';

// 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-->', $js_include);
$template->assign('<!--MAIN_CONTENT-->', $main_content);

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

?>
Return current item: SENAYAN Library Automation