X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fattachments.php;h=e92276ed87fd2934596504ff9147e178394a4542;hb=efa2530a7c385a329c3fc76f4560b28ba97c3efe;hp=b75c58bf280fa5c5bffe9ec735eb268446f4787a;hpb=264c09696d65efe4532c197f317162daf8c24f32;p=fa-stable.git diff --git a/admin/attachments.php b/admin/attachments.php index b75c58bf..e92276ed 100644 --- a/admin/attachments.php +++ b/admin/attachments.php @@ -19,6 +19,7 @@ include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/admin/db/attachments_db.inc"); +include_once($path_to_root . "/admin/db/transactions_db.inc"); if (isset($_GET['vw'])) $view_id = $_GET['vw']; @@ -35,10 +36,7 @@ if ($view_id != -1) $type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream'; header("Content-type: ".$type); header('Content-Length: '.$row['filesize']); - //if ($type == 'application/octet-stream') - // header('Content-Disposition: attachment; filename='.$row['filename']); - //else - header("Content-Disposition: inline"); + header("Content-Disposition: inline"); echo file_get_contents(company_path(). "/attachments/".$row['unique_name']); exit(); } @@ -68,7 +66,7 @@ if ($download_id != -1) } $js = ""; -if ($use_popup_windows) +if ($SysPrefs->use_popup_windows) $js .= get_js_open_window(800, 500); page(_($help_context = "Attach Documents"), false, false, "", $js); @@ -81,10 +79,16 @@ if (isset($_GET['trans_no'])) if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { - if (!$_POST['trans_no']) - display_error(_("No transaction has been selected.")); - elseif ($Mode == 'ADD_ITEM' && (!isset($_FILES['filename']) || $_FILES['filename']['size'] == 0)) + if (!transaction_exists($_POST['filterType'], $_POST['trans_no'])) + display_error(_("Selected transaction does not exists.")); + elseif ($Mode == 'ADD_ITEM' && !isset($_FILES['filename'])) display_error(_("Select attachment file.")); + elseif ($Mode == 'ADD_ITEM' && ($_FILES['filename']['error'] > 0)) { + if ($_FILES['filename']['error'] == UPLOAD_ERR_INI_SIZE) + display_error(_("The file size is over the maximum allowed.")); + else + display_error(_("Select attachment file.")); + } else { //$content = base64_encode(file_get_contents($_FILES['filename']['tmp_name'])); $tmpname = $_FILES['filename']['tmp_name']; @@ -93,27 +97,32 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') if (!file_exists($dir)) { mkdir ($dir,0777); - $index_file = ""; + $index_file = "activate('_page_body'); $Mode = 'RESET'; } @@ -158,7 +169,7 @@ function viewing_controls() start_row(); systypes_list_cells(_("Type:"), 'filterType', null, true); if (list_updated('filterType')) - $selected_id = -1;; + $selected_id = -1; end_row(); end_table(1); @@ -250,4 +261,3 @@ end_form(); end_page(); -?>