// page title - if undefined the site title is displayed by default
$page_title = 'Attachments';
// upload attachment
if (isset($_POST['upload_attachment']) && $_POST['upload_attachment'] == 'upload') {
    $upload_status = insert_attachment();
    if (is_int($upload_status)) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=attachments&attachment_id=' . $upload_status);
    } else {
        $error = $upload_status;
    }
}
// update attachment details
if (isset($_POST['update']) && $_POST['update'] == 'update details') {
    $attachment_id = (int) $_POST['attachment_id'];
    if (!empty($attachment_id)) {
        $update_status = update_attachment($attachment_id);
        if ($update_status == true) {
            header('Location: ' . $url);
        } else {
            $error = $update_status;
        }
    }
}
// insert attachment details -  for rogue attachments
if (isset($_POST['insert']) && $_POST['insert'] == 'insert details') {
    $insert_status = insert_attachment_details($_POST);
    if (is_int($insert_status)) {
        header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=attachments&attachment_id=' . $insert_status);
    } else {
        $error = $insert_status;
    }
Example #2
0
                exit;
            }
            $unique_name = $row['unique_name'];
            if ($filename && file_exists($dir . "/" . $unique_name)) {
                unlink($dir . "/" . $unique_name);
            }
        } else {
            $unique_name = uniqid('');
        }
        //save the file
        move_uploaded_file($tmpname, $dir . "/" . $unique_name);
        if ($Mode == 'ADD_ITEM') {
            add_attachment($_POST['filterType'], $_POST['trans_no'], $_POST['description'], $filename, $unique_name, $filesize, $filetype);
            display_notification(_("Attachment has been inserted."));
        } else {
            update_attachment($selected_id, $_POST['filterType'], $_POST['trans_no'], $_POST['description'], $filename, $unique_name, $filesize, $filetype);
            display_notification(_("Attachment has been updated."));
        }
    }
    refresh_pager('trans_tbl');
    $Ajax->activate('_page_body');
    $Mode = 'RESET';
}
if ($Mode == 'Delete') {
    $row = get_attachment($selected_id);
    $dir = company_path() . "/attachments";
    if (file_exists($dir . "/" . $row['unique_name'])) {
        unlink($dir . "/" . $row['unique_name']);
    }
    delete_attachment($selected_id);
    display_notification(_("Attachment has been deleted."));