112 lines
3.4 KiB
PHP
112 lines
3.4 KiB
PHP
|
<?php
|
||
|
error_reporting(E_ALL);
|
||
|
ini_set('memory_limit', '-1');
|
||
|
header('Content-Type: application/json; charset=utf-8');
|
||
|
date_default_timezone_set('Europe/Moscow');
|
||
|
include 'inc/_db.php';
|
||
|
include 'config.php';
|
||
|
|
||
|
$des=''; if(isset($_GET['des'])) $des = $_GET['des'];
|
||
|
|
||
|
if($des=='liquidation'){
|
||
|
$rez = liquidation_get();
|
||
|
//echo json_encode($rez,JSON_UNESCAPED_UNICODE);
|
||
|
echo '<pre>'.print_r($rez,1).'</pre>';
|
||
|
}
|
||
|
function liquidation_get(){
|
||
|
GLOBAL $ST,$DB; $out=array();
|
||
|
//_liquidation: id, id_student, id_teacher, fakultet, type, iup, name, control, date_create, date_end, semestr, mark, date_mark, id_stat, print, id_user
|
||
|
$sql = 'SELECT id, id_student, id_teacher, fakultet, type, iup, name, control, date_create, date_end, semestr, mark, date_mark
|
||
|
FROM ' . $ST['dbpf'] . '_liquidation WHERE mark IS NOT NULL ORDER BY date_create DESC LIMIT 100';
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if ($rez) {
|
||
|
foreach ($rez as $k => $v) if ($k) {
|
||
|
$tmp = get_student_info($v['id_student']);
|
||
|
if(count($tmp)) {
|
||
|
unset($tmp[0]['id_grupp']);
|
||
|
$v['student'] = $tmp[0];
|
||
|
$tmp = get_teacher_info($v['id_teacher']);
|
||
|
$v['teacher'] = $tmp[0];
|
||
|
unset($v['id_student'],$v['id_teacher']);
|
||
|
$out[] = $v;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
|
||
|
|
||
|
function get_user_info($id_user){
|
||
|
GLOBAL $DB,$ST;
|
||
|
$out=array();
|
||
|
$sql = 'SELECT id,fio,polis,snils,guid FROM '.$ST['dbpf'].'_users WHERE id='.$id_user;
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if ($rez){
|
||
|
foreach($rez as $k => $v)if($k){
|
||
|
$out[] = $v;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
function get_student_info($id_student){
|
||
|
GLOBAL $DB,$ST;
|
||
|
$out=array();
|
||
|
//$sql = 'SELECT
|
||
|
// s.num_zach,s.num_grupp,s.kod_podgotovki,s.id_user
|
||
|
// g.sokr,g.fo,g.year_start,
|
||
|
// f.name,f.abbreviated
|
||
|
//FROM
|
||
|
// '.$ST['dbpf'].'_students as s,
|
||
|
// '.$ST['dbpf'].'_grupp as g,
|
||
|
// '.$ST['dbpf'].'_faculties as f
|
||
|
//WHERE
|
||
|
// g.id_facult=f.id AND
|
||
|
// d.id=s.id_grupp AND
|
||
|
// s.id='.$id_student;
|
||
|
$sql = 'SELECT num_zach, num_grupp, kod_podgotovki, id_user,id_grupp FROM '.$ST['dbpf'].'_students WHERE id='.$id_student.' ORDER BY data_c DESC LIMIT 1';
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if ($rez){
|
||
|
foreach($rez as $k => $v)if($k){
|
||
|
$tmp = get_grupp_info($v['id_grupp']);
|
||
|
if(isset($tmp[0])) $v = array_merge($v,$tmp[0]);
|
||
|
//$v['user'] = get_user_info($v['id_user']);
|
||
|
$tmp = get_user_info($v['id_user']);
|
||
|
if(isset($tmp[0])) $v = array_merge($v,$tmp[0]);
|
||
|
$out[] = $v;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
|
||
|
function get_grupp_info($id_grupp){
|
||
|
GLOBAL $DB,$ST;
|
||
|
$out=array();
|
||
|
$sql = 'SELECT sokr,fo,year_start FROM '.$ST['dbpf'].'_grupp WHERE id='.$id_grupp;
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if ($rez){
|
||
|
foreach($rez as $k => $v)if($k){
|
||
|
$out[] = $v;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|
||
|
function get_teacher_info($id_teacher){
|
||
|
GLOBAL $DB,$ST;
|
||
|
$out=array();
|
||
|
$sql = 'SELECT
|
||
|
t.fakultet,t.kafedra,
|
||
|
u.fio,u.polis,u.snils,u.guid
|
||
|
FROM
|
||
|
'.$ST['dbpf'].'_teachers as t,
|
||
|
'.$ST['dbpf'].'_users as u
|
||
|
WHERE
|
||
|
u.id=t.id_user AND
|
||
|
t.id='.$id_teacher;
|
||
|
$rez = $DB->QUR_SEL($sql);
|
||
|
if ($rez){
|
||
|
foreach($rez as $k => $v)if($k){
|
||
|
$out[] = $v;
|
||
|
}
|
||
|
}
|
||
|
return $out;
|
||
|
}
|