2010-03-29 15:39 written by Dmitry Ovchinnikov

An example via screenshot

No image

See full-sized screenshot

2010-03-29 15:42 written Dmitry Ovchinnikov

XML configuration file

<?xml version="1.0" encoding="UTF-8"?>

<data default-send-script="Generate HTML order form">
    <title>ipform: Universal Order Forms</title>
    <author>ipromes Ltd.</author>
    <lines>

        <line>
            <fields>
                <title>
                    <label>Customer data</label>
                </title>

            </fields>
        </line>
        <line>
            <fields>
                <combo-field id="bef">

                    <label>Business Entity Form</label>
                    <items>
                        <item>Corporation, Incorporated</item>
                        <item>General partnership</item>

                        <item>Limited Liability Company (LLC)</item>
                        <item>Limited Liability Limited Partnership (LLLP)</item>
                        <item>Limited Liability Partnership (LLP)</item>
                        <item>Limited Partnership (LP)</item>

                        <item>Professional Limited Liability Company (PLLC)</item>
                        <item>Professional Corporation (PC)</item>
                        <item>Sole proprietorship</item>
                        <item>National Association (N.A.)</item>

                        <item>National Trust and Savings Association</item>
                        <item>Federal Credit Union</item>
                        <item>Federal Savings Bank</item>
                    </items>

                    <value>Limited Liability Company (LLC)</value>
                    <description>A business entity form of the organisation</description>
                </combo-field>
            </fields>
        </line>

        <line>
            <fields>
                <text-field id="org">
                    <label>Organisation name</label>

                    <value>Cat and dog LLC</value>
                    <description>Organisation name</description>
                </text-field>
            </fields>

        </line>
        <line>
            <fields>
                <text-field id="pa">

                    <label>Postal code and address</label>
                    <description>The postal code and address of the organisation</description>
                </text-field>
            </fields>
        </line>

        <line>
            <fields>
                <text-field id="tel">
                    <label>Phone</label>

                </text-field>
                <text-field id="fax">
                    <label>Fax</label>
                </text-field>

            </fields>
        </line>
        <line>
            <fields>
                <text-field id="email">

                    <label>Email</label>
                </text-field>
                <text-field id="web">
                    <label>Website</label>

                </text-field>
            </fields>
        </line>
        <line>
            <fields>
                <text-field id="misc">

                    <label>Additional information</label>
                </text-field>
            </fields>
        </line>
        <line>

            <fields>
                <radiolist-field id="aoi" cols="4">
                    <label>Area of industry</label>

                    <items>
                        <item>Oil</item>
                        <item>Gas</item>
                        <item>Energy</item>

                        <item>Metallurgy</item>
                        <item>Machine-building</item>
                        <item>Instrument-making</item>
                        <item>Food</item>

                        <item>Water</item>
                        <item>Heat</item>
                        <item>the other</item>
                    </items>

                </radiolist-field>
            </fields>
        </line>
        <line>
            <fields>
                <title>

                    <label>The bill</label>
                </title>
            </fields>
        </line>
        <line>

            <fields>
                <table-field id="bill">
                    <label>Device list</label>
                    <min-width> 40  90 140 30  80 110 60 130 130 130 100</min-width>

                    <max-width> 40 120 500 50 100 150 85 160 160 170 300</max-width>
                    <pref-width>40 100 140 40  90 130 75 150 150 155 100</pref-width>
                    <editable>false true false true true false true true true true true</editable>
                    <meta>

                        <title>Device list</title>
                        <author>ipromes Ltd.</author>
                        <lines>
                            <line>
                                <fields>

                                    <title>
                                        <label>Basic data</label>
                                    </title>
                                </fields>
                            </line>

                            <line>
                                <fields>
                                    <int-field id="n1">
                                        <label></label>

                                        <formula>rowIndex + 1</formula>
                                        <properties>
                                            <property>
                                                <key>visible</key>
                                                <bool>false</bool>

                                            </property>
                                        </properties>
                                    </int-field>
                                </fields>
                            </line>
                            <line>

                                <fields>
                                    <combo-field id="type">
                                        <label>Device type</label>
                                        <items>

                                            <item>ipromes-mailer</item>
                                            <item>ipromes-weber</item>
                                            <item>ipromes-controller</item>
                                            <item>ipromes-messenger</item>

                                        </items>
                                    </combo-field>
                                    <text-field id="code">
                                        <label>Device order code</label>

                                        <formula>
                                            code = "ipromes-";
                                            if (type.equals("ipromes-mailer")) code += "M";
                                            else if (type.equals("ipromes-weber")) code += "W";
                                            else if (type.equals("ipromes-controller")) code += "C";
                                            else if (type.equals("ipromes-messenger")) code += "S";
                                            if (gps) code += "G";
                                            code += "1";
                                            if (rf.equals("GSM/GPRS/EDGE")) code +="L01";
                                            else if (rf.equals("3G")) code +="L02";
                                            else if (rf.equals("CDMA")) code +="L03";
                                            else if (rf.equals("Wi-Fi")) code +="L04";
                                            else if (rf.equals("WiMAX")) code +="L05";
                                            if (opt.equals("Character LCD 2x20")) code += "Y01";
                                            else if (opt.equals("Character LCD 2x20 + keyboard 2x3")) code += "Y02";
                                            else if (opt.equals("Character LCD 2x20 + keyboard 5x5")) code += "Y03";
                                            else if (opt.equals("Character LCD 4x20 + keyboard 5x5")) code += "Y04";
                                            else if (opt.equals("Character LCD 4x20 + keyboard 5x5 + video-out 800x600")) code += "Y05";
                                            else if (opt.equals("Video-out 800x600")) code += "Y06";
                                            if (itype.equals("Cable")) code += "Z01";
                                            else if (itype.equals("Terminals")) code += "Z02";
                                            h = new LinkedHashMap();
                                            opts = new String[] {
                                                "1 x RS-485", "1 x RS-232", "1 x Ethernet", "2 x Pt100 AI", "4 x 4-20mA/0-5V AI",
                                                "4 x 12VDC DI", "2 x 230VAC DI", "4 x 230VAC DO", "4 x 12VDC DO"

                                            };
                                            for (String s: opts) h.put(s, 0);
                                            for (Object[] os: io.data) {
                                                if (os[1] == null) continue;
                                                h.put(os[0], h.get(os[0]) + os[1]);
                                            }
                                            i = 0;
                                            for (int k: h.values()) {
                                                i++;
                                                if (k @gt 0) code += "X" + i + "" + k;
                                            }
                                            code
                                        </formula>
                                        <properties>
                                            <property>
                                                <key>editable</key>

                                                <bool>false</bool>
                                            </property>
                                            <property>
                                                <key>focusable</key>
                                                <bool>false</bool>

                                            </property>
                                        </properties>
                                    </text-field>
                                    <bool-field id="gps">
                                        <label>GPS</label>

                                    </bool-field>
                                </fields>
                            </line>
                            <line>
                                <fields>
                                    <spin-int-field id="num" min="1">

                                        <label>Quantity</label>
                                        <value>1</value>
                                    </spin-int-field>
                                    <int-field id="prc">

                                        <label>Price (euro)</label>
                                        <formula>
                                            price = 0;
                                            if (type.equals("ipromes-mailer")) price += 230;
                                            else if (type.equals("ipromes-weber")) price += 575;
                                            else if (type.equals("ipromes-controller")) price += 200;
                                            else if (type.equals("ipromes-messenger")) price += 625;
                                            if (gps) price += 40;
                                            if (rf.equals("GSM/GPRS/EDGE")) price += 5;
                                            else if (rf.equals("3G")) price += 35;
                                            else if (rf.equals("CDMA")) price += 5;
                                            else if (rf.equals("Wi-Fi")) price += 5;
                                            else if (rf.equals("WiMAX")) price += 15;
                                            if (opt.equals("Character LCD 2x20")) price += 10;
                                            else if (opt.equals("Character LCD 2x20 + keyboard 2x3")) price += 20;
                                            else if (opt.equals("Character LCD 2x20 + keyboard 5x5")) price += 25;
                                            else if (opt.equals("Character LCD 4x20 + keyboard 5x5")) price += 35;
                                            else if (opt.equals("Character LCD 4x20 + keyboard 5x5 + video-out 800x600")) price += 150;
                                            else if (opt.equals("Video-out 800x600")) price += 115;
                                            h = new Hashtable();
                                            opts = new String[] {
                                                "1 x RS-485", "1 x RS-232", "1 x Ethernet", "2 x Pt100 AI", "4 x 4-20mA/0-5V AI",
                                                "4 x 12VDC DI", "2 x 230VAC DI", "4 x 230VAC DO", "4 x 12VDC DO"

                                            };
                                            p = new int[] {20, 15, 40, 30, 25, 20, 20, 25, 25};
                                            for (String s: opts) h.put(s, 0);
                                            for (Object[] os: io.data) {
                                                if (os[1] == null) continue;
                                                h.put(os[0], h.get(os[0]) + os[1]);
                                            }
                                            for (int i = 0; i @lt opts.length; i++)
                                                price += h.get(opts[i]) * p[i];
                                            price
                                        </formula>
                                        <properties>
                                            <property>
                                                <key>editable</key>
                                                <bool>false</bool>

                                            </property>
                                            <property>
                                                <key>focusable</key>
                                                <bool>false</bool>
                                            </property>

                                        </properties>
                                    </int-field>
                                </fields>
                            </line>
                            <line>
                                <fields>

                                    <title>
                                        <label>Device features</label>
                                    </title>
                                </fields>
                            </line>

                            <line>
                                <fields>
                                    <radiolist-field id="rf" cols="3" other="false">

                                        <label>Wireless link type</label>
                                        <items>
                                            <item>GSM/GPRS</item>
                                            <item>GSM/GPRS/EDGE</item>

                                            <item>3G</item>
                                            <item>CDMA</item>
                                            <item>Wi-Fi</item>
                                            <item>WiMAX</item>

                                        </items>
                                        <value>GSM/GPRS</value>
                                    </radiolist-field>
                                </fields>
                            </line>

                            <line>
                                <fields>
                                    <radiolist-field id="itype" cols="3" other="false">

                                        <label>Signal input type</label>
                                        <items>
                                            <item>Cable glands</item>
                                            <item>Cable</item>

                                            <item>Terminals</item>
                                        </items>
                                        <value>Cable glands</value>
                                    </radiolist-field>
                                </fields>

                            </line>
                            <line>
                                <fields>
                                    <combo-field id="opt">
                                        <label>Device options</label>

                                        <items>
                                            <item>None</item>
                                            <item>Character LCD 2x20</item>
                                            <item>Character LCD 2x20 + keyboard 2x3</item>

                                            <item>Character LCD 2x20 + keyboard 5x5</item>
                                            <item>Character LCD 4x20 + keyboard 5x5</item>
                                            <item>Character LCD 4x20 + keyboard 5x5 + video-out 800x600</item>
                                            <item>Video-out 800x600</item>

                                        </items>
                                    </combo-field>
                                </fields>
                            </line>
                            <line>
                                <fields>

                                    <title>
                                        <label>I/O Modules</label>
                                    </title>
                                </fields>
                            </line>

                            <line>
                                <fields>
                                    <table-field id="io">
                                        <label>I/O Modules</label>

                                        <min-width>180 150</min-width>
                                        <max-width>220 170</max-width>
                                        <pref-width>200 160</pref-width>
                                        <editable>true true</editable>

                                        <meta>
                                            <author>ipromes Ltd.</author>
                                            <title>I/O Modules</title>
                                            <lines>
                                                <line>

                                                    <fields>
                                                        <combo-field id="mt">
                                                            <label>Module type</label>
                                                            <items>

                                                                <item>1 x RS-485</item>
                                                                <item>1 x RS-232</item>
                                                                <item>1 x Ethernet</item>
                                                                <item>2 x Pt100 AI</item>

                                                                <item>4 x 4-20mA/0-5V AI</item>
                                                                <item>4 x 12VDC DI</item>
                                                                <item>2 x 230VAC DI</item>
                                                                <item>4 x 230VAC DO</item>

                                                                <item>4 x 12VDC DO</item>
                                                            </items>
                                                            <properties>
                                                                <property>
                                                                    <key>maximumRowCount</key>

                                                                    <int>9</int>
                                                                </property>
                                                            </properties>
                                                        </combo-field>
                                                    </fields>

                                                </line>
                                                <line>
                                                    <fields>
                                                        <spin-int-field id="qty" min="1" max="4">

                                                            <label>Quantity</label>
                                                            <value>1</value>
                                                        </spin-int-field>
                                                    </fields>
                                                </line>

                                                <line><fields><separator/></fields></line>
                                            </lines>
                                        </meta>
                                        <properties>

                                            <property>
                                                <key>preferredSize</key>
                                                <script>
                                                    new Dimension(component.preferredSize.width, 200)
                                                </script>
                                            </property>

                                        </properties>
                                        <trigger>
                                            h = new Hashtable();
                                            opts = new String[] {
                                                "1 x RS-485", "1 x RS-232", "1 x Ethernet", "2 x Pt100 AI", "4 x 4-20mA/0-5V AI",
                                                "4 x 12VDC DI", "2 x 230VAC DI", "4 x 230VAC DO", "4 x 12VDC DO"

                                            };
                                            for (String s: opts) h.put(s, 0);
                                            msg = "";
                                            for (Object[] os: io.data) {
                                                if (os[1] == null) continue;
                                                h.put(os[0], h.get(os[0]) + os[1]);
                                            }
                                            n = 0;
                                            for (int k: h.values()) n += k;
                                            if (n > 4) msg += "The total sum of the module quantities exceeds 4";
                                            if (!msg.empty) target.errorMessage = msg;
                                        </trigger>
                                    </table-field>
                                </fields>
                            </line>

                            <line>
                                <fields>
                                    <text-field id="note">
                                        <label>Note</label>

                                    </text-field>
                                </fields>
                            </line>
                        </lines>
                    </meta>
                    <properties>

                        <property>
                            <key>preferredSize</key>
                            <script>
                                new Dimension(component.preferredSize.width, 300)
                            </script>
                        </property>

                    </properties>
                </table-field>
            </fields>
        </line>
        <line>
            <fields>

                <title>
                    <label>The total costs</label>
                </title>
            </fields>
        </line>

        <line>
            <fields>
                <int-field id="total">
                    <label>The total costs</label>

                    <value>0</value>
                    <formula>
                        sum = 0;
                        for (Object[] line: bill.data) sum += line[4] * line[5];
                        sum
                    </formula>
                    <properties>
                        <property>

                            <key>editable</key>
                            <bool>false</bool>
                        </property>
                        <property>
                            <key>focusable</key>

                            <bool>false</bool>
                        </property>
                    </properties>
                </int-field>
            </fields>

        </line>
    </lines>
    <send-scripts>
        <item icon-path="html" name="Generate HTML report">

            <script>
                alg = new GenHTML(form.meta, form.getKVList());
                GenFormInterface.InvokeStandardAlgorithm.invoke(alg);
            </script>
        </item>
    </send-scripts>
</data>