Page 1 of 2

Attachments list

Posted: Mon Apr 14, 2014 5:45 pm
by GabrieleV
With this report you can see all attachments inserted in MMEX.
Currently links to open directly attachment on filename works only if you use a custom directory as attachments archive.
Attachment list.grm
SQL

Code: Select all

SELECT A.reftype AS Type, A.refid AS Nr,
C.transdate||' | '||AC.AccountName||' | '|| CURR.pfx_symbol||round(C.Transamount, 2) ||CURR.sfx_symbol AS Reference,
A.description AS Description, A.filename AS File,
(SELECT infovalue FROM infotable_v1 WHERE infoname = 'ATTACHMENTSFOLDER:Win' COLLATE NOCASE) AS BasePath,
"\"||A.reftype||"\"||A.filename AS FilePath, '' AS BasepathLUA
FROM attachment_v1 A
    INNER JOIN checkingaccount_v1 C ON C.transid = A.refid
    INNER JOIN accountlist_v1 AC ON C.accountid = AC.accountid
    INNER JOIN currencyformats_v1 CURR ON AC.currencyid = CURR.currencyid
ORDER BY A.reftype,A.refid,A.filename;
LUA

Code: Select all

function get_base_path (BasePath,FilePath)
    if BasePath == "DOCSDIR" then
    	BasePath = "#";
    elseif BasePath == "MMEXDIR" then
    	BasePath = "#";
    elseif BasePath == "DBDIR" then
    	BasePath = "#";
    else
    	BasePath = "file:///" .. BasePath .. FilePath;
	end
    return BasePath;
end

function handle_record(record)
    record:set("BasepathLUA", get_base_path(record:get("BasePath"),record:get("FilePath")));
end
TEMPLATE

Code: Select all

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http - equiv = "Content-Type" content = "text/html" />
    <title><TMPL_VAR REPORTNAME></title>
    <script src = "Chart.js"></script>
    <link href = "master.css" rel = "stylesheet" />
</head>
<body>
<div class = "container">
<h3><TMPL_VAR REPORTNAME></h3>
<TMPL_VAR TODAY><hr>
<div class = "row">
<div class = "col-xs-2"></div>
<div class = "col-xs-8">
<table class = "table">
<thead>
    <tr>
        <th>Type</th>
        <th>Nr</th>
        <th>Reference</th>
        <th>Description</th>
        <th>File</th>
    </tr>
</thead>
<tbody>
    <TMPL_LOOP NAME=CONTENTS>
        <tr>
        <td><TMPL_VAR "Type"></td>
        <td class = "text-right"><TMPL_VAR "Nr"></td>
        <td><TMPL_VAR "Reference"></td>
        <td><TMPL_VAR "Description"></td>
	<td><a href="<TMPL_VAR "BasePathLUA">"><TMPL_VAR "File"></a></td>
        </tr>
    </TMPL_LOOP>
</tbody>
</table>
</div>
<TMPL_LOOP ERRORS>
    <hr>
    <TMPL_VAR ERROR>
</TMPL_LOOP>
</div>
</div>
</body>
<script>
<!--Format numbers-->
    function currency(n) { n = parseFloat(n); return isNaN(n) ? 0 : n.toFixed(2); }
    var elements = document.getElementsByClassName("money, text-right");
    for (var i = 0; i < elements.length; i++)
        { elements[i].innerHTML = "<TMPL_VAR PFX_SYMBOL>" + currency(elements[i].innerHTML) + "<TMPL_VAR SFX_SYMBOL>"; }
</script>
</html>

Re: Attachments list

Posted: Mon Apr 14, 2014 7:13 pm
by Nikolay

Code: Select all

    <script src = "Chart.js"></script>
not needed

Re: Attachments list

Posted: Mon Apr 14, 2014 9:03 pm
by GabrieleV
Yes, it was auto-added by template..

Re: Attachments list

Posted: Tue Apr 15, 2014 8:24 am
by guanlisheng
Cool and could we add it to github as well.

Re: Attachments list

Posted: Wed Apr 23, 2014 4:16 pm
by elwood1229
This report is helpful and working well except for one thing. While it lists all of the transactions that have attachments, when I click on the hyperlink that I assume is designed to open the attachment, it comes up with a blank screen with only a small box with an "x" in it in the upper left hand corner. I do have the MMEX database in a folder called "MoneyManagerEx Mobile" which is located in my DropBox account. That may be causing the problem but I wasn't sure whether/how to change the path since it seems to be generated automatically in the Lua and I didn't want to mess anything up. Any directions would be appreciated.

I was also wondering if it would be possible somehow to make it possible to click on the transaction number (or something) and have it open the transaction associated with the attachment?

Thanks for your work.

Elwood

Re: Attachments list

Posted: Wed Apr 23, 2014 6:01 pm
by Nikolay
Please check Options - Attachmens tab settins.

Re: Attachments list

Posted: Wed Apr 23, 2014 6:28 pm
by elwood1229
Thank you for the response. I did check the settings under Options > Import/Export > Attachment Settings. I did in fact have the wrong folder specified but even after correcting that, it is still not working. When I selected the "systems subdirectory" option, nothing happens when I click on a link on the Attachment report. When I select "Money Manager Directory" option and click on a link, nothing happens. When I select "Database file directory" option, nothing happens--well, technically it scrolls back to the top of report. When I select "User Defined" option, and dig down to the "attachments\Transactions" folder (where I can see the attached pdfs in file explorer), and click on a link I get a page that shows "This page can't be displayed." I am not sure where I am going wrong on this.

Elwood

Re: Attachments list

Posted: Wed Apr 23, 2014 6:40 pm
by GabrieleV
As I've written, report currently works only if you choose "User Defined".

In "User Defined" you have to set the path to top-level folder, so in your example:
dig down to the "attachments\Transactions" folder
you have to choose "attachments" folder, not "Transaction" folder that is auto-created by MMEX.

Please take attenction modifying attachment folder if you have already inserted attachments because,
if not well managed, it can breaks expected behaviour and file structure.

Re: Attachments list

Posted: Wed Apr 23, 2014 7:24 pm
by elwood1229
Thanks again. I actually had the path set to the "Attachment's folder originally. I reset the path to that folder and am back to getting a blank screen with a small black box with an "x" in it at the upper left corner. I don't know if it will help, but I am attaching a screen shot with the option dialog open showing the path as it is set; behind the option dialog is the report screen after clicking on a link in the attachment report (path is set as shown in the options dialog). Sorry to be difficult, but I don't see what is wrong. BTW, when I click on the paper clip icon on a transaction with a file attached, the attachment pdf opens correctly with this setting.

Elwood

Re: Attachments list

Posted: Wed Apr 23, 2014 7:50 pm
by GabrieleV
Ok, attachments settings are correct.

If you right-click somewhere in the report and choose "view source" what did you see as href?

Re: Attachments list

Posted: Wed Apr 23, 2014 8:55 pm
by elwood1229
Alright, when I go to the Attachments List report, click on the hyperlink for any of the transactions listed there and it opens to the report window (like the one shown underneath the options dialog in the photo I attached to the previous message) and then right click on that report window, "View Source" is grayed out and clicking on "View Source" does nothing. I used to develop web pages, so I know how this works and it acts as if there is no web page there at all--no source code shows. The same is true even when I try to right click on the box at the upper left hand corner.

Elwood

Re: Attachments list

Posted: Thu Apr 24, 2014 4:55 pm
by GabrieleV
Hi, right-click directly when it's shown the attachment list, before click any attachment and see blank screen.

Re: Attachments list

Posted: Thu Apr 24, 2014 9:17 pm
by elwood1229
I assume this is what you are looking for: <a href="file:///C:\Users\Hank\Dropbox\apps\MoneyManagerEx Mobile\Attachments\Transaction\Transaction_291_Attach1.pdf">Transaction_291_Attach1.pdf</a>

If it is not, let me know and I will try to locate it for you.

Elwood

Re: Attachments list

Posted: Thu Apr 24, 2014 10:13 pm
by GabrieleV
In Windows, does the file "C:\Users\Hank\Dropbox\apps\MoneyManagerEx Mobile\Attachments\Transaction\Transaction_291_Attach1.pdf" exist and is correct?

Re: Attachments list

Posted: Fri Apr 25, 2014 4:40 am
by elwood1229
GabrieleV wrote:In Windows, does the file "C:\Users\Hank\Dropbox\apps\MoneyManagerEx Mobile\Attachments\Transaction\Transaction_291_Attach1.pdf" exist and is correct?
Yes, I followed the path in Windows Explorer down to the file level and it is correct. The file listed does exist and when I double click on it it opens in Acrobat Reader as expected. The only thing I see that is unusual, is that in the Windows Explorer file tree (in the left hand panel), there is a small lock icon slightly to the left of the folder icon next to the "Hank" folder. I suspect it has to do with sharing but I am not sure why this would affect what we are trying to do. I would have thought it would have only prevented other computers on our network from being able to access the contents of that directory.

Re: Attachments list

Posted: Sun Apr 27, 2014 7:47 pm
by GabrieleV
If file path is correct unfortunately I can't help you.
I've tested on 3 different machine and I always see request to open\download PDF file..

Re: Attachments list

Posted: Sun Apr 27, 2014 10:22 pm
by elwood1229
Would the fact that the needed folder is in Dropbox create a problem for this report?

I went through and triple checked the path and I can see no problems with it whatsoever. The only thing that is a little unusual is that I set it up in a Dropbox folder, though it is a subfolder of where the database resides. I wouldn't mind testing it on another folder located my computer, but due to your warning to be careful to not do anything that might create a problem with the attachment folder I am hesitant to do so.

As I mentioned previously, when clicking on the folder clip icon on a transaction that has a file attached, the PDF opens immediately. This report is the only place where there is a problem.

Elwood

Re: Attachments list

Posted: Mon Apr 28, 2014 7:11 pm
by GabrieleV
Could you try to disable Adobe PDF Reader in Internet Explorer?
http://helpx.adobe.com/acrobat/using/di ... at-xi.html

I don't use Adobe Reader so I haven't that extension on my PCs

Re: Attachments list

Posted: Mon Apr 28, 2014 7:24 pm
by elwood1229
Yes, I can do that but it will be a couple of days as I am out of town.

Elwood

Re: Attachments list

Posted: Wed Apr 30, 2014 10:22 pm
by elwood1229
I went into IE and disabled the Acrobat Reader plugin as shown in the link you included. Unfortunately, I still have the same issue when trying to view an attachment from the Attachment List report. I rebooted, checked IE to make sure Reader was still disabled and I still get the same error in MMEX. If you have any other suggestions, I would be glad to try them.

Elwood

Re: Attachments list

Posted: Thu May 01, 2014 8:51 am
by GabrieleV
What version of Windows\IE are you using?

Re: Attachments list

Posted: Fri May 02, 2014 2:48 am
by elwood1229
I am using IE 11.0.9 and MS Windows 7 Home Premium with all current updates.

Elwood

Re: Attachments list

Posted: Fri May 02, 2014 9:02 pm
by elwood1229
I downloaded the mmex_svn6475_x64_portable file that just became available and had the same problem with the Attachment List report. Just for the heck of it, I then downloaded the mmex_svn6475_win32_portable version of the latest release and with it, the Attachment List report works as desired. When I click on a link in that report, the attachment PDF opens as it is supposed to. I did double check the system info on my computer (control panel > system and security > system) and it does indeed show that I am running the 64-bit version of Windows 7 with Service Pack 1. I always assumed that "mmex_svn6475_x64_portable" meant it was the 64-bit version. Is that an incorrect assumption? Other than the Attachment List report, that version runs fine on my system. For the time being, at least, I will run mmex_svn6475_win32_portable.

Elwood

Re: Attachments list

Posted: Sat May 03, 2014 8:40 am
by GabrieleV
It's correct: x64 means 64 bit version. Anyway, at least with small DB, there isn't a real difference between 32 and 64 bit version.
I will try to reproduce the problem, but all my machine are 64bit and with x64 version of MMEX I haven't any problem..

Re: Attachments list

Posted: Wed May 14, 2014 11:41 am
by avma

Hi,

I pretty much have the same issue...I set the path as described but keep getting the same list of \MoneyManagerEX\res and its content files, although the attachment documents do exist in the asset folder

Thanks
Avi.

p.s im on win8.1 64