0 votes

Dears,

I would like to have a customized window in Efficy 2014 that shows documents and its attachments as sub-list (with check box to choose the whole document or specific attachment) as in the snapshot below.

enter image description here

have any one done something similar? what function tags and grid columns definitions are needed?

Any suggestions or examples are welcomed :)

Thank you.
Best Regards.

asked in Efficy/ Client side by (559 points)

2 Answers

0 votes
Best answer

Ammar I think you should have something like that for the second RunQuery

<#repeat>
    <tr>
        <td class="text-center"><input type="checkbox" name="CheckRec_<#F=K_DOCUMENT>" title="<%GetLabel('Select Record')%>"></td>
        <td class="<#I=OPENED;0=inactive>"><a href="javascript:View('Docu',<#F=K_DOCUMENT>)" class="DocuCursor"><#F=NAME;emptytext=T></a></td>
    </tr>
    <tr>
        <td colspan="2">
            <%RunQuery(id="AttachmentsDocuQry<#F=K_DOCUMENT>",SQL="SELECT K_FILE,COMMENT FROM <#table name='FILES'> WHERE K_1=:param1",PARAM1="<#F=K_DOCUMENT>")%>
            <%GetDataGrid(query="AttachmentsDocuQry<#F=K_DOCUMENT>", entity=file,columndefs="GridColumns.txt", noheader=true, columns="CHECKBOXATTA,COMMENT{FileName}")%>
        </td>
    </tr>
</#repeat>
answered by (1.8k points)
selected by
Hello stephane,

Thanks, it works well :)

Best Regards.
0 votes

Hello,

This is what i come up so far, and it seems working but the appearance is not well yet for the first record in Document table, as in snapshot
enter image description here

It doesn't appear as the others. Here's the code

    <%SetBookmark()%>
<%LoadMacros('MacroLibrary;MacroDialog;MacroGridtools')%>
<%Macro('Doctype')%>
<html lang="<%GetLanguage(lowercase=T)%>" dir="<%OnLanguage(ar='rtl', else='ltr')%>">
<head>
    <title><%GetLabel('Select Offers')%></title>
    <%Macro('MetaHead')%>
    <%UseStyleSheet(page='%%OnLanguage(ar="efficy-rtl", else="efficy")')%>
    <%UseScript("../lib/js/vendor/modernizr.js", fixedline=T, fixedpath=T)%>
    <script>
        function Loaded() {
            requirejs(['jquery', 'base/commandPublisher', 'misc/grid', 'foundation.dropdown'], function ($, CommandPublisher, Grid) {
                $(document).foundation('dropdown');
                CommandPublisher.start();
                Grid.start();
            });
            <%Macro('DialogModel')%>
        }

        function getID(ChkBxName, Header) {
            var startChar = ChkBxName.indexOf("_");
            var RowName = ChkBxName.substr(startChar+1, ChkBxName.length);
            if(RowName == Header) return -33;
            return parseInt(RowName);
        }

        function getDocuList(){
            var DocuListTmp = [];
            checkBoxesDocu = document.getElementById("DocuForm").querySelectorAll('input[type="checkbox"]');
            if (!checkBoxesDocu) return DocuListTmp;
            for (var i = 0, len = checkBoxesDocu.length; i < len; i++){
                if(checkBoxesDocu[i].checked){
                    var ID = getID(checkBoxesDocu[i].name, "MasterDocu");
                    if (ID == -33) continue;
                    DocuListTmp.push(ID);
                }
            }
            return DocuListTmp;
        }

        function getFileList(){
            var FileListTmp = [];
            checkBoxesFile = document.getElementById("AttaForm").querySelectorAll('input[type="checkbox"]');
            if (!checkBoxesFile) return FileListTmp;
            for (var i = 0, len = checkBoxesFile.length; i < len; i++){
                if(checkBoxesFile[i].checked){
                    var ID = getID(checkBoxesFile[i].name, "MasterAtta");
                    if (ID == -33) continue;
                    FileListTmp.push(ID);
                }
            }
            return FileListTmp;
        }

        function ClickOk() {
            requirejs(['Utils/utils'], function(Util) {
                var DocuList = getDocuList();
                var FileList = getFileList();
                //alert(DocuList.length + " " + FileList.length)
                var scriptFile = "serverscripts/documents.js";
                var scriptFunc = "AddDocu";
                var extraParam = "&DocuList=" + encodeURIComponent(DocuList.toString()) + "&FileList=" + encodeURIComponent(FileList.toString()) + "&UserKey=" + <%GetArgument('UserKey')%> + "&DocuEdit=" + <%GetArgument('DocuEdit')%>;
                if(DocuList.length != 0 || FileList.length != 0) {
                    //alert(extraParam)
                    var Result = Util.runScriptAjax2Synchro(scriptFile, scriptFunc, extraParam);
                    if (Result == "Done")
                        top.close();
                    else
                        alert(Result);
                }
            }); 
        }

        window.onunload = refreshParent;
        function refreshParent() {
        window.opener.location.reload();
    }
    </script>
</head>
<body onload="Loaded()">
<%RunQuery(id="DocumentsQry",SQL="SELECT K_DOCUMENT,NAME FROM <#table name='DOCUMENTS'> WHERE F_TYPE = 1 AND <#SECURITYCLAUSE TABLENAME=DOCUMENTS>",store=111)%>
<%RunQuery(id="AttachmentsQry",SQL="SELECT K_FILE,COMMENT FROM <#table name='FILES'> WHERE K_1 in (SELECT K_DOCUMENT FROM <#table name='DOCUMENTS'> WHERE F_TYPE = 2 AND <#SECURITYCLAUSE TABLENAME=DOCUMENTS>)",store=3698)%>
<h3 class="section-title"><%GetLabel('Select Offer')%></h3>
<div class="row dialog-wrapper">
        <div class="small-3 columns">
            <section>
                <form id="DocuForm">
                    <table class="data-grid" data-channel="entitylist/grid">
                        <%GetDataGrid(query="DocumentsQry", entity=docu, TemplateText=|
                            <tr>
                                <th class="text-center nowrap"><input type="checkbox" name="MasterDocu" onclick="CheckAllRecords(this.checked, true, 'DocuForm')" title="<%GetLabel('Select all Records')%>"></th>
                                <th class="text-start nowrap"><%GetLabel("Document Name")%></th>
                            </tr>
                            <#repeat>
                                <tr>
                                    <td class="text-center"><input type="checkbox" name="CheckRec_<#F=K_DOCUMENT>" title="<%GetLabel('Select Record')%>"></td>
                                    <td class="<#I=OPENED;0=inactive>"><a href="javascript:View('Docu',<#F=K_DOCUMENT>)" class="DocuCursor"><#F=NAME;emptytext=T></a></td>
                                </tr>
                                <%RunQuery(id="AttachmentsDocuQry<#F=K_DOCUMENT>",SQL="SELECT K_FILE,COMMENT FROM <#table name='FILES'> WHERE K_1=:param1",PARAM1="<#F=K_DOCUMENT>")%>
                                <%GetDataGrid(query="AttachmentsDocuQry<#F=K_DOCUMENT>", entity=file,columndefs="GridColumns.txt", noheader=true, columns="CHECKBOXATTA,COMMENT{FileName}")%>
                            </#repeat>
                        |)%>
                    </table>
                </form>
            </section>
            <h3 class="section-title"></h3>
            <section>
                <form id="AttaForm">
                    <%GetDialogGrid(query="AttachmentsQry", columndefs="GridColumns.txt", entity=file, columns="CHECKBOXATTA,COMMENT{FileName}")%>
                </form>
            </section>
            <section class="form text-center">
                <%Macro("OKButton", $class$="primary tiny", $onclick$="ClickOk()")%>
                <%Macro('CloseButton', $class$='tiny')%>
            </section>
        </div>
    </div>
<%UseScript('scripts/Base.js', fixedline=T)%>
<%UseScript('scripts/Efficy.js', fixedline=T)%>
<%UseScript('custom/Custom.js', fixedline=T)%>
<%UseScript("js/config/require.config.js", fixedpath=T, data-custombase="%%GetCustomBase()")%>
<%Evaluate("%%Macro('RequireConfigCustom')")%>
<%UseScript('../lib/js/vendor/require.js', fixedpath=T, data-main='%%Macro("MainJsModule")', data-custom-main='%%Macro("MainJsModuleCustom")')%>
</body>

Please let me know your advises and opinions.

Thank you.
Best Regards.

answered by (559 points)
1,166 questions
1,424 answers
1,715 comments
325 users