Example #1
0
function lend_return($option, $bid)
{
    global $database, $my;
    if (!is_array($bid) || count($bid) < 1) {
        echo "<script> alert('Select an item to lend'); window.history.go(-1);</script>\n";
        exit;
    }
    $bids = implode(',', $bid);
    //for databases without subselect
    $select = "SELECT a.*, l.id as lendid, l.lend_from as lend_from, " . "l.lend_return as lend_return, l.lend_until as lend_until, l.fk_userid as fk_userid, " . "l.user_name as user_name, l.user_email as user_email, u.name AS name, u.email as email" . "\nFROM #__booklibrary AS a" . "\nLEFT  JOIN #__booklibrary_lend AS l ON l.id = a.fk_lendid" . "\nLEFT JOIN #__users AS u ON u.id = l.fk_userid" . "\nWHERE a.id in (" . $bids . ")";
    $database->setQuery($select);
    if (!$database->query()) {
        echo "<script> alert('" . addslashes($database->getErrorMsg()) . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $books = $database->loadObjectList();
    $count = count($books);
    for ($i = 0; $i < 1; $i++) {
        if ($books[$i]->lend_from == '' && $books[$i]->lend_return == '') {
            ?>
            <script type = "text/JavaScript" language = "JavaScript">
                alert('You cannot return books that were not lent out');
                window.history.go(-1);
            </script>
            <?php 
            exit;
        }
    }
    // get list of users
    $userlist[] = mosHTML::makeOption('-1', '----------');
    $database->setQuery("SELECT id AS value, name AS text from #__users ORDER BY name");
    $userlist = array_merge($userlist, $database->loadObjectList());
    $usermenu = mosHTML::selectList($userlist, 'userid', 'class="inputbox" size="1"', 'value', 'text', '-1');
    HTML_booklibrary::showLendBooks($option, $books, $usermenu, "lend_return");
}
Example #2
0
 static function lent($option, $bid)
 {
     PHP_booklibrary::addTitleAndMetaTags();
     global $database, $my;
     if (!is_array($bid) || count($bid) < 1) {
         echo "<script> alert('Select an item to lend'); window.history.go(-1);</script>\n";
         exit;
     }
     $bids = implode(',', $bid);
     $select = "SELECT a.*, cc.name AS category, l.id as lendid, l.lend_from as lend_from, " . "l.lend_return as lend_return, l.lend_until as lend_until, " . "l.user_name as user_name, l.user_email as user_email " . "\nFROM #__booklibrary AS a" . "\nLEFT JOIN #__booklibrary_categories AS bc ON bc.bookid  = a.bookid " . "\nLEFT JOIN #__booklibrary_main_categories AS cc ON cc.id = bc.catid" . "\nLEFT JOIN #__booklibrary_lend AS l ON l.id = a.fk_lendid" . "\nWHERE a.id in (" . $bids . ")";
     $database->setQuery($select);
     if (!$database->query()) {
         echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $books = $database->loadObjectList();
     //for rent or not
     $count = count($books);
     // get list of categories
     $userlist[] = mosHTML::makeOption('-1', '----------');
     $database->setQuery("SELECT id AS value, name AS text from #__users ORDER BY name");
     $userlist = array_merge($userlist, $database->loadObjectList());
     $usermenu = mosHTML::selectList($userlist, 'userid', 'class="inputbox" size="1"', 'value', 'text', '-1');
     HTML_booklibrary::showLendBooks($option, $books, $usermenu, "lend");
 }