'.print_r($_POST,1).''; //$debug .= '
'.print_r($_FILES,1).'
'; $fio = htmlspecialchars(addslashes($_POST['fio'])); $tel = htmlspecialchars(addslashes($_POST['tel'])); $pred_obraz = $_POST['pred_obraz']; $obraz_uchr = htmlspecialchars(addslashes($_POST['obraz_uchr'])); $diplom_seriya = htmlspecialchars(addslashes($_POST['diplom_seriya'])); $diplom_nomer = htmlspecialchars(addslashes($_POST['diplom_nomer'])); if($_POST['diplom_data']!=''){ $t=explode('.',$_POST['diplom_data']); $diplom_data = mktime(0,0,0,$t[1],$t[0],$t[2]); }else $diplom_data = time(); $pret_naprav = $_POST['pret_naprav']; $pret_kurs = $_POST['pret_kurs']; $pret_fo = $_POST['pret_fo']; if(isset($_POST['status'])) $status = '-1'; else $status=0; $pret_format = htmlspecialchars(addslashes($_POST['pret_format'])); if($perevod==1) $tperevod=1; elseif ($perevod==2) $tperevod = 2; else $tperevod=0; } $id_studentzayavks=0; if(isset($_POST['iup_student_save'])||isset($_POST['perevod_student_save'])){ $sql = 'INSERT INTO `'.$TB['iup_studentzayavks'].'` VALUES (0,'.time().','.$_SESSION['user']['id'].',"'.$fio.'","'.$pred_obraz.'","'.$obraz_uchr.'","'.$diplom_seriya.'","'.$diplom_nomer.'",'.$diplom_data.',"'.$pret_naprav.'","'.$pret_kurs.'","'.$pret_fo.'",'.$status.',"'.$tel.'","'.$pret_format.'",'.$tperevod.')'; $rez = $DB->QUR($sql); //echo '
'.print_r($rez,1).'
'; if(!$rez['err']){ $id_studentzayavks = mysql_insert_id(); send_email_iup($id_studentzayavks); $msg['msg'][]='Ваша заявка создана!'; }else{ $msg['err'][]='Ваша заявка не создана! Ошибка БД!!!'; } } if(isset($_POST['iup_student_edit'])||isset($_POST['perevod_student_edit'])){ $id = (int)$_POST['id']; $sql = 'UPDATE `'.$TB['iup_studentzayavks'].'` SET data_c='.time().',fio="'.$fio.'",pred_obraz="'.$pred_obraz.'",obraz_uchr="'.$obraz_uchr.'",diplom_seriya="'.$diplom_seriya.'",diplom_nomer="'.$diplom_nomer.'",diplom_data='.$diplom_data.',pret_naprav="'.$pret_naprav.'",pret_kurs="'.$pret_kurs.'",pret_fo="'.$pret_fo.'",status='.$status.',tel="'.$tel.'",pret_format="'.$pret_format.'" WHERE id='.$id.' AND id_user='.$_SESSION['user']['id'].' LIMIT 1'; $rez = $DB->QUR($sql); if($rez){ $msg['msg'][]='Ваша заявка отредактирована!'; $id_studentzayavks = $id; if(isset($_POST['del_file'])){foreach($_POST['del_file'] as $fid => $val){ $sql = 'SELECT * FROM '.$TB['iup_studentzayavks_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$fid.''; $rez = $DB->QUR_SEL($sql); if($rez){ $val = $rez[1]; unlink($val['file']); $rez = $DB->QUR_SEL('DELETE FROM '.$TB['iup_studentzayavks_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$fid.''); $msg['err'][]='Файл удален!'; }else{ $msg['err'][]='Файл не найден в базе данных.'; } }} } } if($id_studentzayavks){ //обходим загруженные файлы foreach($prilogens as $key => $val){ if(isset($_FILES[$val['name']])){ foreach($_FILES[$val['name']]['tmp_name'] as $k => $v){ if($v!=''){//загружаем файл $dir_dest = 'upload/iup/'.$_SESSION['user']['id'].'/'; if(!file_exists($dir_dest)) mkdir($dir_dest); $fil = $_FILES[$val['name']]['name'][$k]; $t = explode('.',$fil); $ext = $t[count($t)-1]; unset($t[count($t)-1]); $fn = implode('.',$t); $uploadfile = $dir_dest . basename(translit($fn).'.'.$ext); //$debug .= $v.' - '.$uploadfile.'
'; //if (move_uploaded_file($v, $uploadfile)) { if ($SYSTEMclass->sysUPLOAD($v, $uploadfile)) { //echo "Файл корректен и был успешно загружен.\n"; $sql1 = 'INSERT INTO `'.$TB['iup_studentzayavks_files'].'` VALUES (0,'.time().','.$_SESSION['user']['id'].','.$id_studentzayavks.',"'.$val['title'].'","'.$uploadfile.'",1);'; $rez1 = $DB->QUR($sql1); if($rez1){ $msg['msg'][]='Файл загружен и сохранен в БД!'; }else{ $msg['err'][]='Файл загружен и не сохранен в БД!'; } } else { $msg['err'][]='Файл не загружен!'; } } } } } $des = 'show'; } if($des == 'del'){ $id = (int)$_GET['id']; $sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$id.' AND status=-1'; $rez = $DB->QUR_SEL($sql); if($rez){ $val = $rez[1]; $sql = 'SELECT id,file FROM '.$TB['iup_studentzayavks_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$val['id'].' ORDER BY data_c'; $rez = $DB->QUR_SEL($sql); if($rez){foreach($rez as $k => $v)if($k){ unlink($v['file']); $rez = $DB->QUR_SEL('DELETE FROM '.$TB['iup_studentzayavks_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$v['id'].''); }} $rez = $DB->QUR_SEL('DELETE FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$id.' AND status=-1'); $des = 'show'; } } if($des == 'add'){ $napravlenie = iup_get_napravlenie(); $smarty->assign('napravlenie',$napravlenie); $zayavka['fio'] = $_SESSION['user']['fio']; $smarty->assign('zayavka',$zayavka); } if($des == 'edit'){ $id = (int)$_GET['id']; $sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND id='.$id.' AND (status=-1 OR status=-2)'; $rez = $DB->QUR_SEL($sql); if($rez){ $val = $rez[1]; $val['data_c'] = date('H:i:s d.m.Y',$val['data_c']); $val['diplom_data'] = date('d.m.Y',$val['diplom_data']); $sql = 'SELECT * FROM '.$TB['iup_studentzayavks_files'].' WHERE id_user='.$_SESSION['user']['id'].' AND id_studentzayavks='.$val['id'].' ORDER BY data_c'; $rez = $DB->QUR_SEL($sql); if($rez){foreach($rez as $k => $v)if($k){ $v['data_c'] = date('H:i:s d.m.Y',$v['data_c']); $val['files'][]=$v; }} $sql = 'SELECT * FROM '.$TB['iup_statuses'].' WHERE id_studentzayavks='.$val['id'].' ORDER BY data_c DESC'; $rez = $DB->QUR_SEL($sql); if($rez){foreach($rez as $k => $v)if($k){ $v['data_c'] = date('H:i:s d.m.Y',$v['data_c']); $val['statuses'][]=$v; }} $zayavka = $val; $napravlenie = iup_get_napravlenie(); $smarty->assign('napravlenie',$napravlenie); $smarty->assign('zayavka',$zayavka); }else{ $des = 'show'; } } if($des == 'show'){ $zayavks=array(); if($perevod==0) $sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND perevod=0 ORDER BY data_c DESC'; elseif ($perevod==2) $sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND perevod=2 ORDER BY data_c DESC'; else $sql = 'SELECT * FROM '.$TB['iup_studentzayavks'].' WHERE id_user='.$_SESSION['user']['id'].' AND perevod=1 ORDER BY data_c DESC'; $rez = $DB->QUR_SEL($sql); //echo $sql.'
'.print_r($rez,1).'
'; if($rez){ foreach($rez as $key => $val)if($key){ $val['data_c'] = date('H:i:s d.m.Y',$val['data_c']); $zayavks[] = $val; } } $smarty->assign('zayavks',$zayavks); } $smarty->assign('page',$page); $smarty->assign('perevod',$perevod); $smarty->assign('des',$des); $smarty->assign('debug',$debug); $smarty->assign('prilogens',$prilogens); $smarty->assign('zd_students',$zd_students); $smarty->assign('msg',$msg); $maincontent = $smarty->fetch('tpl_iup_main.html');