Example #1
0
function db_append_to_log($tabName, $idrec, $opname, $desc, $newval)
{
    global $userid, $link;
    $idtab = idTabForName($tabName);
    $op = operationIDForName($opname);
    $ip = getRealUserIp();
    $rectm = date("Y-m-d H:i:s");
    $stm = $link->stmt_init();
    $stm->prepare('INSERT INTO LOG (RECORDED, IP, ID_USER, ID_TAB, ID_RECORD, OPERATION, DESCRIPTION, NEWVAL) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
    $stm->bind_param('ssiissss', $rectm, $ip, $userid, $idtab, $idrec, $op, $desc, $newval);
    $stm->execute();
    $stm->close();
}
Example #2
0
function db_export_travels()
{
    global $link;
    $maxfiles = db_count_files(idTabForName('STUDENT_EXCHANGES'));
    $maxforeign = db_count_foreign_courses();
    $maxfmfi = db_count_fmfi_courses();
    $stm = $link->stmt_init();
    $stm->prepare('SELECT STUDENT_EXCHANGES.ID, STUDENT_EXCHANGES.FROM_DATE, STUDENT_EXCHANGES.TO_DATE, STUDENT_STUDY_PROGRAMS.ID_STUDENT, STUDENT_STUDY_PROGRAMS.ID_STUDYPROGRAM, STUDENTS.FIRSTNAME, STUDENTS.MIDDLENAMES, STUDENTS.LASTNAME, STUDENTS.STUDENT_ID, STUDENT_EXCHANGES.STUDY_YEAR, STUDY_PROGRAMS.CODE, STUDENT_EXCHANGES.AGREEMENT_ID, UNIVERSITIES.NAME, COUNTRIES.NAME FROM STUDENT_EXCHANGES JOIN STUDENT_STUDY_PROGRAMS ON STUDENT_STUDY_PROGRAMS.ID=STUDENT_EXCHANGES.ID_STUDENT_STUDY_PROGRAM JOIN STUDENTS ON STUDENTS.ID=STUDENT_STUDY_PROGRAMS.ID_STUDENT JOIN STUDY_PROGRAMS ON STUDY_PROGRAMS.ID=STUDENT_STUDY_PROGRAMS.ID_STUDYPROGRAM JOIN AGREEMENTS ON AGREEMENTS.ID=STUDENT_EXCHANGES.AGREEMENT_ID JOIN UNIVERSITIES ON UNIVERSITIES.ID=AGREEMENTS.ID_UNIVERSITY JOIN COUNTRIES ON COUNTRIES.ID=UNIVERSITIES.ID_COUNTRY');
    $stm->execute();
    $st = $stm->get_result();
    print '"ID","TRAVEL_FROM_DATE","TRAVEL_TO_DATE","ID_STUDENT","ID_STUDYPROGRAM","FIRSTNAME","MIDDLENAMES","LASTNAME","STUDENT_ID","STUDY_YEAR","STUDPROG_CODE","AGREEMENT_ID","UNIVERSITY","COUNTRY"';
    for ($i = 1; $i <= $maxfiles; $i++) {
        print ',"FILENAME' . $i . '","ORIGINAL_FILENAME' . $i . '","DESCRIPTION' . $i . '"';
    }
    for ($i = 1; $i <= $maxforeign; $i++) {
        print ',"FOREIGN_COURSE_NAME' . $i . '","FOREIGN_COURSE_CODE' . $i . '","CREDITS' . $i . '","GRADE' . $i . '","COURSE_TYPE' . $i . '"';
    }
    for ($i = 1; $i <= $maxfmfi; $i++) {
        print ',"FMFI_COURSE_NAME' . $i . '","FMFI_COURSE_CODE' . $i . '","CREDITS' . $i . '"';
    }
    print_nl();
    while ($rw = $st->fetch_row()) {
        print $rw[0] . ',"' . $rw[1] . '","' . $rw[2] . '",' . $rw[3] . ',' . $rw[4] . ',"' . ddq($rw[5]) . '","' . ddq($rw[6]) . '","' . ddq($rw[7]) . '","' . ddq($rw[8]) . '",' . ddq($rw[9]) . ',"' . ddq($rw[10]) . '",' . $rw[11] . ',"' . ddq($rw[12]) . '","' . ddq($rw[13]) . '"';
        print_files(idTabForName('STUDENT_EXCHANGES'), $rw[0], $maxfiles);
        print_foreign_courses($rw[0], $maxforeign);
        print_fmfi_courses($rw[0], $maxfmfi);
        print_nl();
    }
    $stm->close();
}