Pman.Tab.XtupleMetric.bjs
authorEdward <edward@roojs.com>
Tue, 5 Aug 2014 05:17:56 +0000 (13:17 +0800)
committerEdward <edward@roojs.com>
Tue, 5 Aug 2014 05:17:56 +0000 (13:17 +0800)
Pman.Tab.XtupleMetric.js

Pman.Tab.XtupleMetric.bjs
Pman.Tab.XtupleMetric.js

index 98fb818..b73d8d7 100644 (file)
                         {
                             "|xns": "Roo",
                             "xtype": "Toolbar",
-                            "*prop": "toolbar",
-                            "items": [
-                                {
-                                    "listeners": {
-                                        "|click": "function()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var ct  =    _this.grid.ds.getCount();\n    \n    var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;\n    \n    var dt = _this.form.findField('pohead_orderdate').getValue();\n    \n    var nr = _this.grid.ds.reader.newRow({\n        poitem_id : 0,\n        poitem_linenumber : last,\n        item_number : '',\n        item_descrip1 : '',\n        poitem_duedate : dt,\n        poitem_qty_ordered : 1,\n        poitem_unitprice : 0\n    });\n    \n    _this.grid.stopEditing();\n    _this.grid.ds.insert(_this.grid.ds.getCount(), nr); \n    _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);\n}\n"
-                                    },
-                                    "cls": "x-btn-text-icon",
-                                    "text": "Add",
-                                    "xtype": "Button",
-                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
-                                    "|xns": "Roo.Toolbar"
-                                },
-                                {
-                                    "listeners": {
-                                        "|click": "function ()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var cs = _this.grid.getSelectionModel().getSelectedCell();\n    if (!cs) {\n        Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n        return;\n    }\n    _this.grid.stopEditing();\n    var r = _this.grid.ds.getAt(cs[0]);\n    \n    if(r.data.poitem_qty_received * 1 > 0){\n        Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n        return;\n    }\n    \n    \n    _this.grid.ds.remove(r);\n   \n}"
-                                    },
-                                    "cls": "x-btn-text-icon",
-                                    "text": "Remove",
-                                    "xtype": "Button",
-                                    "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
-                                    "|xns": "Roo.Toolbar"
-                                }
-                            ]
+                            "*prop": "toolbar"
                         },
                         {
                             "*prop": "footer",
                             "header": "Module",
                             "width": 100,
                             "xtype": "ColumnModel",
-                            "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
-                            "|xns": "Roo.grid"
-                        },
-                        {
-                            "*prop": "colModel[]",
-                            "align": "right",
-                            "dataIndex": "poitem_qty_ordered",
-                            "header": "Ordered",
-                            "width": 75,
-                            "xtype": "ColumnModel",
                             "|renderer": "function(v) { return String.format('{0}', v); }",
-                            "|xns": "Roo.grid",
-                            "items": [
-                                {
-                                    "|xns": "Roo.grid",
-                                    "xtype": "GridEditor",
-                                    "*prop": "editor",
-                                    "items": [
-                                        {
-                                            "*prop": "field",
-                                            "allowDecimals": false,
-                                            "decimalPrecision": 0,
-                                            "minValue": 1,
-                                            "style": "text-align:right",
-                                            "xtype": "NumberField",
-                                            "|xns": "Roo.form"
-                                        }
-                                    ]
-                                }
-                            ]
-                        },
-                        {
-                            "*prop": "colModel[]",
-                            "align": "right",
-                            "dataIndex": "poitem_qty_received",
-                            "header": "Received",
-                            "width": 75,
-                            "xtype": "ColumnModel",
-                            "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v - r.data.poitem_qty_returned);\n}",
                             "|xns": "Roo.grid"
-                        },
-                        {
-                            "*prop": "colModel[]",
-                            "align": "right",
-                            "dataIndex": "poitem_qty_vouchered",
-                            "header": "Vouchered",
-                            "width": 65,
-                            "xtype": "ColumnModel",
-                            "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != v ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v);\n}",
-                            "|xns": "Roo.grid"
-                        },
-                        {
-                            "*prop": "colModel[]",
-                            "align": "right",
-                            "dataIndex": "poitem_unitprice",
-                            "header": "Unit price",
-                            "width": 100,
-                            "xtype": "ColumnModel",
-                            "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }",
-                            "|xns": "Roo.grid",
-                            "items": [
-                                {
-                                    "|xns": "Roo.grid",
-                                    "xtype": "GridEditor",
-                                    "*prop": "editor",
-                                    "items": [
-                                        {
-                                            "*prop": "field",
-                                            "allowBlank": false,
-                                            "allowDecimals": false,
-                                            "decimalPrecision": 0,
-                                            "minValue": 1,
-                                            "style": "text-align:right",
-                                            "xtype": "NumberField",
-                                            "|xns": "Roo.form"
-                                        }
-                                    ]
-                                }
-                            ]
                         }
                     ]
                 }
index b6b39dc..af35c3e 100644 (file)
@@ -110,82 +110,7 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({
                 },
                 toolbar : {
                     xtype: 'Toolbar',
-                    xns: Roo,
-                    items : [
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar,
-                            listeners : {
-                                click : function()
-                                {
-                                    var status = _this.form.findField('pohead_status').getValue();
-                                    
-                                    if(status == 'C'){
-                                        Roo.MessageBox.alert("Error", "This PO has been closed");
-                                        return;
-                                    }
-                                    
-                                    var ct  =    _this.grid.ds.getCount();
-                                    
-                                    var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;
-                                    
-                                    var dt = _this.form.findField('pohead_orderdate').getValue();
-                                    
-                                    var nr = _this.grid.ds.reader.newRow({
-                                        poitem_id : 0,
-                                        poitem_linenumber : last,
-                                        item_number : '',
-                                        item_descrip1 : '',
-                                        poitem_duedate : dt,
-                                        poitem_qty_ordered : 1,
-                                        poitem_unitprice : 0
-                                    });
-                                    
-                                    _this.grid.stopEditing();
-                                    _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
-                                    _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
-                                }
-                            },
-                            cls : 'x-btn-text-icon',
-                            text : "Add",
-                            icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
-                        },
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar,
-                            listeners : {
-                                click : function ()
-                                {
-                                    var status = _this.form.findField('pohead_status').getValue();
-                                    
-                                    if(status == 'C'){
-                                        Roo.MessageBox.alert("Error", "This PO has been closed");
-                                        return;
-                                    }
-                                    
-                                    var cs = _this.grid.getSelectionModel().getSelectedCell();
-                                    if (!cs) {
-                                        Roo.MessageBox.alert("Error", "Select a cell");
-                                        return;
-                                    }
-                                    _this.grid.stopEditing();
-                                    var r = _this.grid.ds.getAt(cs[0]);
-                                    
-                                    if(r.data.poitem_qty_received * 1 > 0){
-                                        Roo.MessageBox.alert("Error", "This item has been receipted");
-                                        return;
-                                    }
-                                    
-                                    
-                                    _this.grid.ds.remove(r);
-                                   
-                                }
-                            },
-                            cls : 'x-btn-text-icon',
-                            text : "Remove",
-                            icon : rootURL + '/Pman/templates/images/trash.gif'
-                        }
-                    ]
+                    xns: Roo
                 },
                 footer : {
                     xtype: 'PagingToolbar',
@@ -225,76 +150,7 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({
                         dataIndex : 'metric_module',
                         header : 'Module',
                         width : 100,
-                        renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        align : 'right',
-                        dataIndex : 'poitem_qty_ordered',
-                        header : 'Ordered',
-                        width : 75,
-                        renderer : function(v) { return String.format('{0}', v); },
-                        editor : {
-                            xtype: 'GridEditor',
-                            xns: Roo.grid,
-                            field : {
-                                xtype: 'NumberField',
-                                xns: Roo.form,
-                                allowDecimals : false,
-                                decimalPrecision : 0,
-                                minValue : 1,
-                                style : 'text-align:right'
-                            }
-                        }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        align : 'right',
-                        dataIndex : 'poitem_qty_received',
-                        header : 'Received',
-                        width : 75,
-                        renderer : function(v,x,r) { 
-                            return String.format(
-                                r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style="color:red">{0}</span>':  '{0}',
-                                 v - r.data.poitem_qty_returned);
-                        }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        align : 'right',
-                        dataIndex : 'poitem_qty_vouchered',
-                        header : 'Vouchered',
-                        width : 65,
-                        renderer : function(v,x,r) { 
-                            return String.format(
-                                r.data.poitem_qty_ordered != v ? '<span style="color:red">{0}</span>':  '{0}',
-                                 v);
-                        }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        align : 'right',
-                        dataIndex : 'poitem_unitprice',
-                        header : 'Unit price',
-                        width : 100,
-                        renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); },
-                        editor : {
-                            xtype: 'GridEditor',
-                            xns: Roo.grid,
-                            field : {
-                                xtype: 'NumberField',
-                                xns: Roo.form,
-                                allowBlank : false,
-                                allowDecimals : false,
-                                decimalPrecision : 0,
-                                minValue : 1,
-                                style : 'text-align:right'
-                            }
-                        }
+                        renderer : function(v) { return String.format('{0}', v); }
                     }
                 ]
             }