Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleCustomer.bjs
index 2f76ca3..115f3d4 100644 (file)
                     "items" : [
                         {
                             "listeners" : {
+                                "rowdblclick" : "function (_self, rowIndex, e)\n{\n   var s =  _self.getDataSource().getAt(rowIndex);\n   \n   new Pman.Download({\n        url : baseURL + '/Images/Download/' + s.data.id\n    });\n   \n}",
                                 "|render" : "function() \n{\n    _this.igrid = this; \n\n    if (_this.ipanel.active) {\n       this.footer.onClick('first');\n    }\n}"
                             },
-                            "autoExpandColumn" : "",
+                            "autoExpandColumn" : "imgtype",
                             "xtype" : "Grid",
                             "loadMask" : true,
                             "$ xns" : "Roo.grid",
                             "items" : [
                                 {
                                     "listeners" : {
-                                        "beforeload" : "function (_self, o)\n{\n\n  \n    Roo.apply(o.params, {\n        _group : 'salesHistory',\n        _name : 'detail',\n        'cust_id:number' : _this.form.findField('cust_id').getValue(),\n        'credit:text' : 'credit',\n        'return:text' : 'return',\n        'includeFormatted:int' :  1,\n        'startDate:text' : _this.dateFrom.getValue(),\n        'endDate:text' :  _this.dateTo.getValue()\n    });\n    \n    \n    \n}",
-                                        "load" : "function (_self, records, options)\n{\n    function setText(str) {\n    \n        _this.hgrid.footer.el.select('.sales-footer-text', \n                true).first().dom.innerHTML = str;\n    }\n    \n    \n    if (!records.length) {\n        //_this.footertext.setText('');\n        Roo.log(\"no records\");\n        setText('');\n        return;\n    }\n    new Pman.Request({\n        method : 'GET',\n        url : baseURL + '/Roo/cohist',\n        params : {\n            _sums : 1,\n            \n            cust_id : _this.form.findField('cust_id').getValue(),\n            startDate : _this.dateFrom.getValue(),\n            endDate :  _this.dateTo.getValue()\n        },\n        success : function(res) \n        {\n            setText(\"Total Orders : \" + parseInt(res.data[0].total_orders) + \n                    \"  Total Shipped : \" + parseInt(res.data[0].total_shipped) +                  \n                   \"   Total Value: \" + res.data[0].total_basecurr + \" \" +\n                    Roo.util.Format.number(res.data[0].total_value,2)\n            );\n        }\n    });\n    \n        \n}"
+                                        "beforeload" : "function (_self, o)\n{\n    o.params = o.params || {}\n    \n    var cust_id = _this.form.findField('cust_id').getValue() * 1;\n    \n    if(cust_id < 1){\n        this.removeAll();\n        return false;\n    }\n\n    o.params.ontable = 'custinfo';\n    o.params.onid = cust_id;\n}"
                                     },
                                     "xtype" : "Store",
                                     "remoteSort" : true,
-                                    "$ sortInfo" : "{ field : 'cohist_shipvia', direction: 'ASC' }",
+                                    "$ sortInfo" : "{ field : 'id', direction: 'ASC' }",
                                     "$ xns" : "Roo.data",
                                     "* prop" : "dataSource",
                                     "items" : [
                                         {
-                                            "$ url" : "baseURL + '/Roo/metasql.php'",
+                                            "$ url" : "baseURL + '/Roo/Images.php'",
                                             "method" : "GET",
                                             "xtype" : "HttpProxy",
                                             "$ xns" : "Roo.data",
                                             "root" : "data",
                                             "xtype" : "JsonReader",
                                             "$ xns" : "Roo.data",
-                                            "$ fields" : "[\n    {\n        'name': 'cohist_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_cust_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_itemsite_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_shipdate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'cohist_shipvia',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_ordernumber',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_orderdate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'cohist_invcnumber',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_invcdate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'cohist_qtyshipped',\n        'type': 'float'\n    },\n    {\n        'name': 'cohist_unitprice',\n        'type': 'float'\n    },\n    {\n        'name': 'cohist_shipto_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_salesrep_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_duedate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'cohist_imported',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_billtoname',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtoaddress1',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtoaddress2',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtoaddress3',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtocity',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtostate',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_billtozip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptoname',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptoaddress1',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptoaddress2',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptoaddress3',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptocity',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptostate',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_shiptozip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_commission',\n        'type': 'float'\n    },\n    {\n        'name': 'cohist_commissionpaid',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_unitcost',\n        'type': 'float'\n    },\n    {\n        'name': 'cohist_misc_type',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_misc_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_misc_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_doctype',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_promisedate',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'cohist_ponumber',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_curr_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_sequence',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_taxtype_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_taxzone_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_curr_id_curr_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_curr_id_curr_base',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_curr_id_curr_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_curr_id_curr_symbol',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_curr_id_curr_abbr',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_taxzone_id_taxzone_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_taxzone_id_taxzone_code',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_taxzone_id_taxzone_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_taxtype_id_taxtype_id',\n        'type': 'int'\n    },\n    {\n        'name': 'cohist_taxtype_id_taxtype_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_taxtype_id_taxtype_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohist_taxtype_id_taxtype_sys',\n        'type': 'int'\n    }\n]",
+                                            "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'filename',\n        'type': 'string'\n    },\n    {\n        'name': 'imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'created',\n        'type': 'date',\n        'dateFormat': 'Y-m-d H:i:s'\n    }\n]",
                                             "* prop" : "reader",
                                             "totalProperty" : "total"
                                         }
                                 {
                                     "pageSize" : 25,
                                     "xtype" : "PagingToolbar",
-                                    "emptyMsg" : "No cohist found",
+                                    "emptyMsg" : "No Images found",
                                     "$ xns" : "Roo",
-                                    "displayMsg" : "Displaying Sales {0} - {1} of {2}",
+                                    "displayMsg" : "Displaying Images {0} - {1} of {2}",
                                     "displayInfo" : true,
-                                    "* prop" : "footer",
-                                    "items" : [
-                                        {
-                                            "text" : "<span class=\"sales-footer-text\"></span>",
-                                            "xtype" : "TextItem",
-                                            "$ xns" : "Roo.Toolbar"
-                                        }
-                                    ]
-                                },
-                                {
-                                    "xtype" : "Toolbar",
-                                    "$ xns" : "Roo",
-                                    "* prop" : "toolbar",
-                                    "items" : [
-                                        {
-                                            "text" : "From",
-                                            "xtype" : "TextItem",
-                                            "$ xns" : "Roo.Toolbar"
-                                        },
-                                        {
-                                            "listeners" : {
-                                                "render" : "function (_self)\n{\n  _this.dateFrom = _self;\n}"
-                                            },
-                                            "format" : "d/M/Y",
-                                            "useIso" : true,
-                                            "xtype" : "DateField",
-                                            "| value" : "(function() {return (new Date()).add(Date.MONTH, -3); })()",
-                                            "$ xns" : "Roo.form"
-                                        },
-                                        {
-                                            "text" : "To",
-                                            "xtype" : "TextItem",
-                                            "$ xns" : "Roo.Toolbar"
-                                        },
-                                        {
-                                            "listeners" : {
-                                                "render" : "function (_self)\n{\n_this.dateTo = _self;\n}"
-                                            },
-                                            "format" : "d/M/Y",
-                                            "useIso" : true,
-                                            "xtype" : "DateField",
-                                            "| value" : "(function() {return (new Date()) })()",
-                                            "$ xns" : "Roo.form"
-                                        },
-                                        {
-                                            "listeners" : {
-                                                "click" : "function (_self, e)\n{\n    _this.hgrid.footer.onClick('first');\n}"
-                                            },
-                                            "text" : "Refresh",
-                                            "xtype" : "Button",
-                                            "$ xns" : "Roo.Toolbar"
-                                        },
-                                        {
-                                            "xtype" : "Fill",
-                                            "$ xns" : "Roo.Toolbar"
-                                        },
-                                        {
-                                            "listeners" : {
-                                                "click" : "function (_self, e)\n{\n    new Pman.Download({\n        grid : _this.hgrid\n    });\n}"
-                                            },
-                                            "text" : "Download",
-                                            "xtype" : "Button",
-                                            "$ xns" : "Roo.Toolbar"
-                                        }
-                                    ]
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Customer",
-                                    "$ renderer" : "function(v) { return String.format('{0}', v); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cust_name"
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Order",
-                                    "$ renderer" : "function(v) { return String.format('{0}', v); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohist_ordernumber"
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Invoice Month",
-                                    "$ renderer" : "function(v) { \n    \n    return String.format('{0}',v);\n }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "invmonth"
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Invoice date",
-                                    "$ renderer" : "function(v) { \n    var d = Date.parseDate(v, 'Y-m-d');\n    return String.format('{0}', d ? d.format('d/M/Y') : '');\n }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohead_orderdate"
+                                    "* prop" : "footer"
                                 },
                                 {
                                     "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Invoice date",
-                                    "$ renderer" : "function(v) { \n    var d = Date.parseDate(v, 'Y-m-d');\n    return String.format('{0}', d ? d.format('d/M/Y') : '');\n }",
+                                    "header" : "Image",
+                                    "width" : 100,
+                                    "$ renderer" : "function(v,x,r) {\n    return String.format('<img src=\"{0}/Images/Thumb/100/{1}/{2}\" height=\"50\">', baseURL, v, r.data.filename);\n}",
                                     "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohist_invcdate"
+                                    "* prop" : "cm[]",
+                                    "dataIndex" : "id"
                                 },
                                 {
                                     "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Invoice#",
-                                    "$ renderer" : "function(v) { return String.format('{0}', v); }",
+                                    "width" : 150,
+                                    "header" : "Date",
+                                    "$ renderer" : "function(v) { \n    return String.format('{0}', v ? v.format('d/M/Y') : '');\n }",
                                     "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohist_invcnumber"
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Item No.",
-                                    "$ renderer" : "function(v) { return String.format('{0}', v ? v   : ''); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "item_number"
+                                    "* prop" : "cm[]",
+                                    "dataIndex" : "created"
                                 },
                                 {
                                     "xtype" : "ColumnModel",
+                                    "header" : "File Name",
                                     "width" : 200,
-                                    "header" : "Description",
                                     "$ renderer" : "function(v) { return String.format('{0}', v); }",
                                     "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "item_descrip1"
+                                    "* prop" : "cm[]",
+                                    "dataIndex" : "filename"
                                 },
                                 {
-                                    "align" : "right",
                                     "xtype" : "ColumnModel",
-                                    "header" : "Qty",
-                                    "width" : 70,
-                                    "$ renderer" : "function(v) { return parseInt(v); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohist_qtyshipped"
-                                },
-                                {
-                                    "xtype" : "ColumnModel",
-                                    "width" : 75,
-                                    "header" : "Currency",
-                                    "$ renderer" : "function(v) { return String.format('{0}', v.split(/\\s+/)[0]); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "currabbr"
-                                },
-                                {
-                                    "align" : "right",
-                                    "xtype" : "ColumnModel",
-                                    "header" : "Unit Price",
-                                    "width" : 75,
-                                    "$ renderer" : "function(v) { return Roo.util.Format.number( v, 2); }",
-                                    "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "cohist_unitprice"
-                                },
-                                {
-                                    "align" : "right",
-                                    "xtype" : "ColumnModel",
-                                    "header" : "Ext Cost",
-                                    "width" : 75,
-                                    "$ renderer" : "function(v) { return Roo.util.Format.number( v, 2); }",
+                                    "header" : "Type",
+                                    "width" : 200,
+                                    "$ renderer" : "function(v) { \n    return String.format('{0}',v);\n }",
                                     "$ xns" : "Roo.grid",
-                                    "* prop" : "colModel[]",
-                                    "dataIndex" : "extprice"
+                                    "* prop" : "cm[]",
+                                    "dataIndex" : "imgtype"
                                 }
                             ]
                         }