'Файл загружен',
UPLOAD_ERR_INI_SIZE => 'File is too big to upload',
UPLOAD_ERR_FORM_SIZE => 'File is too big to upload',
UPLOAD_ERR_PARTIAL => 'Файл загружен частично',
UPLOAD_ERR_NO_FILE => 'Не загружено ни одного файла',
UPLOAD_ERR_NO_TMP_DIR => 'На сервере отсутсвует временная директорая для загрузки файла',
UPLOAD_ERR_CANT_WRITE => 'Не получилось записать файл на диск',
UPLOAD_ERR_EXTENSION => 'Этот файл нельзя загрузить на этот сервер',
);
}
public static function getDocs($order_id)
{
$res = WebAppRaiserDB::select('war_files', 'order_id', $order_id);
return $res;
}
public static function renderDocsTable($docsList)
{
$docData = array();
if(empty($docsList)){
return '
Нет отправленных документов.
';
}
if(!isset($docsList[0]['category'])){
return 'Неверный формат списка документов.
';
}
foreach($docsList as $docItem) {
$docData[$docItem['category']][] = $docItem;
}
$output = '';
foreach($docData as $category => $category_list){
$output .= '
';
}
$output .= '
';
return $output;
}
public static function getDocument($fid){
global $user;
$agency = User::getUserAgencyID();
$files_dir = self::filesDir();
$res = WebAppRaiserDB::select('war_files', 'fid', $fid);
if(!empty($res)){
$filename = $res[0]['file_name'];
$filepath = $res[0]['file_path'];
$file = $files_dir.$filepath.$filename;
if(file_exists($file)){
if($res[0]['agency'] == $agency){
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: ".mime_content_type($file));
header("Content-Transfer-Encoding: binary");
readfile($file);
exit;
}
else {
die('access denied');
}
}
}
die('file not found');
}
public static function getCategories()
{
$return = array();
$sql = 'SELECT category FROM `war_files` GROUP BY `category`';
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
$return[$row['category']] = $row['category'];
}
return $return;
}
}