2024-09-27 15:28:55 +05:00
< ? php
//Получаем список пользователей
$users = DB :: getAll ( " SELECT * FROM `users` WHERE `status`=? " , 1 );
$smarty -> assign ( 'users' , $users );
//Ставим задачу
if ( $_POST ){
if ( $_FILES ){
@ mkdir ( " files " , 0777 );
@ mkdir ( " files/task " , 0777 );
$fm = rand ( 10000 , 99999 ) . '_' . $_FILES [ 'doc' ][ 'name' ];
copy ( $_FILES [ 'doc' ][ 'tmp_name' ], 'files/task/' . $fm );
}
$array [ 'doc' ] = $fm ;
$array [ 'srok' ] = $_POST [ 'srok' ];
$array [ 'target_user' ] = $_POST [ 'target_user' ];
$array [ 'prioritet' ] = $_POST [ 'prioritet' ];
$j = core :: j ( $array );
DB :: add ( " INSERT INTO `content` (`txt`, `json`, `content_type`, `t`, `user`) VALUES (?,?,?,?,?) " , [ $_POST [ 'txt' ], $j , 2 , time (), $_SESSION [ 'user_id' ]]);
header ( 'Location: /task/' );
}
//Показываем мои задачи
$mytask = DB :: getAll ( " SELECT * FROM `content` WHERE `content_type`=? AND `status`<>? AND `json` LIKE '% \" target_user \" : \" " . $_SESSION [ 'user_id' ] . " \" %' " , [ 2 , 0 ]);
$c = count ( $mytask );
for ( $i = 0 ; $i < $c ; $i ++ ){
$mytask [ $i ][ 'array' ] = core :: j ( $mytask [ $i ][ 'json' ]);
$mytask [ $i ][ 'avtor' ] = DB :: getRow ( " SELECT * FROM `users` WHERE `id`=? " , $mytask [ $i ][ 'user' ]);
$mytask [ $i ][ 'd' ] = date ( " d.m.Y " , $mytask [ $i ][ 't' ]);
}
$smarty -> assign ( 'mytask' , $mytask );
2024-09-30 08:50:06 +05:00
unset ( $mytask );
//Показываем задачи поставленные людям
$mytask = DB :: getAll ( " SELECT * FROM `content` WHERE `content_type`=? AND `status`<>? AND `user`=? " , [ 2 , 0 , $_SESSION [ 'user_id' ]]);
$c = count ( $mytask );
for ( $i = 0 ; $i < $c ; $i ++ ){
$mytask [ $i ][ 'array' ] = core :: j ( $mytask [ $i ][ 'json' ]);
$mytask [ $i ][ 'avtor' ] = DB :: getRow ( " SELECT * FROM `users` WHERE `id`=? " , $mytask [ $i ][ 'user' ]);
$mytask [ $i ][ 'd' ] = date ( " d.m.Y " , $mytask [ $i ][ 't' ]);
}
$smarty -> assign ( 'mytasksend' , $mytask );
2024-09-27 15:28:55 +05:00
?>