Example #1
0
function getListAjax()
{
    global $error;
    $arr_submit = array(array('uid', 'int', true, ''), array('cid', 'int', false, ''));
    $frm_submitted = validate_var($arr_submit);
    header("location:" . FULLCAL_URL . "/admin/lists/?action=get_list&uid=" . $frm_submitted['uid'] . "&cid=" . $frm_submitted['cid']);
    exit;
    $arr_mixed_list = Lists::getList($frm_submitted);
    $arr_list = $arr_mixed_list['list'];
    $arr_user = User::getUserById($frm_submitted['uid']);
    $arr_calendars = Calendar::getCalendarsByUserId($frm_submitted['uid']);
    echo json_encode(array('list' => $arr_list));
    exit;
}
Example #2
0
                     } else {
                         if ($index_a[1] == "modify") {
                             echo "modify book";
                         }
                     }
                 }
             }
         }
     }
 } else {
     if ($index_a[0] == "users") {
         //User pages
         if (!isset($index_a[1])) {
             require 'list.class.php';
             $list = new Lists($index_a[0]);
             $res['users'] = $list->getList();
         } else {
             if ($index_a[1] == "stats") {
                 require 'stats.class.php';
                 //Default stats page, without extra variables
                 //$index_a[2] == book id
                 if (count($index_a) == 3) {
                     $stats = new Stats($index_a[0], $index_a[2]);
                     $res['stats'] = $stats->printStats();
                 } else {
                     //As there are no "global" stats for users yet (haven't come up with a reason to have it, and what it would include)
                     $res['error'] = 'Ingen bruker er spesifisert.';
                 }
             }
         }
     } else {
Example #3
0
function print_info($info)
{
    $date = (new DateTime())->format('Y-m-d H:i:s');
    echo '<div class="padding" id="details">';
    if (isset($info['userID'])) {
        $type = "user";
        echo '<h2>Brukerinformasjon</h2>';
    } else {
        if (isset($info['bookID'])) {
            $type = "book";
            echo '<h2>Bokinformasjon</h2>';
        } else {
            if (isset($info['shelfID']) || isset($info['shelfNR'])) {
                $type = "shelf";
                echo '<h2>Hylle informasjon</h2>';
            } else {
                return false;
            }
        }
    }
    //Print general info
    echo '<table cellspacing=0><form method="POST" action="' . URL_ROOT . 'modify/' . $type . '/' . $info[$type . "ID"] . '/' . $info[$type . "ID"] . '">';
    foreach ($info as $key => $inf) {
        if (!is_array($inf)) {
            if ($key != "userID" && $key != "bookID" && ($key != "shelfID" || $type == "book") && $key != "username" && $key != "registered") {
                if ($key == "sex") {
                    echo '<tr><td>Kjønn</td><td><select name="' . $key . '">';
                    $descs = array("Ikke spesifisert", "Gutt", "Jente");
                    for ($i = 0; $i < count($descs); $i++) {
                        $selected = '';
                        if ($i == $inf) {
                            $selected = 'selected="selected"';
                        }
                        echo '<option value="' . $i . '" ' . $selected . '>' . $descs[$i] . '</option>';
                    }
                    echo '</select></td></tr>';
                } else {
                    if ($key == "approved_date") {
                        echo '<tr><td>Godkjent</td><td><select name="' . $key . '"><option value="null">Ikke godkjent</option>';
                        $selected = '';
                        $approved_date = date("Y-m-d H:i:s");
                        if ($inf != null) {
                            $selected = 'selected="selected"';
                            $approved_date = $inf;
                        }
                        echo '<option value="' . $approved_date . '" ' . $selected . '>Godkjent ' . $inf . '</option>';
                        echo '</select></td></tr>';
                    } else {
                        if ($key == "shelfID" && $type != "shelf") {
                            $sel = "";
                            if ($inf == 0) {
                                $sel = "selected='selected'";
                            }
                            echo '<tr><td>Hylle</td><td><select name="' . $key . '"><option value="0" ' . $sel . '>Ingen hylle</option>';
                            include 'list.class.php';
                            $_list = new Lists("shelves");
                            $list = $_list->getList();
                            foreach ($list as $shelf) {
                                $selected = "";
                                if ($inf == $shelf['shelfID']) {
                                    $selected = "selected='selected'";
                                }
                                echo '<option value="' . $shelf['shelfID'] . '" ' . $selected . '>' . $shelf['name'] . '</option>';
                            }
                            echo '</select></td></tr>';
                        } else {
                            if ($key == 'birth') {
                                $datee = explode(" ", $inf)[0];
                                $date = explode("-", $datee);
                                echo '<tr><td>Fødselsdag</td><td><select name="' . $key . '_day">';
                                for ($i = 1; $i <= 31; $i++) {
                                    if ($i < 10) {
                                        $i = '0' . $i;
                                    }
                                    $selected = '';
                                    if ($i . "" == "" . $date[2]) {
                                        $selected = 'selected="selected"';
                                    }
                                    echo "<option value='{$i}' {$selected}>" . $i . "</option>";
                                }
                                echo '</select> <select name="' . $key . '_month">';
                                for ($i = 1; $i <= 12; $i++) {
                                    if ($i < 10) {
                                        $i = '0' . $i;
                                    }
                                    $selected = '';
                                    if ($i . "" == "" . $date[1]) {
                                        $selected = 'selected="selected"';
                                    }
                                    echo "<option value='{$i}' {$selected}>" . $i . "</option>";
                                }
                                echo '</select> <select name="' . $key . '_year">';
                                for ($i = (int) date("Y"); $i >= (int) date("Y") - 80; $i--) {
                                    $selected = '';
                                    if ($i == $date[0]) {
                                        $selected = 'selected="selected"';
                                    }
                                    echo "<option value='{$i}' {$selected}>" . $i . "</option>";
                                }
                                echo '</select></td></tr>';
                            } else {
                                if ($key == "type") {
                                    echo '<tr><td>Type</td><td><select name="' . $key . '">';
                                    $types = array('blad', 'bok', 'film', 'lydbok');
                                    foreach ($types as $typi) {
                                        $selected = '';
                                        if ($inf == $typi) {
                                            $selected = 'selected="selected"';
                                        }
                                        echo "<option value='{$typi}' {$selected}>{$typi}</option>";
                                    }
                                    echo '</select></td></tr>';
                                } else {
                                    if ($key == "language") {
                                        echo '<tr><td>Språk</td><td><select name="' . $key . '">';
                                        $languages = array('Engelsk', 'Norsk');
                                        foreach ($languages as $lang) {
                                            $selected = '';
                                            if ($inf == $lang) {
                                                $selected = 'selected="selected"';
                                            }
                                            echo "<option value='{$lang}' {$selected}>{$lang}</option>";
                                        }
                                        echo '</select></td></tr>';
                                    } else {
                                        echo '<tr>
                        <td>' . $key . '</td>
                        <td><input type="text" name="' . $key . '" maxlength=400 value="' . $inf . '" /></td>
                    </tr>';
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                echo '<tr>
                    <td>' . $key . '</td>
                    <td>' . $inf . '</td>
                </tr>';
            }
        }
    }
    echo '<tr><td colspan=2><button>Oppdater</button></td></tr></form></table>';
    //Contact info
    if ($type == "user") {
        //Contact info
        if (isset($info['contact']) && is_array($info['contact'])) {
            echo '<h2>Kontaktinformasjon</h2>';
            echo '<table cellspacing=0><tr><th>Telefon</th><th>Email</th><th colspan=2>Comment</th></tr>';
            foreach ($info['contact'] as $contact) {
                echo '<tr><form action="' . URL_ROOT . 'modify/contact/' . $contact['contactID'] . '/' . $info[$type . "ID"] . '" method="POST">';
                foreach ($contact as $key => $cont) {
                    if ($key != "contactID") {
                        echo '<td><input type="text" maxlength=300 name="' . $key . '" value="' . $cont . '" /></td>';
                    }
                }
                echo '<td><button>Oppdater</button><input type="button" value="Slett" onclick="window.location.href = \'' . URL_ROOT . 'contact/delete/' . $contact['contactID'] . '/' . $info[$type . "ID"] . '\'" /></td>';
                echo '</form></tr>';
            }
            echo '<tr><td colspan=4><input type="button" value="Legg til" onclick="window.location.href = \'' . URL_ROOT . 'contact/add/' . $info[$type . "ID"] . '\'" /></td></tr>';
            echo '</table>';
        }
    }
    //Settings
    if ($type == 'user') {
        if (isset($info['settings']) && is_array($info['settings'])) {
            echo '<h2>Innstillinger</h2>';
            /*'public_photos' => 0, 'save_log' => 0, 'save_visits' => 0, 'preferred_contact' => 0*/
            echo '<form action="' . URL_ROOT . 'modify/setting/' . $info['settings']["settingID"] . '/' . $info[$type . "ID"] . '" method="POST"><table cellspacing=0>';
            foreach ($info['settings'] as $keyy => $vall) {
                if ($keyy == "settingID") {
                    echo "<input type='hidden' name='{$keyy}' value='{$vall}' />";
                } else {
                    if ($keyy == "preferred_contact") {
                        echo '<tr><td>Foretrukket kontakt</td><td><select name="' . $keyy . '">';
                        //List contact-infos and display them by their comment
                        foreach ($info['contact'] as $contact) {
                            echo '<option value="' . $contact['contactID'] . '">' . $contact['comment'] . '</option>';
                        }
                        echo '</select></td></tr>';
                    } else {
                        echo '<tr><td>' . $keyy . '</td><td><select name="' . $keyy . '">';
                        $poss_vals = array(0 => 'Ikke tillatt', 1 => 'Tillatt');
                        foreach ($poss_vals as $k => $v) {
                            $se = '';
                            if ($k == $vall) {
                                $se = 'selected="selected"';
                            }
                            echo '<option value="' . $k . '" ' . $se . '>' . $v . '</option>';
                        }
                        echo '</select></td></tr>';
                    }
                }
            }
            echo '<tr><td colspan=2><button>Oppdater</button></td></tr></table></form>';
        }
    }
    //RFID
    echo '<h2>RFID</h2>';
    if (isset($info['rfid']) && is_array($info['rfid'])) {
        echo '<table cellspacing=0>';
        foreach ($info['rfid'] as $key => $rfid) {
            echo '<tr><td>';
            //echo '<form action="'.URL_ROOT.'modify/rfid" method="POST" id="rfid_'.$key.'">';
            echo '<form action="' . URL_ROOT . 'modify/rfid/' . get_plural($type) . '/' . $info[$type . "ID"] . '" method="POST" id="rfid_' . $key . '">';
            echo '<p class="p ' . $rfid[0] . '" style="display:inline;">' . $rfid[0] . '</p>';
            echo '<input type="hidden" name="original" class="original" value="' . $rfid[0] . '" />';
            echo '<input type="hidden" name="new" class="new" />';
            if ($type == "book") {
                echo '<input type="hidden" name="_shelfID" value="' . $rfid[2] . '" />';
            }
            echo '</form></td>';
            echo '<td style="border-right: 1px solid black;"><input type="button" value="Endre" onclick="change_rfid(' . $key . ')" /> <input type="button" value="Slett" onclick="window.location.href=\'' . URL_ROOT . 'rfid/delete/' . $rfid[0] . '/' . $type . '/' . $info[$type . "ID"] . '\'" /></td>';
            if ($type == "book") {
                echo '<td><form action="' . URL_ROOT . 'modify/rfid/' . get_plural($type) . '/' . $info[$type . "ID"] . '" method="POST">';
                echo '<select style="display:inline;" name="_shelfID">';
                $selected = '';
                if ($rfid[2] == 0) {
                    $selected = "selected='selected'";
                }
                echo '<option value="0" ' . $selected . '>Ingen Hylle.</option>';
                require ROOT . '../../koble_til_database.php';
                $get_shelves = "SELECT * FROM lib_Shelf";
                $get_shelves_qry = $conn->query($get_shelves);
                if ($get_shelves_qry->num_rows > 0) {
                    while ($shelf = $get_shelves_qry->fetch_assoc()) {
                        $selected = '';
                        if ($shelf['shelfID'] == $rfid[2]) {
                            $selected = 'selected="selected"';
                        }
                        echo '<option value="' . $shelf['shelfID'] . '" ' . $selected . '>' . $shelf['shelfNR'] . ' - ' . $shelf['name'] . '</option>';
                    }
                }
                echo '</select><input type="hidden" name="original" value="' . $rfid[0] . '" />';
                echo '<input type="hidden" name="new" value="' . $rfid[0] . '" />';
                echo ' <button>Oppdater</button></form></td>';
            }
            echo '</tr>';
        }
        echo '</table>';
    }
    echo '<input type="button" onclick="window.location.href = \'' . URL_ROOT . 'rfid/create/' . $type . '/' . $info[$type . "ID"] . '\'" value="Legg til RFID">';
    //Lended history
    if ($type == "book" || $type == "user") {
        echo '<h2>Lånehistorikk</h2>';
        if (isset($info['lended']) && is_array($info['lended'])) {
            echo '<table cellspacing=0><tr><th>Bok RFID</th><th>Bruker ID</th><th>Bok ID</th><th>Utlånsdato</th><th>Innleveringsdato</th><th>Innleveringsfrist</th></tr>';
            foreach ($info['lended'] as $lended) {
                echo '<tr>';
                echo '<td><a href="' . URL_ROOT . 'info/books/' . $lended['bookID'] . '#' . $lended['bookRFID'] . '" class="' . $lended['bookRFID'] . '">' . $lended['bookRFID'] . '</a></td>';
                echo '<td><a href="' . URL_ROOT . 'info/users/' . $lended['userID'] . '">' . $lended['userID'] . '</a></td>';
                echo '<td><a href="' . URL_ROOT . 'info/books/' . $lended['bookID'] . '#' . $lended['bookRFID'] . '">' . $lended['bookID'] . '</a></td>';
                echo '<td>' . $lended['outDate'] . '</td>';
                echo '<td>' . $lended['inDate'] . '</td>';
                echo '<td></td>';
                echo '</tr>
                ';
            }
            echo '</table>';
        }
    }
    //Button to delete
    echo '<h3>Slett</h3><input type="button" value="Slett" onclick="window.location.href = \'' . URL_ROOT . 'delete/' . $type . '/' . $info[$type . "ID"] . '\'">';
    echo "</div>";
    display_select_rfid_script();
    display_rfid_script();
}