EIOS/integration/inc/class_STUDENTS.php

1122 lines
56 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class class_STUDENTS{
/**
* Работа со студентами
* Table: _users: id, data_c, data_u, email, pass, status, fio, foto, high_school, phone, polis, snils, guid
* Table: _students: id, data_c, data_u, id_grupp, id_user, status, num_zach, num_grupp, kod_podgotovki, id_newgrupp
* Abazovadzanet@mail.com¶
*/
function __construct(){
GLOBAL $ST,$DB;
$this->TUsers = $ST['dbpf'].'_users';
$this->TStudents = $ST['dbpf'].'_students';
$this->TTeachers = $ST['dbpf'].'_teachers';
$this->TGrupp = $ST['dbpf'].'_grupp';
$this->TFakultets = $ST['dbpf'].'_faculties';
$this->DB = $DB;
$this->DIRupload = 'upload';
$this->DIRstudents = 'students_xlsx';
}
function info(){
$SYS = new class_SYSTEM();
$out = '<h3>Выгрузка студентов</h3>';
$url = 'https://eios.mkgtu.ru/integration/api.php?step=students_get_all&format=';
$out .= '<div class="row">';
$out .= '<div class="col-8">';
$out .= '<p><a href="'.$url.'json" target="_blank" class="btn btn-info btn-sm">JSON</a> формат: <input type="text" class="form-control" value="'.$url.'json"></p>';
$out .= '<p><a href="'.$url.'csv" target="_blank" class="btn btn-info btn-sm">CSV</a> формат: <input type="text" class="form-control" value="'.$url.'csv"></p>';
$out .= '</div>';
$out .= '<div class="col-4">';
$data['dir'] = 'upload/students/';
$out .= $SYS->info_last_files($data);
$out .= '</div>';
$out .= '</div>';
$out .= '<h3>Выгрузка преподавателей</h3>';
$url = 'https://eios.mkgtu.ru/integration/api.php?step=prepods_get_all&format=';
$out .= '<div class="row">';
$out .= '<div class="col-8">';
$out .= '<p><a href="'.$url.'json" target="_blank" class="btn btn-info btn-sm">JSON</a> формат: <input type="text" class="form-control" value="'.$url.'json"></p>';
$out .= '<p><a href="'.$url.'csv" target="_blank" class="btn btn-info btn-sm">CSV</a> формат: <input type="text" class="form-control" value="'.$url.'csv"></p>';
$out .= '</div>';
$out .= '<div class="col-4">';
$data['dir'] = 'upload/prepods/';
$out .= $SYS->info_last_files($data);
$out .= '</div>';
$out .= '</div>';
$out .= '<h3>Выгрузка групп</h3>';
$url = 'https://eios.mkgtu.ru/integration/api.php?step=grupp_get_all&format=';
$out .= '<div class="row">';
$out .= '<div class="col-8">';
$out .= '<p><a href="'.$url.'json" target="_blank" class="btn btn-info btn-sm">JSON</a> формат: <input type="text" class="form-control" value="'.$url.'json"></p>';
$out .= '<p><a href="'.$url.'csv" target="_blank" class="btn btn-info btn-sm">CSV</a> формат: <input type="text" class="form-control" value="'.$url.'csv"></p>';
$out .= '</div>';
$out .= '<div class="col-4">';
$data['dir'] = 'upload/grupp/';
$out .= $SYS->info_last_files($data);
$out .= '</div>';
$out .= '</div>';
return $out;
}
function get_students($data){
$out = array();
$sql = 'SELECT u.guid, u.fio, u.email, u.phone, u.email,s.num_grupp,s.kod_podgotovki,g.specialnost,g.kurs,g.sokr,g.fo,g.year_start,f.name FROM '.$this->TUsers.' as u, '.$this->TStudents.' as s, '.$this->TGrupp.' as g, '.$this->TFakultets.' as f WHERE s.id_user=u.id AND s.id_grupp=g.id AND g.id_facult=f.id AND g.year_start>='.(date('Y')-5).' ORDER BY u.fio';
$rez = $this->DB->QUR_SEL($sql);
//echo '<pre>'.print_r($rez,1).'</pre>';
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $k => $v){
$out[] = $v;
}
}
$data['items'] = $out;
$data['dir'] = 'students';
$data['head'] = array(
'guid'=>array('name' => 'GUID','type'=>'string'),
'fio'=>array('name' => 'ФИО','type'=>'string'),
'email'=>array('name' => 'Емаил','type'=>'string'),
'phone'=>array('name' => 'Телефон','type'=>'string'),
'sokr'=>array('name' => 'Группа','type'=>'string'),
'num_grupp'=>array('name' => 'Подгруппа','type'=>'string'),
'kurs'=>array('name' => 'Курс','type'=>'string'),
'fo'=>array('name' => 'ФО','type'=>'string'),
'year_start'=>array('name' => 'Год начала','type'=>'string'),
'kod_podgotovki'=>array('name' => 'Код подготовки','type'=>'string'),
'specialnost'=>array('name' => 'Специальность','type'=>'string'),
'name'=>array('name' => 'Факультет','type'=>'string')
);
//echo '<pre>'.print_r($data,1).'</pre>';
$SYS = new class_SYSTEM();
$SYS->format($data);
}
function get_prepods($data){
$out = array();
$sql = 'SELECT u.guid, u.fio, u.email, u.phone, u.email,t.zvanie,t.dolgnost,t.stepen,t.fakultet,t.kafedra FROM '.$this->TUsers.' as u, '.$this->TTeachers.' as t WHERE t.id_user=u.id AND t.status=1 ORDER BY u.fio';
$rez = $this->DB->QUR_SEL($sql);
//echo '<pre>'.print_r($rez,1).'</pre>'; exit();
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $k => $v){
$out[] = $v;
}
}
$data['items'] = $out;
$data['dir'] = 'prepods';
$data['head'] = array(
'guid'=>array('name' => 'GUID','type'=>'string'),
'fio'=>array('name' => 'ФИО','type'=>'string'),
'email'=>array('name' => 'Емаил','type'=>'string'),
'phone'=>array('name' => 'Телефон','type'=>'string'),
'zvanie'=>array('name' => 'Звание','type'=>'string'),
'dolgnost'=>array('name' => 'Должность','type'=>'string'),
'stepen'=>array('name' => 'Степень','type'=>'string'),
'fakultet'=>array('name' => 'Факультет','type'=>'string'),
'kafedra'=>array('name' => 'Кафедра','type'=>'string')
);
//echo '<pre>'.print_r($data,1).'</pre>';
$SYS = new class_SYSTEM();
$SYS->format($data);
}
function get_grupp($data){
$out = array();
$sql = 'SELECT g.sokr,g.fo,g.kurs,g.specialnost,g.year_start,f.name FROM '.$this->TGrupp.' as g, '.$this->TFakultets.' as f WHERE g.id_facult=f.id ORDER BY g.sokr';
$rez = $this->DB->QUR_SEL($sql);
//echo '<pre>'.print_r($rez,1).'</pre>'; exit();
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $k => $v){
$out[] = $v;
}
}
$data['items'] = $out;
$data['dir'] = 'grupp';
$data['head'] = array(
'sokr'=>array('name' => 'Группа','type'=>'string'),
'fo'=>array('name' => 'ФО','type'=>'string'),
'kurs'=>array('name' => 'Курс','type'=>'string'),
'specialnost'=>array('name' => 'Специальность','type'=>'string'),
'year_start'=>array('name' => 'Год начала','type'=>'string'),
'name'=>array('name' => 'Факультет','type'=>'string')
);
//echo '<pre>'.print_r($data,1).'</pre>';
$SYS = new class_SYSTEM();
$SYS->format($data);
}
function HTML(){
GLOBAL $WorkDIR;
$CHPU = new class_CHPU($WorkDIR);
$URLS = $CHPU->uri();
$smartyC = new class_smarty();
$smarty = $smartyC->config(__DIR__.'\..\tpl');
$view = 'all'; $url= $WorkDIR.'/students/';
$out = array('name'=>'Студенты ВУЗа','body'=>'');
if(isset($_POST['ajdes'])){
header('Content-Type: application/json; charset=utf-8');
$out=array();
if($_POST['ajdes']=='students_check'){
$data = json_decode($_POST['json'],1);
$out = $this->student_check($data);//TODO переделать
}
echo json_encode($out);
exit();
}
if (isset($_POST['upload0'])){
$pi = pathinfo($_FILES['file0']['name'],PATHINFO_EXTENSION );
//print_r($pi);exit();
if(mb_strtolower($pi)=='xlsx'||mb_strtolower($pi)=='xls') {
$cSystem = new class_SYSTEM();
$file = $cSystem->uploadfile('file0', 'students_xlsx', 1);
$smarty->assign('file', $file);
if (!$file['err']) {
//$rez = $this->parse_xls($file['path'] . $file['file']);
//if($rez['err']==0) {
// $view = 'one';
// $smarty->assign('PLAN', $rez);
// $smarty->assign('view', $view);
// $out['body'] = $smarty->fetch('page_shahtplan.html');
// return $out;
//}else{
// $view = 'all';
// $smarty->assign('uplmes',$rez['file']);
//}
} else {
$rez = array();
}
}else{
$view = 'all';
$smarty->assign('uplmes','Файл должен быть Excel формата!');
}
}
if($URLS[1]=='update_grupp'){
$view = 'update_grupp';
$file = $URLS[2];
$items = $this->file_update_grupp($file);
$smarty->assign('items', $items);
}
if($URLS[1]=='update'){
$view = 'update';
$file = $URLS[2];
$items = $this->file_update($file);
$smarty->assign('items', $items);
}
if($URLS[1]=='check'){
$view = 'check';
$file = $URLS[2];
$items = $this->file_check($file);
$smarty->assign('items', $items);
}
if($URLS[1]=='parse'){
$view = 'parse';
$file = $URLS[2];
$items = $this->file_parse($file);
$smarty->assign('items', $items);
}
if(!isset($URLS[1])||$URLS[1]=='all') {
$items = $this->files_scan();
$smarty->assign('items', $items);
}
$smarty->assign('url',$url);
$smarty->assign('view',$view);
$out['body'] = $smarty->fetch('page_students.html');
return $out;
}
/**
* Определение шапки файла!
* @param $tr
* @return array
*/
function file_parse_HEAD($tr){
$out = array();
//ШАпка такая должна быть
//[5] => Array (
// [0] => № п/п
// [1] => GUID
// [2] => ФИО
// [3] => Номер зачетной книжки
// [4] => Эл.почта
// [5] => Факультет
// [6] => Курс
// [7] => Группа
// [8] => Код специальности
// [9] => Форма обучения
// [10] => Основа обучения
// [11] => СНИЛС
// [12] => Телефон
//)
$head = array('№ п/п','GUID','ФИО','Номер зачетной книжки','Эл.почта','Факультет','Курс','Группа','Код специальности','Форма обучения','Основа обучения','СНИЛС','Телефон');
//echo '<pre>'.print_r($head,1).'</pre>';
//echo '<pre>'.print_r($tr,1).'</pre>';
if($head == $tr){
$out['head']=1;
}else{
$out['head']=0;
$kol = 0;
foreach($tr as $k => $v){
if (in_array($v,$head)) $kol++;
}
if($kol>8) $out['head']=1;
}
return $out;
}
/**
* Работа с файлом JSON от ексель
* @param $des (string) save get
* @param $data (array)
* @return array
*/
function file_parse_JSON($des,$data=array()){
$out = array();
if($des=='save'){
if(isset($data['file'])){
$pi = pathinfo($data['file']);
$file_json = $pi['dirname'].'/'.$pi['filename'].'.json';
file_put_contents($file_json,json_encode($data,JSON_UNESCAPED_UNICODE));
$out['err']=0;
$out['file_json']=$file_json;
}else{
$out['err']=1;
$out['file_json']='';
}
}
if($des=='get'){
if(isset($data['file'])){
$pi = pathinfo($data['file']);
$file_json = $pi['dirname'].'/'.$pi['filename'].'.json';
if(file_exists($file_json)){
$out['err']=0;
$out['data']=json_decode(file_get_contents($file_json),1);
}else{
$out['err']=1;
$out['msg']='файла нет '.$file_json;
$out['data']=array();
}
}else{
$out['err']=1;
$out['msg']='Не указан файл';
$out['data']=array();
}
}
return $out;
}
/**
* XLS - JSON перевод
* @param $file
* @return array|mixed
* @throws PHPExcel_Reader_Exception
*/
function file_parse($file){
$out = array();
$file_cur = $this->DIRupload.'/'.$this->DIRstudents.'/'.$file;
$out['file'] = $file_cur;
$dan = $this->file_parse_JSON('get',$out);
if(!$dan['err']){
$out = $dan['data'];
$out['err'] = 0;
}else{
if(file_exists($file_cur)) {
require_once 'PHPExcel.php';
try {
$excel = PHPExcel_IOFactory::load('./' . $file_cur);
//print_r($excel);
//if (count($excel)) {
//перебираем файлы эксель, в начале - листы
foreach ($excel->getWorksheetIterator() as $worksheet) {
$lists[] = $worksheet->toArray();
}
$isHead = 0;
if (count($lists)) {
foreach ($lists as $nList => $list) {
foreach ($list as $tr => $row) {
if ($isHead == 1) {//шапка была надо хранить данные
foreach ($row as $td => $val) {
$out['items'][$nList][$tr][$td] = trim(str_replace('¶','',$val));
}
}
if ($isHead == 0) {//определим когда начнется шапка
$tmp = $this->file_parse_HEAD($row);
if ($tmp['head'] == 1) $isHead = 1;
}
}
}
//echo '<pre>'.print_r($out,1).'</pre>'; //exit();
$out['rez'] = $this->file_parse_JSON('save', $out);
} else {
$out['err'] = 1;
$out['msg'] = 'Не смогли определить листы';
}
//} else {
// $out['err'] = 1;
// $out['msg'] = 'Не смогли открыть файл';
//}
} catch (PHPExcel_Reader_Exception $e) {
$out['err'] = 1;
$out['msg'] = $e->getMessage();
}
} else {
$out['err'] = 1;
$out['msg'] = 'Не нашли файл';
}
}
return $out;
}
/**
* Запись и получение из кэша результата проверки
* @param $file (string)
* @param $data (array)
* @return array|mixed
*/
function file_check_cache($file,$data=array()){
$out=array();
if(count($data)){//Сохраняем
file_put_contents($file,json_encode($data,JSON_UNESCAPED_UNICODE));
}else{
if(file_exists($file)){
$out = json_decode(file_get_contents($file),1);
}
}
return $out;
}
/**
* Проверка 1С с базой ЭИОС
* @param $file
* @return array|mixed
*/
function file_check($file){
$out = array();
$file_cur = $this->DIRupload.'/'.$this->DIRstudents.'/'.$file;
$pi = pathinfo($file_cur);
$file_cache = $pi['dirname'].'/'.$pi['filename'].'_checks.json';
$cache = $this->file_check_cache($file_cache);
//удалим файлы результатов обработки!
$file_double = $pi['dirname'].'/'.$pi['filename'].'_report_double.csv';
if(file_exists($file_double)) unlink($file_double);
$file_change = $pi['dirname'].'/'.$pi['filename'].'_report_change.csv';
if(file_exists($file_change)) unlink($file_change);
if(!count($cache)) {//Если нет кэша проверяем
$out['file'] = $file_cur;
$dan = $this->file_parse_JSON('get', $out);
if (!$dan['err']) {
$out = $dan['data'];
$out['err'] = 0;
foreach ($out['items'][0] as $k => $data) {
$out['items'][0][$k]['check'] = $this->student_check($data);
}
$this->file_check_cache($file_cache, $out);//Записываем в кэш
} else {
$out = $dan;
$out['file'] = $file_cur;
}
}else{
$out = $cache;
}
return $out;
}
/**
* Обновление в ЭИОС данных по группам из 1С
* @param $file
* @return array
*/
function file_update_grupp($file){
$out = array();
$out['err']=0;
$out['msg']='';
$fo = array('Очная'=>'ОФО','Заочная'=>'ЗФО','Очно-заочная'=>'ОЗФО',);
$file_cur = $this->DIRupload.'/'.$this->DIRstudents.'/'.$file;
$pi = pathinfo($file_cur);
//$file_change = $pi['dirname'].'/'.$pi['filename'].'_report_change.csv';
//if(!file_exists($file_change)) {
$file_cache = $pi['dirname'] . '/' . $pi['filename'] . '_checks.json';
$cache = $this->file_check_cache($file_cache);
if (count($cache)) {
//Array(
// [file] => upload/students_xlsx/1_studentovKolledzh.xls
// [items] => Array( [0] => Array(
// [6] => Array(
// [0] => 1 [1] => c96d4d7a-3834-11ed-9365-b42e9988bf39
// [2] => Абазова Дженет Мухарбиевна [3] =>
// [4] => Abazovadzanet@mail.com [5] =>
// [6] => 2 [7] => Ф-21 (2022-2 025)
// [8] => 33.02.01 [9] => Очная форма обучения
// [10] => Бюджетное финансирование [11] => 173-754-501 84
// [12] => +7-964-910-29-24
// [check] => Array( [err] => 0
// [rez] => Array( [0] => Array(
// [id] => 31625 [data_c] => 1671107883
// [data_u] => 1682601476 [email] => Abazovadzanet@mail.com
// [pass] => c8db8e6e6f171bfa85c51d2bbf140f42
// [status] => 0 [fio] => Абазова Дженет Мухарбиевна
// [foto] => [high_school] => 0
// [phone] => +7-964-910-29-24
// [polis] => [snils] => 173-754-501 84
// [guid] => c96d4d7a-3834-11ed-9365-b42e9988bf39
// [grupp] => Array(
// [0] => Array(
// [id] => 2529 [sokr] => колледж Ф-11
// [fo] => ОФО [year_start] => 2022
// [num_zach] => [num_grupp] =>
// )
// )
// )
// )
// [html] => Кол-во:1
// [proc] => 100
// )
//)
foreach ($cache['items'][0] as $k => $student) {
$nocheck = array();
if (isset($student['check']) && count($student['check']['rez'])) {
foreach ($student['check']['rez'] as $kc => $check) {
//if($check['email']!=$student[4])
// $nocheck[]=array('pole'=>'email', 'val_yes'=>$student[4], 'val_no'=>$check['email'], 'id_user'=>$check['id']);
if ($check['fio'] != $student[2])
$nocheck[] = array('pole' => 'fio', 'val_yes' => $student[2], 'val_no' => $check['fio'], 'id_user' => $check['id']);
if ($check['phone'] != $student[12])
$nocheck[] = array('pole' => 'phone', 'val_yes' => $student[12], 'val_no' => $check['phone'], 'id_user' => $check['id']);
if ($check['snils'] != $student[11])
$nocheck[] = array('pole' => 'snils', 'val_yes' => $student[11], 'val_no' => $check['snils'], 'id_user' => $check['id']);
if ($check['guid'] != $student[1])
$nocheck[] = array('pole' => 'guid', 'val_yes' => $student[1], 'val_no' => $check['guid'], 'id_user' => $check['id']);
if ($check['grupp'][0]['sokr'] != $student[7])
$nocheck[] = array('pole' => 'student.id_grupp', 'val_yes' => $student[7], 'val_no' => $check['grupp'][0]['sokr'], 'grupp_id' => $check['grupp'][0]['id'], 'id_user' => $check['id']);
if ($check['grupp'][0]['fo'] != $fo[$student[9]])
$nocheck[] = array('pole' => 'grupp.fo', 'val_yes' => $fo[$student[9]], 'val_no' => $check['grupp'][0]['fo'], 'grupp_id' => $check['grupp'][0]['id'], 'id_user' => $check['id']);
}
}
$student['no_check'] = $nocheck;
//echo '<pre>'.print_r($student,1).'</pre>';
if (count($nocheck) && count($student['check']['rez']) > 1) {//ДВОЙНЫЕ ПОЛЬЗОВАТЕЛИ!
//$this->student_report($cache['file'], $student, 'report_double');
} else {//Есть несоответствия у одного ПОЛЬЗОВАТЕЛЯ!
if (!count($nocheck)) {
//студент одинаковый с 1С
} else {
//$sqls = $this->student_update($nocheck);
////Array([sql] => Array([0] => UPDATE acs_users SET `phone`="+7 (953) 102-20-54",`snils`="166-858-612 24",`guid`="9297b991-22d8-11ed-935b-b42e9988bf39" WHERE id=27171 LIMIT 1)
//if (count($sqls) && isset($sqls['sql'])) {
// foreach ($sqls['sql'] as $ks => $vsql) {
// $rezs = $this->DB->QUR($vsql);
// if (!$rezs['err']) {
// $student['check']['rez'][0]['rep'] = 'ОК';
// $student['check']['rez'][0]['sql'] = $vsql;
// } else {
// $student['check']['rez'][0]['rep'] = $rezs['rep'];
// $student['check']['rez'][0]['sql'] = $vsql;
// }
// }
// //$student['check']['rez'][]['sql'] = '"'.implode('";"'.$sqls).'"';
// //echo '<pre>'.print_r($sqls,1).'</pre>';exit();
// //echo '<pre>'.print_r($student,1).'</pre>';exit();
// $this->student_report($cache['file'], $student, 'report_change');
//}
}
}
if($k>20) echo '<pre>'.print_r($student,1).'</pre>';
if($k>25) exit();
}
//надо удалить файл кэша!!!
//unlink($file_cache);
} else {
$out['err'] = 1;
$out['msg'] = 'Нет файла ' . $file_cache;
}
//}else{
// $out['err'] = 1;
// $out['msg'] = 'Уже отрабатывали такой файл';
//}
return $out;
}
//Обновление в ЭИОС данных из 1С
function file_update($file){
$out = array();
$out['err']=0;
$out['msg']='';
$file_cur = $this->DIRupload.'/'.$this->DIRstudents.'/'.$file;
$pi = pathinfo($file_cur);
$file_change = $pi['dirname'].'/'.$pi['filename'].'_report_change.csv';
if(!file_exists($file_change)) {
$file_cache = $pi['dirname'] . '/' . $pi['filename'] . '_checks.json';
$cache = $this->file_check_cache($file_cache);
if (count($cache)) {
//Array(
// [file] => upload/students_xlsx/1_studentovKolledzh.xls
// [items] => Array( [0] => Array(
// [6] => Array(
// [0] => 1 [1] => c96d4d7a-3834-11ed-9365-b42e9988bf39
// [2] => Абазова Дженет Мухарбиевна [3] =>
// [4] => Abazovadzanet@mail.com [5] =>
// [6] => 2 [7] => Ф-21 (2022-2 025)
// [8] => 33.02.01 [9] => Очная форма обучения
// [10] => Бюджетное финансирование [11] => 173-754-501 84
// [12] => +7-964-910-29-24
// [check] => Array( [err] => 0
// [rez] => Array( [0] => Array(
// [id] => 31625 [data_c] => 1671107883
// [data_u] => 1682601476 [email] => Abazovadzanet@mail.com
// [pass] => c8db8e6e6f171bfa85c51d2bbf140f42
// [status] => 0 [fio] => Абазова Дженет Мухарбиевна
// [foto] => [high_school] => 0
// [phone] => +7-964-910-29-24
// [polis] => [snils] => 173-754-501 84
// [guid] => c96d4d7a-3834-11ed-9365-b42e9988bf39
// [grupp] => Array(
// [0] => Array(
// [id] => 2529 [sokr] => колледж Ф-11
// [fo] => ОФО [year_start] => 2022
// [num_zach] => [num_grupp] =>
// )
// )
// )
// )
// [html] => Кол-во:1
// [proc] => 100
// )
//)
foreach ($cache['items'][0] as $k => $student) {
$nocheck = array();
if (isset($student['check']) && count($student['check']['rez'])) {
foreach ($student['check']['rez'] as $kc => $check) {
//if($check['email']!=$student[4])
// $nocheck[]=array('pole'=>'email', 'val_yes'=>$student[4], 'val_no'=>$check['email'], 'id_user'=>$check['id']);
if ($check['fio'] != $student[2])
$nocheck[] = array('pole' => 'fio', 'val_yes' => $student[2], 'val_no' => $check['fio'], 'id_user' => $check['id']);
if ($check['phone'] != $student[12])
$nocheck[] = array('pole' => 'phone', 'val_yes' => $student[12], 'val_no' => $check['phone'], 'id_user' => $check['id']);
if ($check['snils'] != $student[11])
$nocheck[] = array('pole' => 'snils', 'val_yes' => $student[11], 'val_no' => $check['snils'], 'id_user' => $check['id']);
if ($check['guid'] != $student[1])
$nocheck[] = array('pole' => 'guid', 'val_yes' => $student[1], 'val_no' => $check['guid'], 'id_user' => $check['id']);
}
}
//echo '<pre>'.print_r($student,1).'</pre>';
if (count($nocheck) && count($student['check']['rez']) > 1) {//ДВОЙНЫЕ ПОЛЬЗОВАТЕЛИ!
$this->student_report($cache['file'], $student, 'report_double');
} else {//Есть несоответствия у одного ПОЛЬЗОВАТЕЛЯ!
if (!count($nocheck)) {
//студент одинаковый с 1С
} else {
$sqls = $this->student_update($nocheck);
//Array([sql] => Array([0] => UPDATE acs_users SET `phone`="+7 (953) 102-20-54",`snils`="166-858-612 24",`guid`="9297b991-22d8-11ed-935b-b42e9988bf39" WHERE id=27171 LIMIT 1)
if (count($sqls) && isset($sqls['sql'])) {
foreach ($sqls['sql'] as $ks => $vsql) {
$rezs = $this->DB->QUR($vsql);
if (!$rezs['err']) {
$student['check']['rez'][0]['rep'] = 'ОК';
$student['check']['rez'][0]['sql'] = $vsql;
} else {
$student['check']['rez'][0]['rep'] = $rezs['rep'];
$student['check']['rez'][0]['sql'] = $vsql;
}
}
//$student['check']['rez'][]['sql'] = '"'.implode('";"'.$sqls).'"';
//echo '<pre>'.print_r($sqls,1).'</pre>';exit();
//echo '<pre>'.print_r($student,1).'</pre>';exit();
$this->student_report($cache['file'], $student, 'report_change');
}
}
}
}
//надо удалить файл кэша!!!
unlink($file_cache);
} else {
$out['err'] = 1;
$out['msg'] = 'Нет файла ' . $file_cache;
}
}else{
$out['err'] = 1;
$out['msg'] = 'Уже отрабатывали такой файл';
}
return $out;
}
/**
* Формирвоание файла отчета по обновлению пользователей!
* @param $file
* @param $data
* @return void
*/
function student_report($file,$data,$file_pref='report_double'){
$head = array(0=>'№', 1 => 'GUID',2 => 'ФИО',3 => 'Номер зачетной книжки',4 => 'Эл.почта',5 => 'Факультет',6 => 'Курс',7 => 'Группа',8 => 'Код специальности',9 => 'Форма обучения',10 => 'Основа обучения',11 => 'СНИЛС',12 => 'Телефон',13=>'Система',14=>'Результат ДБ','15'=>'Запрос ДБ');
$pi = pathinfo($file);
$file_report = $pi['dirname'].'/'.$pi['filename'].'_'.$file_pref.'.csv';
if(!file_exists($file_report)) {
file_put_contents($file_report,chr(0xEF).chr(0xBB).chr(0xBF));
file_put_contents($file_report,'"'.implode('";"',$head).'"'.PHP_EOL,FILE_APPEND);
}
$data_eios = $data['check']['rez'];
unset($data['check']);
$data_1c = $data;
file_put_contents($file_report,'"'.implode('";"',$data_1c).'";"1С"'.PHP_EOL,FILE_APPEND);
foreach ($data_eios as $k => $v){
if(!isset($v['grupp'])) $v['grupp'][0]=array('num_zach'=>'','sokr'=>'','fo'=>'');
if(!isset($v['rep'])) $v['rep']='';
if(!isset($v['sql'])) $v['sql']='';
$str = array(0=>$v['id'], 1 => $v['guid'],2 => $v['fio'],3 => $v['grupp'][0]['num_zach'],4 => $v['email'],5 => '',6 => '',7 => $v['grupp'][0]['sokr'],8 => '',9 => $v['grupp'][0]['fo'],10 => '',11 => $v['snils'],12 => $v['phone'],13=>'ЭИОС',14=>$v['rep'],'15'=>$v['sql']);
file_put_contents($file_report,'"'.implode('";"',$str).'"'.PHP_EOL,FILE_APPEND);
}
}
/**
* подготавливаем обновление записи в ЭИОС пользователя
* @return void
*/
function student_update($data){
$out = array();
if(count($data)){
//Array(
// [0] => Array( [pole] => phone [val_yes] => +7 (953) 102-20-54 [val_no] => [id_user] => 27171)
// [1] => Array( [pole] => snils [val_yes] => 166-858-612 24 [val_no] => [id_user] => 27171)
// [2] => Array( [pole] => guid [val_yes] => 9297b991-22d8-11ed-935b-b42e9988bf39 [val_no] => [id_user] => 27171 )
//)
$WH=array();
foreach($data as $k => $v){
if($v['val_yes']!=''){//не затираем то что есть у пользователя!
$WH[$v['id_user']][] = '`'.$v['pole'].'`="'.$this->DB->rescape($v['val_yes']).'"';
}
}
if(count($WH)){
foreach($WH as $id_user => $wh){
$out['sql'][] = 'UPDATE acs_users SET '.implode(',',$wh).' WHERE id='.$id_user.' LIMIT 1';
}
}
}
return $out;
}
function student_check($data){
$out = array();
$out['err']=1;
$out['rez']=array();
$out['html']='Кол-во:0';
$filter=array();
//0 - № п/п 1 - GUID 2 - ФИО 3 - Номер зачетной книжки
//4 - Эл.почта 5 - Факультет 6 - Курс 7 - Группа
//8 - Код специальности 9 - Форма обучения 10 - Основа обучения 11 - СНИЛС
//12 - Телефон
//acs_users: id, data_c, data_u, email, pass, status, fio, foto, high_school, phone, polis, snils, guid
//acs_students: id, data_c, data_u, id_grupp, id_user, status, num_zach, num_grupp, kod_podgotovki, id_newgrupp
//acs_grupp: id, data_c, data_u, specialnost, kurs, sokr, fo, id_teacher, id_facult, year_start
if($data['1']!='') {//проверим по GUID
$filter['where'][] = 'guid="' . trim($data['1']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 100;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if(!count($out['rez'])&&trim($data['2'])!=''){//проверим по ФИО
unset($filter['where']);
$filter['where'][] = 'fio="' . trim($data['2']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 90;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if(!count($out['rez'])&&trim($data['11'])!=''){//проверим по СНИЛС
unset($filter['where']);
$filter['where'][] = 'snils="' . trim($data['11']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 80;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if(count($out['rez'])){
foreach($out['rez'] as $k => $v) {
//Array( [id] => 31625 [data_c] => 1671107883 [data_u] => 1682601476 [email] => Abazovadzanet@mail.com [pass] => c8db8e6e6f171bfa85c51d2bbf140f42 [status] => 0 [fio] => Абазова Дженет Мухарбиевна [foto] => [high_school] => 0 [phone] => +7-964-910-29-24 [polis] => [snils] => 173-754-501 84 [guid] => c96d4d7a-3834-11ed-9365-b42e9988bf39 )
$sql = 'SELECT gr.id,gr.sokr,gr.fo,gr.year_start,st.num_zach, st.num_grupp FROM acs_grupp as gr, acs_students as st WHERE st.id_user='.$v['id'].' AND st.id_grupp=gr.id';
$rez = $this->DB->QUR_SEL($sql);
//$out['rez'][$k]['grupp_sql'] = $sql;
if(!$rez['err']&&$rez['kol']) {
foreach ($rez['rez'] as $key => $val) {
$out['rez'][$k]['grupp'][] = $val;
}
}
}
}
return $out;
}
function json_1c_to_eios($file){
$out = array();
$out1 = array();
$dir = $this->DIRupload.'/'.$this->DIRstudents.'/';
$file_cur = $dir.$file;
$pi = pathinfo($file_cur);
$file_json = $pi['dirname'].'/'.$pi['filename'].'.json';
if(file_exists($file_json)) {
$out['err'] = 1;
$out['rez'] = array();
$out['html'] = 'Кол-во:0';
$filter = array();
$students = json_decode(file_get_contents($file_json),1);
foreach ($students['items'][0] as $k => $data) {
$file_cache = 'upload/students_xlsx/1c_students/'.$data[0].'_'.$data[2].'.json';
if(file_exists('upload/students_xlsx/'.$data[0].'_'.$data[2].'.json')) unlink('upload/students_xlsx/'.$data[0].'_'.$data[2].'.json');
if(!file_exists($file_cache)) {
$out['fio'] = $data[2];
$out['data'] = $data;
//0 - № п/п 1 - GUID 2 - ФИО 3 - Номер зачетной книжки
//4 - Эл.почта 5 - Факультет 6 - Факультет GUID 7 - Курс 8 - Группа
//9 - Группа GUID 10 - Код специальности 11 - Форма обучения 12 - Основа обучения 13 - СНИЛС
//14 - Телефон
//acs_users: id, data_c, data_u, email, pass, status, fio, foto, high_school, phone, polis, snils, guid
//acs_students: id, data_c, data_u, id_grupp, id_user, status, num_zach, num_grupp, kod_podgotovki, id_newgrupp
//acs_grupp: id, data_c, data_u, specialnost, kurs, sokr, fo, id_teacher, id_facult, year_start
if ($data['1'] != '') {//проверим по GUID
$filter['where'][] = 'guid="' . trim($data['1']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 100;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if (!count($out['rez']) && trim($data['2']) != '') {//проверим по ФИО
unset($filter['where']);
$filter['where'][] = 'fio="' . trim($data['2']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 90;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if (!count($out['rez']) && trim($data['13']) != '') {//проверим по СНИЛС
unset($filter['where']);
$filter['where'][] = 'snils="' . trim($data['13']) . '"';
$rez = $this->users_get($filter);
if (count($rez)) {
$out['err'] = 0;
$out['rez'] = $rez['users'];
$out['proc'] = 80;
$out['html'] = 'Кол-во:' . count($rez['users']);
}
}
if (count($out['rez'])) {
foreach ($out['rez'] as $k => $v) {
$sql = 'SELECT gr.id,gr.sokr,gr.fo,gr.year_start,st.num_zach, st.num_grupp FROM acs_grupp as gr, acs_students as st WHERE st.id_user=' . $v['id'] . ' AND st.id_grupp=gr.id';
$rez = $this->DB->QUR_SEL($sql);
//$out['rez'][$k]['grupp_sql'] = $sql;
if (!$rez['err'] && $rez['kol']) {
foreach ($rez['rez'] as $key => $val) {
$out['rez'][$k]['grupp'][] = $val;
}
}
}
}
//$out1[] = array('fio'=>$data,'rez'=>$out['rez']);
file_put_contents($file_cache, json_encode($out, JSON_UNESCAPED_UNICODE));
$this->grupp_create_1c(array('name'=>$data[8],'guid'=>$data[9],'kurs'=>$data[7],'code_spec'=>$data[10],'fo'=>$data[11],'id_grupp'=>0));
$out['err'] = 1;
$out['rez'] = array();
$out['html'] = 'Кол-во:0';
$out['data'] = array();
}
}
}
//теперь смотрим в каждый файл и решаем что делать
$dir_jsons = 'upload/students_xlsx/1c_students/';
$files = scandir($dir_jsons);
foreach($files as $k => $file_json)if($file_json!='.'&&$file_json!='..'){
$file_cur = $dir_jsons.$file_json;
$this->json_1c_to_eios_cheksfile($file_cur);
}
return $out1;
}
/**
* Проверяем файл с ЭИОС и обновляем
* @param $file
* @return void
*/
function json_1c_to_eios_cheksfile($file){
$out=array();
$stud_data = json_decode(file_get_contents($file),1);
if(isset($stud_data['rez'])&&count($stud_data['rez'])) {//проверим данные
$SETs = array();
if ($stud_data['data'][1] != '' && $stud_data['data'][1] != $stud_data['rez'][0]['guid']) $SETs[] = 'guid="' . $stud_data['data'][1] . '"';
if ($stud_data['data'][13] != '' && $stud_data['data'][13] != $stud_data['rez'][0]['snils']) $SETs[] = 'snils="' . $stud_data['data'][13] . '"';
if ($stud_data['data'][14] != '' && $stud_data['data'][14] != $stud_data['rez'][0]['phone']) $SETs[] = 'phone="' . $stud_data['data'][14] . '"';
if(count($SETs)){
$sql = 'UPDATE acs_users SET '.implode(', ',$SETs).' WHERE id='.$stud_data['rez'][0]['id'];
$rez = $this->DB->QUR($sql);
}
}else{//добавим пользователя
$fio1 = explode(' ',mb_strtolower($stud_data['data'][2]));
$fio1_0_fl = mb_substr($fio1[1],0,1);
$insert=false;
$sql = 'SELECT * FROM acs_users WHERE fio LIKE "%'.$fio1[0].' '.$fio1_0_fl.'%" AND guid=""';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
echo $stud_data['data'][0].':'.$stud_data['fio'].PHP_EOL;
print_r($rez);
$update=false;
if(count($rez['rez'])==1){
$rezi = $rez['rez'][0];
if($rezi['snils']!='' && $rezi['snils'] == $stud_data['data'][13]) $update=true;
$phone1 = substr(preg_replace("/[^0-9]/", '', $stud_data['data'][14]),1);
$phone2 = substr(preg_replace("/[^0-9]/", '', $rezi['phone']),1);
if($phone1!=''&&$phone1==$phone2) $update=true;
$fio1_2 = levenshtein($stud_data['data'][2],$rezi['fio']);
if($fio1_2<=3) $update=true;
}
if($update==true){
if ($stud_data['data'][1] != '' && $stud_data['data'][1] != $rezi['guid']) $SETs[] = 'guid="' . $stud_data['data'][1] . '"';
if ($stud_data['data'][2] != '' && $stud_data['data'][2] != $rezi['fio']) $SETs[] = 'fio="' . $stud_data['data'][2] . '"';
if ($stud_data['data'][13] != '' && $stud_data['data'][13] != $rezi['snils']) $SETs[] = 'snils="' . $stud_data['data'][13] . '"';
if ($stud_data['data'][14] != '' && $stud_data['data'][14] != $rezi['phone'] && $stud_data['data'][14]!='<Не заполнен>') $SETs[] = 'phone="' . preg_replace("/[^0-9]/", '', $stud_data['data'][14]) . '"';
if(count($SETs)){
$sql = 'UPDATE acs_users SET '.implode(', ',$SETs).' WHERE id='.$rezi['id'];
echo $sql.PHP_EOL;
//$rez = $this->DB->QUR($sql);
}
}
echo 'GUID: ' . $stud_data['data'][1] . ' ; Email:' . $stud_data['data'][4] . '; Группа: ' . $stud_data['data'][8] . '; Снилс: ' . $stud_data['data'][13] . '; Тел: ' . $stud_data['data'][14] . '; ' . PHP_EOL. PHP_EOL;
}else $insert=true;
$insert==false;
if($insert==true) {
if ($stud_data['data'][4] != '') $email = $stud_data['data'][4];
else {
$email = $this->translit_email($fio1[0]) . '_' . mt_rand(10, 99) . '@student.mkgtu.ru';
}
$pass = $this->gen_password_NEW1();
$sql = 'INSERT INTO acs_users VALUES(0,' . time() . ',' . time() . ',"' . $email . '","' . $this->passw_generate($pass) . '",0,"' . $this->DB->rescape($stud_data['data'][2]) . '","",1,"' . $this->DB->rescape($stud_data['data'][14]) . '","","' . $this->DB->rescape($stud_data['data'][13]) . '","' . $this->DB->rescape($stud_data['data'][1]) . '");';
//echo $sql.PHP_EOL;
$rez = $this->DB->QUR($sql);
if(!$rez['err']){
$tmp = array();
$tmp[] = date('H:i d.m.Y');
$tmp[] = $stud_data['data'][2];
$tmp[] = $stud_data['data'][3];
$tmp[] = $stud_data['data'][5];
$tmp[] = $stud_data['data'][8];
$tmp[] = $stud_data['data'][7];
$tmp[] = $stud_data['data'][10];
$tmp[] = $stud_data['data'][11];
$tmp[] = $pass;
//$out[] = $tmp;
file_put_contents('/home/admin/web/eios.mkgtu.ru/public_html/integration/upload/students_xlsx/inserts.csv','"'.implode('";"',$tmp).'";'.PHP_EOL,FILE_APPEND);
}
}
//print_r($stud_data); //exit();
//Array( [err] => 1
// [rez] => Array()
// [fio] => Ашуров Джамал Айяр
// [data] => Array(
// [0] => 1,020
// [1] => f695edeb-78f7-11ec-9a9c-1c6f6580f598
// [2] => Ашуров Джамал Айяр
// [3] => 18002048
// [4] =>
// [5] => Экологический факультет
// [6] => 3055eae1-5f16-11ec-80b4-a0369f032517
// [7] => Пятый
// [8] => ПБ-51
// [9] => a87f6e88-b994-11ec-937d-f8cc6e370458
// [10] => 20.05.01
// [11] => Очная
// [12] => Бюджетная основа
// [13] => 161-691-700 69
// [14] => 9182229458
// [15] => 7/24/2023 12:00:00 AM
// )
// [proc] => 90
//)
}
//{"err":0, "fio":"Ашинов Адам Юрьевич",
//"rez":[{ "id":"22471",
// "email":"ashinov.adam@bk.ru", "fio":"Ашинов Адам Юрьевич",
// "phone":"+7-961-829-29-30", "polis":"",
// "snils":"146-399-261 00", "guid":"05c6fa6d-4049-11e2-bcec-001cc0873e09",
// "grupp":[{
// "id":"2520","sokr":"ТМО(м)-21","fo":"ОФО",
// "year_start":"2022","num_zach":"","num_grupp":"0"
// }]
//}],
//"data":["1,000", 0 - № п/п
// "05c6fa6d-4049-11e2-bcec-001cc0873e09", 1 - GUID
// "Ашинов Адам Юрьевич", 2 - ФИО
// "22001125", 3 - Номер зачетной книжки
// "", 4 - Эл.почта
// "Технологический факультет", 5 - Факультет
// "d4e5054d-5f00-11ec-80b4-a0369f032517", 6 - Факультет GUID
// "Второй", 7 - Курс
// "ТМО(м)-21", 8 - Группа
// "51e3aee9-b1af-11ec-937c-f8cc6e370458", 9 - Группа GUID
// "15.04.02", 10 - Код специальности
// "Очная", 11 - Форма обучения
// "Бюджетная основа", 12 - Основа обучения
// "146-399-261 00", 13 - СНИЛС
// "", 14 - Телефон
// "10\/1\/2023 12:00:00 AM"],
//"proc":90}
}
function translit_email($st) {
$a = array_merge(array_combine(preg_split('//u', "абвгдеёзийклмнопрстуфхцьыэАБВГДЕЁЗИЙКЛМНОПРСТУФХЦЬЫЭabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"), preg_split('//u', "abvgdeeziyklmnoprstufhc_ieABVGDEEZIYKLMNOPRSTUFHC'IEabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")), array("ж" => "zh", "ч" => "ch", "ш" => "sh", "щ" => "shch", "ъ" => "", "ю" => "yu", "я" => "ya", "Ж" => "Zh", "Ч" => "Ch", "Ш" => "Sh", "Щ" => "Shch", "Ъ" => "", "Ю" => "Yu", "Я" => "Ya"));
$r = preg_split('//u', $st);
$out = '';
foreach ($r as $v) {
if (isset($a[$v])){
$out .= $a[$v];
}
}
return $out;
}
function gen_password_NEW1($length = 8){
$password = '';
$arr = array(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', '*', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', '!', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
);
for ($i = 0; $i < $length; $i++) {
$password .= $arr[random_int(0, count($arr) - 1)];
}
return $password;
}
function passw_generate($passw){
//include_once 'ps01salt.php';
return md5('MkGTU_'.$passw.'$_2010!');
}
/**
* Создание групп из 1С
* @param $data
* @return void
*/
function grupp_create_1c($data){
if($data['fo']=='Очная') $fo='ОФО';
if($data['fo']=='Заочная') $fo='ЗФО';
if($data['fo']=='Очно-заочная') $fo='ОЗФО';
if(date('m')>8) $year_start=date('Y'); else $year_start=date('Y')-1;
//Таблица: acs_grupp_1c: id, name, guid, kurs, code_spec, fo, id_grupp
$sql = 'SELECT id,id_grupp FROM acs_grupp_1c WHERE guid="'.$this->DB->rescape($data['guid']).'"';
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
if($rez['rez'][0]['id_grupp']==0){
}
}else{
$data['id_grupp'] = 0;
$sql = 'SELECT id FROM acs_grupp WHERE sokr="'.$this->DB->rescape($data['name']).'" AND fo="'.$fo.'" AND year_start='.$year_start;
$rez = $this->DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']) $data['id_grupp'] = $rez['rez'][0]['id'];
$sql = 'INSERT INTO acs_grupp_1c VALUES(0,"'.$this->DB->rescape($data['name']).'","'.$this->DB->rescape($data['guid']).'","'.$this->DB->rescape($data['kurs']).'","'.$this->DB->rescape($data['code_spec']).'","'.$this->DB->rescape($data['fo']).'",'.$data['id_grupp'].')';
$rez = $this->DB->QUR($sql);
}
}
/**
* Сканируем все файлы в системе и отображаем
* @return array
*/
function files_scan(){
$out = array();
$dir = $this->DIRupload.'/'.$this->DIRstudents.'/';
$files = scandir($dir);
$cSystem = new class_SYSTEM();
foreach($files as $k => $file) if($file!='.'&&$file!='..'){
$file_cur = $dir.$file;
$tmp=array();
$pi = pathinfo($file_cur);
if($pi['extension']=='xls'||$pi['extension']=='xlsx') {
$tmp['file'] = $file_cur;
$tmp['pi'] = $pi;
$tmp['data_m'] = filemtime($file_cur);
$tmp['data_c'] = filectime($file_cur);
$tmp['size'] = $cSystem->human_filesize(filesize($file_cur));
$file_json = $pi['dirname'].'/'.$pi['filename'].'.json';
$tmp['is_json']=0; if(file_exists($file_json)) $tmp['is_json']=1;
$file_checks = $pi['dirname'].'/'.$pi['filename'].'_checks.json';
$tmp['is_checks']=0; if(file_exists($file_checks)) $tmp['is_checks']=1;
$file_csv = $pi['dirname'].'/'.$pi['filename'].'_report_double.csv';
$tmp['is_csv_double']=0; if(file_exists($file_csv)) {
$tmp['is_csv_double']=1;
$tmp['file_csv_double']=$file_csv;
}
$file_csv = $pi['dirname'].'/'.$pi['filename'].'_report_change.csv';
$tmp['is_csv_change']=0; if(file_exists($file_csv)) {
$tmp['is_csv_change']=1;
$tmp['file_csv_change']=$file_csv;
}
$out[] = $tmp;
}
}
return $out;
}
/**
* Получение пользователей
* @param $filters (array) where(array) where_conc order(array) limit
* @return array
*/
function users_get($filters=array()){
$out = array();
$WHERE = '';
$WHERE_CONC=' AND '; if(isset($filters['where_conc'])) $WHERE_CONC=$filters['where_conc'];
if(isset($filters['where'])){
$tmp=array();
foreach($filters['where'] as $k => $v){
$tmp[] = $v;
}
$WHERE = ' WHERE '.implode($WHERE_CONC,$tmp);
}
$ORDER = '';
if(isset($filters['order'])){
$tmp=array();
foreach($filters['order'] as $k => $v){
$tmp[] = $v;
}
$ORDER = ' ORDER BY '.implode(', ',$tmp);
}
$LIMIT = '';
if(isset($filters['limit'])){
$LIMIT = $filters['limit'];
}
$sql = 'SELECT * FROM '.$this->TUsers.$WHERE.$ORDER.$LIMIT;
$rez = $this->DB->QUR_SEL($sql);
//$out['sql'] = $sql;
if(!$rez['err']&&$rez['kol']) {
foreach ($rez['rez'] as $key => $val) {
$out['users'][] = $val;
}
}
return $out;
}
}