Pman.Dialog.XtupleSalesOrder.bjs
authoredward <edward@roojs.com>
Thu, 24 Mar 2016 06:21:47 +0000 (14:21 +0800)
committeredward <edward@roojs.com>
Thu, 24 Mar 2016 06:21:47 +0000 (14:21 +0800)
Pman.Dialog.XtupleSalesOrder.js

Pman.Dialog.XtupleSalesOrder.bjs

index 9443ece..3d9446c 100644 (file)
       "activate" : "function (_self)\n{\n    // we need to reload to find out the subtotal.\n    if (!_this.data || !_this.data.cohead_id) {\n        return;\n    }\n    new Pman.Request({\n        method : 'GET',\n        url : baseURL + '/Roo/cohead',\n        params : { \n            _id : _this.data.cohead_id\n        },\n        success : function(res) {\n            _this.form.findField('cohead_subtotal').setValue(res.data.cohead_subtotal);\n            _this.form.findField('cohead_tax').setValue(res.data.cohead_tax);\n            _this.form.findField('cohead_uninvoiced').setValue(res.data.cohead_uninvoiced);\n            _this.form.findField('cohead_unshipped').setValue(res.data.cohead_unshipped);\n           _this.form.findField('cohead_pretax_discount').setValue(res.data.cohead_pretax_discount); \n            _this.form.findField('cohead_total').recalc(); \n            _this.form.findField('cohead_misc').recalc(); \n        }\n    });\n}"
      },
      "region" : "center",
-     "title" : "Order Details",
      "xtype" : "ContentPanel",
+     "title" : "Order Details",
      "$ xns" : "Roo",
      "items" : [
       {
         "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
        },
        "$ url" : "baseURL + '/Roo/cohead.php'",
-       "method" : "POST",
        "xtype" : "Form",
+       "method" : "POST",
        "style" : "margin:10px;",
        "$ xns" : "Roo.form",
        "items" : [
         {
          "xtype" : "Column",
-         "$ xns" : "Roo.form",
          "width" : 435,
+         "$ xns" : "Roo.form",
          "items" : [
           {
+           "style" : "width:420px",
            "legend" : "Order",
            "xtype" : "FieldSet",
-           "style" : "width:420px",
            "labelWidth" : 120,
            "$ xns" : "Roo.form",
            "items" : [
                "items" : [
                 {
                  "fieldLabel" : "Order#",
-                 "xtype" : "TextField",
                  "emptyText" : "Automatic",
+                 "xtype" : "TextField",
                  "allowBlank" : true,
                  "readOnly" : true,
                  "width" : 120,
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/location.php'",
-                   "method" : "GET",
                    "xtype" : "HttpProxy",
+                   "method" : "GET",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
            ]
           },
           {
+           "style" : "width:420px",
            "legend" : "Details",
            "xtype" : "FieldSet",
-           "style" : "width:420px",
            "labelWidth" : 100,
            "$ xns" : "Roo.form",
            "items" : [
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/terms.php'",
-                   "xtype" : "HttpProxy",
                    "method" : "GET",
+                   "xtype" : "HttpProxy",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/salesrep.php'",
-                   "xtype" : "HttpProxy",
                    "method" : "GET",
+                   "xtype" : "HttpProxy",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/salesrep.php'",
-                   "xtype" : "HttpProxy",
                    "method" : "GET",
+                   "xtype" : "HttpProxy",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
            ]
           },
           {
+           "style" : "width:420px",
            "xtype" : "FieldSet",
            "legend" : "Billing",
-           "style" : "width:420px",
            "$ xns" : "Roo.form",
            "items" : [
             {
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/cntct.php'",
-                   "xtype" : "HttpProxy",
                    "method" : "GET",
+                   "xtype" : "HttpProxy",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
                 "render" : "function (_self)\n{\n   Roo.log(this.el)\n   \n   \n   \n   this.el.on('click', function() { \n       var id = _this.form.findField('cohead_billto_cntct_id').getValue();\n        Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n            \n                for(var i in  data) {\n                    \n                    _this.data['cohead_billto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('billto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_billto_cntct_id : data.cntct_id,\n                    cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n                \n                        \n                Roo.log(data);\n            }\n        );\n   \n        Roo.log(\"Click text\");\n        \n        \n     });\n}"
                },
                "fieldLabel" : "or enter Address",
-               "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) { \n            v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {\n            v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n    \n    if(_this.data.cohead_billto_cntct_id_cntct_email.length){\n        _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);\n    }\n}\n",
                "xtype" : "TextArea",
+               "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) { \n            v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {\n            v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n    \n    if(_this.data.cohead_billto_cntct_id_cntct_email.length){\n        _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);\n    }\n}\n",
                "readOnly" : true,
                "$ xns" : "Roo.form",
                "name" : "billto_address"
          "$ xns" : "Roo.form",
          "items" : [
           {
+           "legend" : "Price Details",
            "xtype" : "FieldSet",
            "style" : "width:420px",
-           "legend" : "Price Details",
            "labelWidth" : 50,
            "$ xns" : "Roo.form",
            "items" : [
                    "items" : [
                     {
                      "$ url" : "baseURL + '/Roo/curr_symbol.php'",
-                     "xtype" : "HttpProxy",
                      "method" : "GET",
+                     "xtype" : "HttpProxy",
                      "$ xns" : "Roo.data",
                      "* prop" : "proxy"
                     },
                    "items" : [
                     {
                      "$ url" : "baseURL + '/Roo/taxzone.php'",
-                     "method" : "GET",
                      "xtype" : "HttpProxy",
+                     "method" : "GET",
                      "$ xns" : "Roo.data",
                      "* prop" : "proxy"
                     },
                   "keyup" : "function (_self, e)\n{\n    var pv =  parseFloat(_this.form.findField('cohead_subtotal').getValue());\n    var tax = parseFloat(_this.form.findField('cohead_tax').getValue());\n    var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());\n    \n    var n = this.getValue();\n    var discount = parseFloat(n * (pv + tax + pd) * 0.01);\n    \n    _this.form.findField('cohead_posttax_discount').setValue(discount);\n\n    _this.form.findField('cohead_total').recalc();\n    _this.form.findField('cohead_misc').recalc();\n    var val = discount * -1.0;\n     if (val > 0) {\n        _this.form.findField('cohead_misc_descrip').setValue(\"Discount of \" + val.toFixed(1)+'%');\n    }\n   \n    \n}"
                  },
                  "fieldLabel" : "%",
-                 "$ update" : "function() {\n    var m = _this.form.findField('cohead_misc_per');\n    var pv =  parseFloat(_this.form.findField('cohead_subtotal').getValue());\n    var tax = parseFloat(_this.form.findField('cohead_tax').getValue());\n    var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());\n    \n    var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());\n    \n    if (discount > 0.0) {\n        this.setValue(0);        \n        return;\n    }\n    if (pv < 0) {\n        this.setValue(0);        \n        return;\n    }\n    var val = ((discount) / (pv + tax + pd)) * -100;\n    \n    //Roo.log(\"update discount?\" + val);\n    this.setValue(val.toFixed(1));\n    \n     if (val > 0.0) {\n        _this.form.findField('cohead_misc_descrip').setValue(\"Discount of \" + val.toFixed(1)+'%');\n    \n    }\n    \n   \n}\n",
                  "xtype" : "NumberField",
+                 "$ update" : "function() {\n    var m = _this.form.findField('cohead_misc_per');\n    var pv =  parseFloat(_this.form.findField('cohead_subtotal').getValue());\n    var tax = parseFloat(_this.form.findField('cohead_tax').getValue());\n    var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());\n    \n    var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());\n    \n    if (discount > 0.0) {\n        this.setValue(0);        \n        return;\n    }\n    if (pv < 0) {\n        this.setValue(0);        \n        return;\n    }\n    var val = ((discount) / (pv + tax + pd)) * -100;\n    \n    //Roo.log(\"update discount?\" + val);\n    this.setValue(val.toFixed(1));\n    \n     if (val > 0.0) {\n        _this.form.findField('cohead_misc_descrip').setValue(\"Discount of \" + val.toFixed(1)+'%');\n    \n    }\n    \n   \n}\n",
                  "cls" : "roo-align-right",
                  "allowDecimals" : true,
                  "decimalPrecision" : 1,
            ]
           },
           {
+           "style" : "width:420px",
            "xtype" : "FieldSet",
            "legend" : "Shipping",
-           "style" : "width:420px",
            "$ xns" : "Roo.form",
            "items" : [
             {
                   "check" : "function (_self, checked)\n{\n   if (!_this.form) {\n       return;\n   }\n   \n   if (_this.dataloading) {\n   \n       return;\n   }\n   \n   \n   if (checked) {\n   \n        // copy the cohead_billto_cntct_id\n        for (var i in _this.data) {\n            if (!i.match(/^cohead_billto_cntct_id/)) {\n                continue;\n            }\n            var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');\n            _this.data[ni] = _this.data[i];\n        }\n         _this.form.findField('shipto_address').update();\n         _this.form.setValues( {\n                cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,\n                cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' + \n                        _this.data.cohead_shipto_cntct_id_cntct_last_name \n                        \n                \n            });\n\n   \n    } else {\n         for (var i in _this.data) {\n            if (!i.match(/^cohead_billto_cntct_id/)) {\n                continue;\n            }\n            var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');\n            \n            _this.data[ni] = '';\n        }\n         _this.form.findField('shipto_address').update();\n         \n        _this.form.setValues( {\n                cohead_shipto_cntct_id : '',\n                cohead_shipto_cntct_id_cntct_name : '' \n                \n                \n            });\n    }\n    \n}"
                  },
                  "xtype" : "Checkbox",
-                 "$ xns" : "Roo.form",
                  "boxLabel" : "Same as Billing",
+                 "$ xns" : "Roo.form",
                  "name" : "_shipto_same"
                 }
                ]
                  "items" : [
                   {
                    "$ url" : "baseURL + '/Roo/cntct.php'",
-                   "xtype" : "HttpProxy",
                    "method" : "GET",
+                   "xtype" : "HttpProxy",
                    "$ xns" : "Roo.data",
                    "* prop" : "proxy"
                   },
                 "render" : "function (_self)\n{\n   Roo.log(this.el)\n   \n   \n   \n   this.el.on('click', function() { \n       var id = _this.form.findField('cohead_shipto_cntct_id').getValue();\n        Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n            \n                for(var i in  data) {\n                    \n                    _this.data['cohead_shipto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('shipto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_shipto_cntct_id : data.cntct_id,\n                    cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n                \n                        \n                //Roo.log(data);\n            }\n        );\n   \n      //  Roo.log(\"Click text\");\n        \n        \n     });\n}"
                },
                "fieldLabel" : "Address",
-               "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    \n    if (_this.data['cohead_shipto_vend_name'] && _this.data['cohead_shipto_vend_name'].length) {\n         v.push(_this.data['cohead_shipto_vend_name']);\n    }\n        if (_this.data['cohead_shipto_vendaddr_code'] && _this.data['cohead_shipto_vendaddr_code'].length) {\n         v.push(_this.data['cohead_shipto_vendaddr_code']);\n    }\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {\n            v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) { \n            v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n}\n",
                "xtype" : "TextArea",
+               "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    \n    if (_this.data['cohead_shipto_vend_name'] && _this.data['cohead_shipto_vend_name'].length) {\n         v.push(_this.data['cohead_shipto_vend_name']);\n    }\n        if (_this.data['cohead_shipto_vendaddr_code'] && _this.data['cohead_shipto_vendaddr_code'].length) {\n         v.push(_this.data['cohead_shipto_vendaddr_code']);\n    }\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {\n            v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) { \n            v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n}\n",
                "readOnly" : true,
                "width" : 300,
                "$ xns" : "Roo.form",
       "deactivate" : "function (_self)\n{\n    if(_this.grid){\n        _this.grid.stopEditing();\n    }\n}",
       "|activate" : "function() {\n    _this.panel = this;\n    \n    try { if (MODULE.isBuilder) {\n        return;\n    } } catch(e) { }\n    \n    var id = _this.form.findField('cohead_id').getValue() * 1;\n    if (id < 1) {\n        Roo.MessageBox.alert(\"Save First\", \"Save the order first, before adding items\");\n        _this.dialog.layout.getRegion('center').showPanel(0);\n        return;\n    }\n    \n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    \n         //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {\n         //   _this.xferAll.show();\n        // \n        // } else {\n        //     _this.xferAll.hide();\n        // }\n     }\n    \n}"
      },
+     "fitToframe" : true,
      "background" : true,
      "region" : "center",
-     "fitToframe" : true,
      "title" : "Order Items",
      "xtype" : "GridPanel",
      "fitContainer" : true,
       {
        "listeners" : {
         "beforeedit" : "function (e)\n{\n    // we can only edit if nothing is assigned to shipping or invoices..\n    \n    var rec = e.record\n\n    if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {\n        Roo.MessageBox.alert(\"Error\", \"That item has been shipped, has a draft shipment  or invoices - void the shipments/invoices first\");\n        e.cancel = true;\n        return;\n    }\n    \n    if (rec.data.coitem_subnumber * 1 > 0) {\n        Roo.log(\"Edit container event\");\n        Roo.log(e); // if it's a tab.. \n\n        \n        switch(e.field) {\n            // allow editing of source / destination..\n            case 'coitem_shipto_id':\n            case 'coitem_location_src':            \n                return;\n            default : \n                break;\n        }\n        Roo.MessageBox.alert(\"Error\", \"That is a kit item, edit the container.\");\n        e.cancel = true;\n        return;\n    }\n    // zero off values..\n    //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {\n    //        e.value ='';\n    //    }\n    //    if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {\n    //        e.value ='';\n    //    }\n    \n    if (rec.data.item_type == 'K' && e.field == 'item_number') {\n        // you can not change the product type on kits' as it messing things up..\n        Roo.MessageBox.alert(\"Error\", \"That is a kit item,if you need to change it, delete it first.\");\n        e.cancel = true;\n        return;\n    }\n    \n}",
-        "celldblclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    var di = this.cm.getDataIndex(columnIndex);\n    if (di != 'avail_qty') {\n        return;\n    }\n    \n    Pman.Dialog.XtupleInvHistory.show({\n        itemsite_item_id_item_number   : rec.data.item_number,\n       // itemsite_item_id_item_descript1 : rec.data.item_descrip1,\n        location_name : rec.data.coitem_location_src_location_name,\n        location_descrip : rec.data.coitem_location_src_location_descrip,\n        \n        invhist_transdate : _this.form.findField('cohead_targetdate').getValue() \n    }); \n    \n}",
         "|render" : "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    \n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
+        "celldblclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    var di = this.cm.getDataIndex(columnIndex);\n    if (di != 'avail_qty') {\n        return;\n    }\n    \n    Pman.Dialog.XtupleInvHistory.show({\n        itemsite_item_id_item_number   : rec.data.item_number,\n       // itemsite_item_id_item_descript1 : rec.data.item_descrip1,\n        location_name : rec.data.coitem_location_src_location_name,\n        location_descrip : rec.data.coitem_location_src_location_descrip,\n        \n        invhist_transdate : _this.form.findField('cohead_targetdate').getValue() \n    }); \n    \n}",
         "afteredit" : "function (e)\n{\n    Roo.log('afteredit:' + e.record.data.coitem_linenumber);\n\n    \n   // if ( e.record && e.record.data.coitem_id) {\n        // as we disable update to the display on the ajax callback to \n        // allow editing flow to continue, and not refresh - we can only update\n        // these values after something has actually been edited.\n        // e.record.set('coitem_id', e.record.data.coitem_id);\n        // e.record.set('coitem_status', e.record.data.coitem_status);\n   // }\n    \n    if (e.field == 'item_number' || e.originalValue == e.value) {\n        // afterselect handles this...\n        return;\n    }\n    if (e.field == 'item_descrip1') {\n        e.record.set('coitem_memo', e.value);\n    }\n    var rate = _this.form.findField('taxzone_rate').getValue();\n    switch(e.field) {\n        case 'coitem_linedisc':\n           \n            var cp = parseFloat(e.record.data.coitem_custprice);\n           \n            if (isNaN(cp) || cp == 0.0) {\n                break;\n            }\n            \n            var dis = parseFloat(e.value);\n           \n            if (isNaN(dis)) {\n                break;\n            }\n            \n            e.record.set(\n                'coitem_price',\n                Math.max(0,cp * ((100.0 -  parseInt(e.value))/ 100.0) )  \n            );\n            \n           // donot need to set the subtotal here, coz we will render it automatically\n           // e.record.set(\n           //     'coitem_subtotal',\n           //      e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord\n           // );\n            break;\n        \n        case  'coitem_price': // SELL@ price\n\n             var cp = parseFloat(e.record.data.coitem_custprice);\n             // list price is < price -- update it..\n             if (isNaN(cp) || cp == 0.0 || cp < e.value) {\n                e.record.set('coitem_custprice', e.value);\n                cp = e.value;\n             }\n             // update the discount calc.\n             \n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( e.value / cp) * 100.0)));  \n             \n             // donot need to set the subtotal here, coz we will render it automatically\n             //e.record.set(\n             //   'coitem_subtotal',\n              //   e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord\n             //);\n             break;\n        \n        case 'coitem_custprice':\n            // modified customer price...\n            // just modify the discount.. -- leave the entered price the same..\n              var sp =  parseFloat(e.record.data.coitem_price);\n              var cp = parseFloat(e.value);\n              if (isNaN(cp) || cp == 0.0 || cp < e.value) {\n                    break;\n              }\n              \n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break;\n             \n        case 'coitem_custprice_tax':\n              var cp = parseFloat(e.value / ( 1 + rate * 1 ));\n              var sp =  parseFloat(e.record.data.coitem_price);\n              \n              if (isNaN(cp) || cp == 0.0) {\n                    break;\n              }\n              e.record.set('coitem_custprice', cp);\n              e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break; \n             \n         case  'coitem_price_tax':\n\n             var cp = parseFloat(e.record.data.coitem_custprice);\n             var sp = parseFloat(e.value / ( 1 + rate * 1 ));\n             if (isNaN(cp) || cp == 0.0 || cp < sp) {\n                e.record.set('coitem_custprice', sp);\n                cp = sp;\n             }\n             e.record.set('coitem_price', sp);\n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break;\n      \n    }\n    \n     \n    \n    \n    var doupdate = function() { \n       if (!e.record.updatePending) {\n            Roo.log('doupdate...'  + e.record.data.coitem_linenumber);\n            Roo.log(e.record);\n            e.record.commit();\n            return;\n        }\n       Roo.log('doupdate pending...'   + e.record.data.coitem_linenumber);\n        // wait until it's not peding an update..\n        doupdate.defer(500);\n    }\n\n    if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert\n        e.record.isInserting = 1;\n        e.record.isUpdating = 0;\n        doupdate();\n        return;\n    }\n    \n    // update\n    if(!e.record.isInserting && !e.record.isUpdating){\n        e.record.isUpdating = 1;\n        doupdate();\n        return;\n    }\n    \n    if(!e.record.updatePending){\n        e.record.updatePending = 1;\n        doupdate();\n        return;\n    }\n    Roo.log(\"got to end without doing an update?\"  + e.record.data.coitem_linenumber);\n    \n}\n",
         "rowclass" : "function (gridview, rowcfg)\n{\n    if (rowcfg.record.data.coitem_status == 'C' &&\n        rowcfg.record.data.shipitem_shipped * 1 < 1) {\n        \n        rowcfg.rowClass = 'strikethrough';\n    }\n     if (rowcfg.record.data.coitem_status == 'X'  ) {\n        \n        rowcfg.rowClass = 'strikethrough';\n    }\n    \n    if (!rowcfg.record.data.coitem_id) { \n            rowcfg.rowClass = 'dragon-not-saved';\n    }\n    \n    \n   // Roo.log(rowcfg);\n//    shipitem_shipped\n}"
        },
          "items" : [
           {
            "$ url" : "baseURL + '/Roo/coitem.php'",
-           "method" : "GET",
            "xtype" : "HttpProxy",
+           "method" : "GET",
            "$ xns" : "Roo.data",
            "* prop" : "proxy"
           },
             "render" : "function (_self)\n{\n    _this._applyDiscount = _self;\n}"
            },
            "xtype" : "TextField",
-           "width" : 40,
-           "$ xns" : "Roo.form"
+           "$ xns" : "Roo.form",
+           "width" : 40
           },
           {
            "listeners" : {
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 40,
          "header" : "Item#",
+         "width" : 40,
          "$ renderer" : "function(v,x,r) {\n\n    if (r.data.coitem_subnumber * 1 > 0) {\n         return String.format('{0}.{1}', v,r.data.coitem_subnumber);\n     }\n     return String.format('{0}', v);\n  }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 75,
          "header" : "Item Code",
+         "width" : 75,
          "$ renderer" : "function(v) { return String.format('{0}', v); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
                "items" : [
                 {
                  "$ url" : "baseURL + '/Roo/itemsite.php'",
-                 "method" : "GET",
                  "xtype" : "HttpProxy",
+                 "method" : "GET",
                  "$ xns" : "Roo.data",
                  "* prop" : "proxy"
                 },
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 75,
          "header" : "From",
+         "width" : 75,
          "$ renderer" : "function(v,x,r) { \n    return String.format('{0}', r.data.coitem_location_src_location_name); \n}",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
                "items" : [
                 {
                  "$ url" : "baseURL + '/Roo/location.php'",
-                 "method" : "GET",
                  "xtype" : "HttpProxy",
+                 "method" : "GET",
                  "$ xns" : "Roo.data",
                  "* prop" : "proxy"
                 },
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 75,
          "header" : "To",
+         "width" : 75,
          "$ renderer" : "function(v,x,r) { \n    return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name); \n}",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
                "items" : [
                 {
                  "$ url" : "baseURL + '/Roo/shiptoinfo.php'",
-                 "method" : "GET",
                  "xtype" : "HttpProxy",
+                 "method" : "GET",
                  "$ xns" : "Roo.data",
                  "* prop" : "proxy"
                 },
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 150,
          "header" : "Item Description",
+         "width" : 150,
          "$ renderer" : "function(v,x,r) { \n\n    if (r.data.coitem_memo && r.data.coitem_memo.length) {\n        return String.format('{0}', r.data.coitem_memo);\n        if (r.data.coitem_memo != v) {\n            r.set('item_descrip1', r.data.coitem_memo);\n        }\n        \n    }\n    if (v && v.length > 49) {\n        return String.format('<span style=\"color:orange\" qtip=\"line may be too long to print\">{0}</span>', v);\n    }\n    \n    return String.format('{0}', v); \n    \n}",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
               "focus" : "function (_self)\n{\n    if (this.value == 0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 1,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "allowDecimals" : false,
              "decimalPrecision" : 0,
              "$ xns" : "Roo.form",
               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 0,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "decimalPrecision" : 3,
              "$ xns" : "Roo.form",
              "* prop" : "field"
               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 0,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "decimalPrecision" : 3,
              "$ xns" : "Roo.form",
              "* prop" : "field"
               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 0,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "decimalPrecision" : 2,
              "$ xns" : "Roo.form",
              "maxValue" : 100,
               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 0,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "decimalPrecision" : 3,
              "$ xns" : "Roo.form",
              "* prop" : "field"
               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
              },
              "minValue" : 0,
-             "xtype" : "NumberField",
              "style" : "text-align:right",
+             "xtype" : "NumberField",
              "decimalPrecision" : 3,
              "$ xns" : "Roo.form",
              "* prop" : "field"
                "items" : [
                 {
                  "$ url" : "baseURL + '/Roo/taxtype.php'",
-                 "method" : "GET",
                  "xtype" : "HttpProxy",
+                 "method" : "GET",
                  "$ xns" : "Roo.data",
                  "* prop" : "proxy"
                 },
       "activate" : "function (_self)\n{\n    _this.shipinvtab = _self;\n}"
      },
      "region" : "center",
-     "title" : "Shipments / Invoices",
      "xtype" : "NestedLayoutPanel",
+     "title" : "Shipments / Invoices",
      "$ xns" : "Roo",
      "items" : [
       {
          "listeners" : {
           "|activate" : "function() {\n    _this.shippanel = this;\n    if (_this.shipgrid) {\n        _this.shipgrid.ds.load({});\n    }\n}"
          },
+         "background" : false,
          "fitToframe" : true,
          "region" : "north",
-         "background" : false,
          "title" : "shiphead",
          "xtype" : "GridPanel",
          "fitContainer" : true,
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/shiphead.php'",
-               "xtype" : "HttpProxy",
                "method" : "GET",
+               "xtype" : "HttpProxy",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 80,
              "header" : "number",
+             "width" : 80,
              "$ renderer" : "function(v,x,r) {\n    if (r.json.shiphead_shipdate.length) {\n         return String.format('{0}', v); \n     }\n     return String.format('<s>{0}</s>', v); \n }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 100,
              "header" : "From Location",
+             "width" : 100,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 100,
              "header" : "Ship to",
+             "width" : 100,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "shipdate",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 50,
              "header" : "Status",
+             "width" : 50,
              "$ renderer" : "function(v,x,r) { \n\n\n\n  \n    if (r.json.shiphead_shipdate.length) {\n    \n        if (r.json.shiphead_shipped) {\n            return \"Confirmed\";\n        }\n    \n         return '<span style=\"color:red\">Draft</span>';\n    }\n     \n    return 'VOID';\n   \n\n}",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 200,
              "header" : "shipvia",
+             "width" : 200,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 200,
              "header" : "tracknum",
+             "width" : 200,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
          "listeners" : {
           "|activate" : "function() {\n    _this.invpanel = this;\n    if (_this.invgrid) {\n        _this.invgrid.ds.load({});\n    }\n}"
          },
+         "fitToframe" : true,
          "background" : false,
          "region" : "center",
-         "fitToframe" : true,
          "title" : "Invoices",
          "xtype" : "GridPanel",
          "fitContainer" : true,
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/cobmisc.php'",
-               "method" : "GET",
                "xtype" : "HttpProxy",
+               "method" : "GET",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 100,
              "header" : "Invoice #",
+             "width" : 100,
              "$ renderer" : "function(v,x,r) { \n       if (v && \n             r.data.cobmisc_invchead_id_invchead_id * 1 && \n            !r.data.cobmisc_invchead_id_invchead_posted) {\n           return  '<span style=\"color:red\">' + \n                \"NEEDS Voiding then re-posted: \" + \n                String.format('{0}', v) +\n                '</span>'; \n       }\n\n       if(v && r.data.cobmisc_id == -2){\n            return String.format('<span style=\"margin-left: 10px;\"> - {0} (Credit Memo)</span>', v); \n       }\n       if(v && r.data.cobmisc_id == -3){\n            return String.format('<span style=\"margin-left: 20px;\"> - {0} (Miscellaneous Check)</span>', v); \n       }\n      if(v && r.data.cobmisc_id == -4){\n            return String.format('<span style=\"margin-left: 10px;\"> - {0} (Receive Payment to {2}) [ {1} ]</span>', \n                    v, r.data.cobmisc_cashrcpt_amount, r.json.cashrcpt_bankaccnt_id_bankaccnt_bankname); \n       }\n       \n        return v ? String.format('{0}', v) : \n                '<span style=\"color:red\">' + \"Not Posted\" + '</span>'; \n}",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "invcdate",
+             "width" : 75,
              "$ renderer" : "function(v,x,r) { \n    \n    return String.format('{0}', v && v.format ? v.format('d/M/Y') : ''); \n}",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
      "listeners" : {
       "|activate" : "function() {\n    _this.hpanel = this;\n    if (_this.hgrid) {\n        _this.hgrid.footer.onClick('first');\n    }\n}"
      },
+     "background" : true,
      "fitToframe" : true,
      "region" : "center",
-     "background" : true,
      "title" : "History",
      "xtype" : "GridPanel",
      "fitContainer" : true,
          "items" : [
           {
            "$ url" : "baseURL + '/Roo/events.php'",
-           "xtype" : "HttpProxy",
            "method" : "GET",
+           "xtype" : "HttpProxy",
            "$ xns" : "Roo.data",
            "* prop" : "proxy"
           },
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 120,
          "header" : "Changed",
+         "width" : 120,
          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 120,
          "header" : "action",
+         "width" : 120,
          "$ renderer" : "function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 120,
          "header" : "IP address",
+         "width" : 120,
          "$ renderer" : "function(v) { return String.format('{0}', v); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 120,
          "header" : "Who",
+         "width" : 120,
          "$ renderer" : "function(v) { return String.format('{0}', v); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 200,
          "header" : "Notes",
+         "width" : 200,
          "$ renderer" : "function(v) { return String.format('{0}', v); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
     },
     {
      "region" : "center",
-     "title" : "Stock Tx",
      "xtype" : "NestedLayoutPanel",
+     "title" : "Stock Tx",
      "$ xns" : "Roo",
      "items" : [
       {
         },
         {
          "xtype" : "LayoutRegion",
-         "$ xns" : "Roo",
          "width" : 500,
+         "$ xns" : "Roo",
          "split" : true,
          "* prop" : "east"
         },
          "listeners" : {
           "|activate" : "function() {\n    _this.txpanel = this;\n    if (_this.txgrid) {\n        _this.txgrid.footer.onClick('first');\n    }\n}"
          },
+         "fitToframe" : true,
          "background" : false,
          "region" : "center",
-         "fitToframe" : true,
          "title" : "invdetail",
          "xtype" : "GridPanel",
          "fitContainer" : true,
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/invdetail.php'",
-               "method" : "GET",
                "xtype" : "HttpProxy",
+               "method" : "GET",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Item",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
          "listeners" : {
           "|activate" : "function() {\n    _this.txdpanel = this;\n    if (_this.txdgrid) {\n        _this.txdgrid.footer.onClick('first');\n    }\n}"
          },
+         "fitToframe" : true,
          "background" : false,
          "region" : "east",
-         "fitToframe" : true,
          "title" : "invdetail",
          "xtype" : "GridPanel",
          "fitContainer" : true,
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/invdetail.php'",
-               "method" : "GET",
                "xtype" : "HttpProxy",
+               "method" : "GET",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 60,
              "header" : "TX#",
+             "width" : 60,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Date",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Ref#",
+             "width" : 75,
              "$ renderer" : "function(v,x,r) {\n    if (r.data.invfifo_void *1 != 0) {\n        return String.format('<s>{0}</s>', v); \n    }\n\n     return String.format('{0}', v); \n }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 60,
              "header" : "TX#",
+             "width" : 60,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Notes",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 40,
              "header" : "Posted",
+             "width" : 40,
              "$ renderer" : "function(v,x,r) { \n    \n    var state = v   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
     },
     {
      "region" : "center",
-     "title" : "GL Tx",
      "xtype" : "NestedLayoutPanel",
+     "title" : "GL Tx",
      "$ xns" : "Roo",
      "items" : [
       {
         },
         {
          "xtype" : "LayoutRegion",
-         "$ xns" : "Roo",
          "width" : 500,
+         "$ xns" : "Roo",
          "split" : true,
          "* prop" : "east"
         },
          "listeners" : {
           "|activate" : "function() {\n    _this.gltxpanel = this;\n    if (_this.gltxgrid) {\n        _this.gltxgrid.footer.onClick('first');\n    }\n}"
          },
+         "fitToframe" : true,
          "background" : false,
          "region" : "center",
-         "fitToframe" : true,
          "title" : "invdetail",
          "xtype" : "GridPanel",
          "fitContainer" : true,
          "items" : [
           {
            "listeners" : {
-            "|render" : "function() \n{\n    _this.gltxgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxpanel.active) {\n       this.footer.onClick('first');\n    }\n}",
-            "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    if (columnIndex > 0) {\n        return;\n    }\n    var rec = this.ds.getAt(rowIndex);\n    rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);\n    _this.gltxdgrid.footer.onClick('first');\n}"
+            "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    if (columnIndex > 0) {\n        return;\n    }\n    var rec = this.ds.getAt(rowIndex);\n    rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);\n    _this.gltxdgrid.footer.onClick('first');\n}",
+            "|render" : "function() \n{\n    _this.gltxgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
            },
            "autoExpandColumn" : "gltrans_accnt_id_accnt_descrip",
            "xtype" : "Grid",
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/gltrans.php'",
-               "method" : "GET",
                "xtype" : "HttpProxy",
+               "method" : "GET",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 50,
              "header" : "Summary",
+             "width" : 50,
              "$ renderer" : "function(v,x,r) { \n    \n    var state = v*1   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Account",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
          "listeners" : {
           "|activate" : "function() {\n    _this.gltxdpanel = this;\n    if (_this.gltxdgrid) {\n        _this.gltxdgrid.footer.onClick('first');\n    }\n}"
          },
+         "fitToframe" : true,
          "background" : false,
          "region" : "east",
-         "fitToframe" : true,
          "title" : "invdetail",
          "xtype" : "GridPanel",
          "fitContainer" : true,
          "items" : [
           {
            "listeners" : {
-            "|render" : "function() \n{\n    _this.gltxdgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxdpanel.active) {\n       this.footer.onClick('first');\n    }\n}",
-            "cellclick" : "function (_self, ri, ci, e)\n{\n    \n      var deleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _void : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', false);\n                rec.set('gltrans_deleted', true);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    var undeleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _unvoid : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', true);\n                rec.set('gltrans_deleted', false);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    \n    var di = this.colModel.config[ci].dataIndex;\n    if (di != 'gltrans_posted') {\n        return;\n    }\n    \n    \n    \n    var rec = this.ds.getAt(ri);\n    if (rec.data.gltrans_deleted) {\n    \n         Roo.MessageBox.confirm(\n            \"Confirm\", \n            \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n            function(x) {\n                if (x != 'yes') {\n                    return;\n                }\n                undeleteSel();\n            }\n        );\n    \n        return false;\n    }\n\n    \n    \n    if (!rec.data.gltrans_posted) {\n\n        \n        \n        new Pman.Request({\n            method : 'POST',\n            url : baseURL + '/Roo/gltrans',\n            mask : \"Posting\",\n            params : {\n                _post : 1,\n                gltrans_id : rec.data.gltrans_id\n            },\n            success : function (res)\n            {\n                rec.set('gltrans_posted', true);\n                _this.gltxgrid.footer.onClick('first');\n            \n            }\n        \n        \n        });\n        return;\n    }\n    \n    // we have a posted transaction.\n    // only allow recalled to be deleted..\n    if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {\n        return false;\n    }\n    \n    \n \n    \n    \n\n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n        function(x) {\n            if (x != 'yes') {\n                return;\n            }\n            deleteSel();\n        }\n    );\n          \n    \n    \n}"
+            "cellclick" : "function (_self, ri, ci, e)\n{\n    \n      var deleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _void : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', false);\n                rec.set('gltrans_deleted', true);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    var undeleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _unvoid : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', true);\n                rec.set('gltrans_deleted', false);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    \n    var di = this.colModel.config[ci].dataIndex;\n    if (di != 'gltrans_posted') {\n        return;\n    }\n    \n    \n    \n    var rec = this.ds.getAt(ri);\n    if (rec.data.gltrans_deleted) {\n    \n         Roo.MessageBox.confirm(\n            \"Confirm\", \n            \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n            function(x) {\n                if (x != 'yes') {\n                    return;\n                }\n                undeleteSel();\n            }\n        );\n    \n        return false;\n    }\n\n    \n    \n    if (!rec.data.gltrans_posted) {\n\n        \n        \n        new Pman.Request({\n            method : 'POST',\n            url : baseURL + '/Roo/gltrans',\n            mask : \"Posting\",\n            params : {\n                _post : 1,\n                gltrans_id : rec.data.gltrans_id\n            },\n            success : function (res)\n            {\n                rec.set('gltrans_posted', true);\n                _this.gltxgrid.footer.onClick('first');\n            \n            }\n        \n        \n        });\n        return;\n    }\n    \n    // we have a posted transaction.\n    // only allow recalled to be deleted..\n    if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {\n        return false;\n    }\n    \n    \n \n    \n    \n\n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n        function(x) {\n            if (x != 'yes') {\n                return;\n            }\n            deleteSel();\n        }\n    );\n          \n    \n    \n}",
+            "|render" : "function() \n{\n    _this.gltxdgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxdpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
            },
            "autoExpandColumn" : "gltrans_notes",
            "xtype" : "Grid",
              "items" : [
               {
                "$ url" : "baseURL + '/Roo/gltrans.php'",
-               "method" : "GET",
                "xtype" : "HttpProxy",
+               "method" : "GET",
                "$ xns" : "Roo.data",
                "* prop" : "proxy"
               },
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Date",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Doc#",
+             "width" : 75,
              "$ renderer" : "function(v,x,r) { \n    if (r.data.gltrans_deleted) {\n       return String.format('<s>{0}</s>', v);     \n    }\n    return String.format('{0}', v); \n}",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 50,
              "header" : "Source",
+             "width" : 50,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 75,
              "header" : "Notes",
+             "width" : 75,
              "$ renderer" : "function(v) { return String.format('{0}', v); }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
             },
             {
              "xtype" : "ColumnModel",
-             "width" : 50,
              "header" : "Posted",
+             "width" : 50,
              "$ renderer" : "function(v,x,r) { \n    \n    var state = v   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
              "$ xns" : "Roo.grid",
              "* prop" : "colModel[]",
      "listeners" : {
       "|activate" : "function() {\n    _this.profitpanel = this;\n    \n    try { if (MODULE.isBuilder) {\n        return;\n    } } catch(e) { }\n    \n    var id = _this.form.findField('cohead_id').getValue() * 1;\n    if (id < 1) {\n        Roo.MessageBox.alert(\"Save First\", \"Save the order first, before adding items\");\n        _this.dialog.layout.getRegion('center').showPanel(0);\n        return;\n    }\n    \n    if (_this.profitgrid) {\n        _this.profitgrid.footer.onClick('first');\n     }\n    \n}"
      },
+     "fitToframe" : true,
      "background" : true,
      "region" : "center",
-     "fitToframe" : true,
      "title" : "Profit",
      "xtype" : "GridPanel",
      "fitContainer" : true,
          "items" : [
           {
            "$ url" : "baseURL + '/Roo/coitem.php'",
-           "method" : "GET",
            "xtype" : "HttpProxy",
+           "method" : "GET",
            "$ xns" : "Roo.data",
            "* prop" : "proxy"
           },
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 75,
          "header" : "Item Code",
+         "width" : 75,
          "$ renderer" : "function(v) { return String.format('{0}', v); }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 200,
          "header" : "SubTotal",
+         "width" : 200,
          "$ renderer" : "function(v) {\n\n\n     return Roo.util.Format.number( v, 2);\n  }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 200,
          "header" : "Cost of goods",
+         "width" : 200,
          "$ renderer" : "function(v) {\n\n    return Roo.util.Format.number( v, 2);\n  }",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",
         },
         {
          "xtype" : "ColumnModel",
-         "width" : 200,
          "header" : "Profit",
+         "width" : 200,
          "$ renderer" : "function(v,x,r) {\n        \n   var profit = r.data.calc_subtotal - r.data.calc_cost_total;\n   \n   if(parseInt(profit) < 1){\n       return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(profit,2));      \n   }\n        \n        \n    return Roo.util.Format.number( profit, 2);\n}",
          "$ xns" : "Roo.grid",
          "* prop" : "colModel[]",