Pman.Tab.XtupleSalesOrder.bjs
authorEdward <edward@roojs.com>
Thu, 20 Aug 2015 06:17:56 +0000 (14:17 +0800)
committerEdward <edward@roojs.com>
Thu, 20 Aug 2015 06:17:56 +0000 (14:17 +0800)
Pman.Tab.XtupleSalesOrder.js

Pman.Tab.XtupleSalesOrder.bjs
Pman.Tab.XtupleSalesOrder.js

index 1932e90..3b47fdd 100644 (file)
 {
-    "id": "roo-file-68",
-    "name": "Pman.Tab.XtupleSalesOrder",
-    "parent": "Pman.Tab.XtupleSales",
-    "title": "",
-    "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleSalesOrder.bjs",
-    "items": [
+ "name" : "Pman.Tab.XtupleSalesOrder",
+ "parent" : "Pman.Tab.XtupleSales",
+ "title" : "",
+ "path" : "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleSalesOrder.bjs",
+ "permname" : "",
+ "modOrder" : "001",
+ "strings" : {
+  "fdb35c1a9883acaa94378144a114dfe6" : "Cust. PO#",
+  "a8929eb5c1553d3f70497f862d25d0ce" : "Select Action",
+  "3bd9a9f36601eeb35d5afce4dcfbfce5" : "No cohead found",
+  "6f1bf85c9ebb3c7fa26251e1e335e032" : "Terms",
+  "d2fd3c49554ebcce7e57b85dfa682160" : "Displaying cohead{0} - {1} of {2}",
+  "72d6d7a1885885bb55a565fd1070581a" : "Import",
+  "36dc4ac22a9c9aa45d359e55937499da" : "as PDF",
+  "051f291b80c3336fc75368454ca2a8d2" : "Import HSBC csv file",
+  "f313afd5710eeea203821d3201cc27d8" : "Email to warehouse",
+  "a1fa27779242b4902f7ae3bdd5c6d508" : "Type",
+  "d1228f5476d15142b1358ae4b5fa2454" : "Order #",
+  "bf2234cf486127ba73efe4b2986eed78" : "Customer Statement",
+  "bcc3c81377e8aef6878f3048ad3e1845" : "cohead",
+  "be99bd9be2f6204e18d9be098b1cec84" : "AR Aging",
+  "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
+  "ce26601dac0dea138b7295f02b7620a7" : "Customer",
+  "1243daf593fa297e07ab03bf06d925af" : "Searching...",
+  "3f7488c396d3d4e015d8886452db4110" : "Staff IC.",
+  "4351cfebe4b61d8aa5efa1d020710005" : "View",
+  "f38ab62162b94b4978679aeca58a270c" : "Select Order",
+  "8f3e1295a3a1d30b6ee5d8de6e0b8c0a" : "as Excel",
+  "13348442cc6a27032d2b4aa28b75a5d3" : "Search",
+  "26e09a1ee1517389c7b07f42df65561a" : "Ordered",
+  "8db91c5e3376bc85414ebca9c53fb53f" : "MYOPEN",
+  "904062c33353866aa5234f35ed29e114" : "Download Results",
+  "959462c653dede23e7152b97b45a8aa5" : "Clear Unpaid Orders",
+  "3e208ad5d41ca414bb432adbb7d39c33" : "View type",
+  "4d02be4779719ea23232946e4a34aa82" : "Magento Upload",
+  "74002cb040b036511b8d031da591364a" : "Ship to",
+  "5da618e8e4b89c66fe86e32cdafde142" : "From",
+  "ebe043e4c90950fe50c8a95d96af10f5" : "Quick Stock Check",
+  "54ca6e7fdb43298ae82cd9cb04e77f9b" : "#order",
+  "c91c7b93c28cd18741b71f727ee81ee3" : "Reports",
+  "96b0141273eabab320119c467cdcaf17" : "Total",
+  "99360e60ce244a99256c131555f20d4e" : "Sales Orders",
+  "1c5b744a085a30924e4436c89a79027e" : "Complete and Close",
+  "a2fdeac60e3c5b6c51a92e027fb9d533" : "Target Delivery",
+  "5fb63579fc981698f97d55bfecb213ea" : "Copy",
+  "b155bf2beaeeb2018389eded7c74b56f" : "Customer History",
+  "b0ca9fe87723f63f290ec66b891ec9ee" : "Import Waybill Delivery",
+  "2d899459cc25ea99ea2573d592860ec8" : "Customer#",
+  "fce6d3795b41b54dc0dab82df50517c1" : "Select custinfo",
+  "e12167aa0a7698e6ebc92b4ce3909b53" : "To",
+  "d720bb04db44a8269a09bea3b90352f4" : "Summary Excel",
+  "f4c6f851b00d5518bf888815de279aba" : "Notes"
+ },
+ "items" : [
+  {
+   "listeners" : {
+    "activate" : "function (_self)\n{\n    this.setTitle('Sales Orders (' + Pman.Login.authUser.dbname +')');\n}"
+   },
+   "region" : "center",
+   "xtype" : "NestedLayoutPanel",
+   "title" : "Sales Orders",
+   "$ xns" : "Roo",
+   "items" : [
+    {
+     "xtype" : "BorderLayout",
+     "$ xns" : "Roo",
+     "* prop" : "layout",
+     "items" : [
+      {
+       "xtype" : "LayoutRegion",
+       "title" : "Search",
+       "$ xns" : "Roo",
+       "width" : 200,
+       "split" : true,
+       "* prop" : "west"
+      },
+      {
+       "xtype" : "LayoutRegion",
+       "$ xns" : "Roo",
+       "* prop" : "center"
+      },
+      {
+       "listeners" : {
+        "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+       },
+       "background" : true,
+       "fitToframe" : true,
+       "region" : "center",
+       "title" : "cohead",
+       "xtype" : "GridPanel",
+       "fitContainer" : true,
+       "$ xns" : "Roo",
+       "# builderCfg" : "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
+       "tableName" : "cohead",
+       "items" : [
         {
-            "listeners": {
-                "activate": "function (_self)\n{\n    this.setTitle('Sales Orders (' + Pman.Login.authUser.dbname +')');\n}"
+         "listeners" : {
+          "|rowdblclick" : "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('refresh');\n        Pman.Tab.XtupleSales.grid.footer.onClick('first');\n    }); \n}\n",
+          "|render" : "function() \n{\n    _this.grid = this; \n    try { \n        _this.dialog = Pman.Dialog.XtupleSalesOrder;\n    } catch(e) {}\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}"
+         },
+         "autoExpandColumn" : "cohead_cust_id_cust_name",
+         "xtype" : "Grid",
+         "loadMask" : true,
+         "$ xns" : "Roo.grid",
+         "* prop" : "grid",
+         "items" : [
+          {
+           "listeners" : {
+            "beforeload" : "function (_self, options)\n{\n    var vl;\n    try { \n         vl = _this.form.getFieldValues();\n     } catch (e) {\n        vl = {};\n     }\n\n     \n     \n    for(var x in vl) {\n        if (!(new String(vl[x])).length) {\n            continue;\n        }\n        options.params[x] = vl[x];\n        \n    }\n    try {\n        if (options.params['query[cohead_number]'].length) {\n            options.params.viewtype = 'REALALL';\n        }\n    } catch (e) {}\n}"
+           },
+           "remoteSort" : true,
+           "xtype" : "Store",
+           "$ sortInfo" : "{ field : 'cohead_orderdate', direction: 'DESC' }",
+           "$ xns" : "Roo.data",
+           "* prop" : "dataSource",
+           "# builderCfg" : "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
+           "items" : [
+            {
+             "$ url" : "baseURL + '/Roo/cohead.php'",
+             "method" : "GET",
+             "xtype" : "HttpProxy",
+             "timeout" : 60000,
+             "$ xns" : "Roo.data",
+             "* prop" : "proxy"
             },
-            "region": "center",
-            "title": "Sales Orders",
-            "xtype": "NestedLayoutPanel",
-            "|xns": "Roo",
-            "items": [
+            {
+             "id" : "id",
+             "root" : "data",
+             "xtype" : "JsonReader",
+             "$ xns" : "Roo.data",
+             "$ fields" : "[\n    {\n        'name': 'cohead_number',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_cust_id_cust_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_custponumber',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_type'\n    },\n    {\n        'name': 'cohead_orderdate',\n        'type': 'date'\n    },\n    {\n        'name': 'cohead_shipto_id_shipto_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_terms_id_terms_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_curr_id_curr_name',\n        'type': 'string'\n    }\n]",
+             "* prop" : "reader",
+             "totalProperty" : "total",
+             "# builderCfg" : "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}"
+            }
+           ]
+          },
+          {
+           "pageSize" : 25,
+           "xtype" : "PagingToolbar",
+           "emptyMsg" : "No cohead found",
+           "$ xns" : "Roo",
+           "displayInfo" : true,
+           "displayMsg" : "Displaying cohead{0} - {1} of {2}",
+           "* prop" : "footer",
+           "items" : [
+            {
+             "listeners" : {
+              "click" : "function ()\n{\n    new Pman.Download({\n        grid : _this.grid,\n        newWindow : true,\n        timeout : 6000000,\n        method : 'POST'\n    });     \n   \n}"
+             },
+             "text" : "Download Results",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "rootURL + '/Pman/templates/images/spreadsheet.gif'",
+             "$ xns" : "Roo.Toolbar"
+            }
+           ]
+          },
+          {
+           "xtype" : "Toolbar",
+           "$ xns" : "Roo",
+           "* prop" : "toolbar",
+           "items" : [
+            {
+             "listeners" : {
+              "click" : "function (_self, e)\n{\n Pman.Dialog.XtupleInvHistory.show({\n \n \n    });\n}"
+             },
+             "text" : "Quick Stock Check",
+             "xtype" : "Button",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "text" : "Import",
+             "xtype" : "Button",
+             "$ xns" : "Roo.Toolbar",
+             "items" : [
+              {
+               "xtype" : "Menu",
+               "$ xns" : "Roo.menu",
+               "* prop" : "menu",
+               "items" : [
+                {
+                 "listeners" : {
+                  "click" : "function (_self, e)\n{\n   Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/Magento',\n            timeout : 90000\n        \n       },\n       function (data) {\n            Roo.MessageBox.alert(\"Notice\", data); \n            _this.grid.footer.onClick('first');\n\n       }\n   );\n}"
+                 },
+                 "text" : "Magento Upload",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu"
+                },
+                {
+                 "listeners" : {
+                  "click" : "function (_self, e)\n{\n    Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {\n        Pman.Dialog.Image.show({\n            timeout : 900000,\n            _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)\n        }, function(data) {\n            Roo.MessageBox.alert('Success', data);\n            _this.grid.footer.onClick('first');\n        });\n    }); \n}"
+                 },
+                 "text" : "Import HSBC csv file",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu"
+                },
                 {
-                    "xtype": "BorderLayout",
-                    "|xns": "Roo",
-                    "*prop": "layout",
-                    "items": [
-                        {
-                            "xtype": "LayoutRegion",
-                            "|xns": "Roo",
-                            "*prop": "west",
-                            "width": "200",
-                            "split": true,
-                            "title": "Search"
-                        },
-                        {
-                            "xtype": "LayoutRegion",
-                            "|xns": "Roo",
-                            "*prop": "center"
-                        },
-                        {
-                            "listeners": {
-                                "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
-                            },
-                            ".builderCfg": "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
-                            "background": true,
-                            "fitContainer": true,
-                            "fitToframe": true,
-                            "region": "center",
-                            "tableName": "cohead",
-                            "title": "cohead",
-                            "xtype": "GridPanel",
-                            "|xns": "Roo",
-                            "items": [
-                                {
-                                    "listeners": {
-                                        "|render": "function() \n{\n    _this.grid = this; \n    try { \n        _this.dialog = Pman.Dialog.XtupleSalesOrder;\n    } catch(e) {}\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
-                                        "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('refresh');\n        Pman.Tab.XtupleSales.grid.footer.onClick('first');\n    }); \n}\n"
-                                    },
-                                    "*prop": "grid",
-                                    "autoExpandColumn": "cohead_cust_id_cust_name",
-                                    "loadMask": true,
-                                    "xtype": "Grid",
-                                    "|xns": "Roo.grid",
-                                    "items": [
-                                        {
-                                            "listeners": {
-                                                "beforeload": "function (_self, options)\n{\n    var vl;\n    try { \n         vl = _this.form.getFieldValues();\n     } catch (e) {\n        vl = {};\n     }\n\n     \n     \n    for(var x in vl) {\n        if (!(new String(vl[x])).length) {\n            continue;\n        }\n        options.params[x] = vl[x];\n        \n    }\n    try {\n        if (options.params['query[cohead_number]'].length) {\n            options.params.viewtype = 'REALALL';\n        }\n    } catch (e) {}\n}"
-                                            },
-                                            "*prop": "dataSource",
-                                            ".builderCfg": "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
-                                            "remoteSort": true,
-                                            "xtype": "Store",
-                                            "|sortInfo": "{ field : 'cohead_orderdate', direction: 'DESC' }",
-                                            "|xns": "Roo.data",
-                                            "items": [
-                                                {
-                                                    "*prop": "proxy",
-                                                    "method": "GET",
-                                                    "timeout": 60000,
-                                                    "xtype": "HttpProxy",
-                                                    "|url": "baseURL + '/Roo/cohead.php'",
-                                                    "|xns": "Roo.data"
-                                                },
-                                                {
-                                                    "|xns": "Roo.data",
-                                                    "xtype": "JsonReader",
-                                                    "totalProperty": "total",
-                                                    "root": "data",
-                                                    ".builderCfg": "{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
-                                                    "*prop": "reader",
-                                                    "id": "id",
-                                                    "|fields": "[\n    {\n        'name': 'cohead_number',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_cust_id_cust_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_custponumber',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_type'\n    },\n    {\n        'name': 'cohead_orderdate',\n        'type': 'date'\n    },\n    {\n        'name': 'cohead_shipto_id_shipto_name',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_terms_id_terms_descrip',\n        'type': 'string'\n    },\n    {\n        'name': 'cohead_curr_id_curr_name',\n        'type': 'string'\n    }\n]"
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "*prop": "footer",
-                                            "xtype": "PagingToolbar",
-                                            "pageSize": 25,
-                                            "displayInfo": true,
-                                            "displayMsg": "Displaying cohead{0} - {1} of {2}",
-                                            "emptyMsg": "No cohead found",
-                                            "|xns": "Roo",
-                                            "items": [
-                                                {
-                                                    "listeners": {
-                                                        "click": "function ()\n{\n    new Pman.Download({\n        grid : _this.grid,\n        newWindow : true,\n        timeout : 6000000,\n        method : 'POST'\n    });     \n   \n}"
-                                                    },
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Download Results",
-                                                    "xtype": "Button",
-                                                    "|icon": "rootURL + '/Pman/templates/images/spreadsheet.gif'",
-                                                    "|xns": "Roo.Toolbar"
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "*prop": "toolbar",
-                                            "xtype": "Toolbar",
-                                            "|xns": "Roo",
-                                            "items": [
-                                                {
-                                                    "listeners": {
-                                                        "click": "function (_self, e)\n{\n Pman.Dialog.XtupleInvHistory.show({\n \n \n    });\n}"
-                                                    },
-                                                    "text": "Quick Stock Check",
-                                                    "xtype": "Button",
-                                                    "|xns": "Roo.Toolbar"
-                                                },
-                                                {
-                                                    "text": "Import",
-                                                    "xtype": "Button",
-                                                    "|xns": "Roo.Toolbar",
-                                                    "items": [
-                                                        {
-                                                            "|xns": "Roo.menu",
-                                                            "xtype": "Menu",
-                                                            "*prop": "menu",
-                                                            "items": [
-                                                                {
-                                                                    "listeners": {
-                                                                        "click": "function (_self, e)\n{\n   Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/Magento',\n            timeout : 90000\n        \n       },\n       function (data) {\n            Roo.MessageBox.alert(\"Notice\", data); \n            _this.grid.footer.onClick('first');\n\n       }\n   );\n}"
-                                                                    },
-                                                                    "text": "Magento Upload",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu"
-                                                                },
-                                                                {
-                                                                    "listeners": {
-                                                                        "click": "function (_self, e)\n{\n    Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {\n        Pman.Dialog.Image.show({\n            timeout : 900000,\n            _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)\n        }, function(data) {\n            Roo.MessageBox.alert('Success', data);\n            _this.grid.footer.onClick('first');\n        });\n    }); \n}"
-                                                                    },
-                                                                    "text": "Import HSBC csv file",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu"
-                                                                },
-                                                                {
-                                                                    "listeners": {
-                                                                        "click": "function (_self, e)\n{\n   Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/WayBill',\n            timeout : 900000\n        \n       },\n       function (data) {\n            Roo.MessageBox.alert(\"Notice\", data); \n            _this.grid.footer.onClick('first');\n       }\n   );\n}"
-                                                                    },
-                                                                    "text": "Import Waybill Delivery",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu"
-                                                                }
-                                                            ]
-                                                        }
-                                                    ]
-                                                },
-                                                {
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Reports",
-                                                    "xtype": "Button",
-                                                    "|icon": "rootURL + '/Pman/templates/images/spreadsheet.gif'",
-                                                    "|xns": "Roo.Toolbar",
-                                                    "items": [
-                                                        {
-                                                            "|xns": "Roo.menu",
-                                                            "xtype": "Menu",
-                                                            "*prop": "menu",
-                                                            "items": [
-                                                                {
-                                                                    "text": "AR Aging",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu",
-                                                                    "items": [
-                                                                        {
-                                                                            "|xns": "Roo.menu",
-                                                                            "xtype": "Menu",
-                                                                            "*prop": "menu",
-                                                                            "items": [
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n    if(!from || !to){\n        Roo.Msg.alert('Error', 'Please select a date range for the report');\n        return;\n    }\n    \n    var params  =   {\n        template: 'ARAging',\n        filename : 'ARAging-' + to.format('Y-m-d'),\n        'param[0]':   \"startDate:string='\" + from.format('Y-m-d') + \"'\",\n        'param[1]':   \"relDate:string='\" + to.format('Y-m-d') + \"'\",\n        'param[2]':   \"useDocDate:number=1\"\n    };\n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['param[3]'] = 'cust_id:number=' + cust_id;\n    }\n \n    new Pman.Download({\n      url : baseURL + '/Xtuple/Print',\n      params :   params,\n      method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                                                    },
-                                                                                    "text": "as PDF",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                },
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n   \n    \n    var params = {\n        '_group' : 'arAging',\n        '_name' : 'bydate',\n        'limit' : 99999,\n        \n          'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n     \n        \n        \n        'useDocDate:text' : 'TRUE',\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    \n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['cust_id:number'] = cust_id;\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
-                                                                                    },
-                                                                                    "text": "as Excel",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                },
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n   \n    \n    var params = {\n        '_group' : 'arAging',\n        '_name' : 'summary',\n        'limit' : 99999,\n        \n        \n      \n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n     \n        \n        'useDocDate:text' : 'TRUE',\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['cust_id:number'] = cust_id;\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
-                                                                                    },
-                                                                                    "text": "Summary Excel",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                }
-                                                                            ]
-                                                                        }
-                                                                    ]
-                                                                },
-                                                                {
-                                                                    "text": "Customer History",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu",
-                                                                    "items": [
-                                                                        {
-                                                                            "|xns": "Roo.menu",
-                                                                            "xtype": "Menu",
-                                                                            "*prop": "menu",
-                                                                            "items": [
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n    if(!from || !to){\n        Roo.Msg.alert('Error', 'Please select a date range for the report');\n        return;\n    }\n    \n    var params  =   {\n        template: 'customer_ar_history',\n        filename : 'customer_ar_history-' + to.format('Y-m-d'),\n        'param[0]':   \"startDate:string='\" + from.format('Y-m-d') + \"'\",\n        'param[1]':   \"endDate:string='\" + to.format('Y-m-d') + \"'\",\n        'param[2]':   \"cust_id:number=\" + cust_id\n    };\n         \n    new Pman.Download({\n        url : baseURL + '/Xtuple/Print',\n        params :   params,\n        method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                                                    },
-                                                                                    "text": "as PDF",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                },
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n  \n    \n    var params = {\n        '_group' : 'customerHistory',\n        '_name' : 'detail',\n        'limit' : 99999,\n        \n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n       \n        'cust_id:number' : cust_id,\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                                                    },
-                                                                                    "text": "as Excel",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                }
-                                                                            ]
-                                                                        }
-                                                                    ]
-                                                                },
-                                                                {
-                                                                    "text": "Customer Statement",
-                                                                    "xtype": "Item",
-                                                                    "|xns": "Roo.menu",
-                                                                    "items": [
-                                                                        {
-                                                                            "|xns": "Roo.menu",
-                                                                            "xtype": "Menu",
-                                                                            "*prop": "menu",
-                                                                            "items": [
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n \n     \n    var params  =   {\n        template: 'customer_ar_statement',\n        filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),\n        'param[0]':   \"startDate:string='\" + (from ? from.format('Y-m-d') : '2000-01-01') + \"'\",\n        'param[1]':   \"asofdate:string='\" + (to ? to.format('Y-m-d') : '2100-01-01')+ \"'\",\n        'param[2]':   \"cust_id:number=\" + cust_id\n    };\n    \n    new Pman.Download({\n        url : baseURL + '/Xtuple/Print',\n        params :   params,\n        method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                                                    },
-                                                                                    "text": "as PDF",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                },
-                                                                                {
-                                                                                    "listeners": {
-                                                                                        "click": "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n   var from = _this.form.findField('_fromdate').getValue();\n   var to = _this.form.findField('_todate').getValue();\n\n    //if(!from || !to){\n    //    Roo.Msg.alert('Error', 'Please select a date range for the report');\n    //    return;\n    //}\n    \n    var params = {\n        '_group' : 'customerStatement',\n        '_name' : 'detail',\n        'limit' : 99999,\n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n        'cust_id:number' : cust_id,\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                                                    },
-                                                                                    "text": "as Excel",
-                                                                                    "xtype": "Item",
-                                                                                    "|xns": "Roo.menu"
-                                                                                }
-                                                                            ]
-                                                                        }
-                                                                    ]
-                                                                }
-                                                            ]
-                                                        }
-                                                    ]
-                                                },
-                                                {
-                                                    "listeners": {
-                                                        "|click": "function (_self, e)\n{\n    var sels = _this.grid.getSelectionModel().getSelections();\n    \n    if (!sels.length) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order\");\n        return;\n    }\n    var ids = [];\n    for (var i =0; i < sels.length; i++) {\n        var s = sels[i];    \n        \n        if(s.data.cohead_qtyuninvoiced * 1 > 0){\n            Roo.MessageBox.alert(\"Error\", \"Order has not been invoiced! - \" + s.data.cohead_number);\n            return;\n        }\n        \n        if(s.data.aropen_unpaid * 1 > 0){\n            Roo.MessageBox.alert(\"Error\", \"Order has not been paid! - \"  + s.data.cohead_number);\n            return;\n        }\n        ids.push(s.data.cohead_id);\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',\r\n      params :   {\n            cohead_id : ids.join(',')\n      },\r\n      method : 'GET'\r\n    });\r\n    \n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
-                                                    },
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Email to warehouse",
-                                                    "xtype": "Button",
-                                                    "|icon": "Roo.rootURL + 'images/default/dd/email.gif'",
-                                                    "|xns": "Roo.Toolbar"
-                                                },
-                                                {
-                                                    "listeners": {
-                                                        "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelected();\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order to close\");\n        return;\n    }\n    \n    if(s.data.cohead_status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This order has been closed\");\n        return;\n    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure?\",\n        function(v) {\n            if (v != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                url: baseURL + '/Roo/cohead',\n                method : 'POST',\n                params :  {\n                    cohead_id : s.data.cohead_id,\n                    _close : 1\n                },\n                mask : 'Sending',\n                success : function()\n                {\n                    Roo.MessageBox.alert(\"Notice\", \"DONE\");\n                    _this.grid.footer.onClick('first');\n                }\n           });\n        }\n    );\n    \n    \n}\n"
-                                                    },
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Complete and Close",
-                                                    "xtype": "Button",
-                                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
-                                                    "|xns": "Roo.Toolbar"
-                                                },
-                                                {
-                                                    "listeners": {
-                                                        "|click": "function()\n{\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/cohead',\n        method : 'POST',\n        params :  {\n            _clearUnpaid : 1\n        },\n        mask : 'Clearing',\n        success : function()\n        {\n            Roo.MessageBox.alert(\"Notice\", \"DONE\");\n            _this.grid.footer.onClick('first');\n        }\n   });\n    \n}\n"
-                                                    },
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Clear Unpaid Orders",
-                                                    "xtype": "Button",
-                                                    "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
-                                                    "|xns": "Roo.Toolbar"
-                                                },
-                                                {
-                                                    "xtype": "Fill",
-                                                    "|xns": "Roo.Toolbar"
-                                                },
-                                                {
-                                                    "listeners": {
-                                                        "|click": "function()\n{\n   // check if the login in user have more than 25 open orders..\n   // if yes, warning...\n   new Pman.Request({\n        url : baseURL + '/Roo/cohead.php',\n        method :'GET',\n        params : {\n            viewtype : 'MYOPEN',\n            _count_order : 1 // make the search faster!\n        },\n        success : function(res) {\n            if(res.data[0].order_totals * 1 > 25){\n                Roo.MessageBox.alert(\"Warning\", \"Can you please close old orders before creating new ones\");\n            }\n        }\n    });\n   \n   Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \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 s = _this.grid.getSelectionModel().getSelected();\n   if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order to copy\");\n        return;\n   }\n   \n   \n   Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {\n   \n        // get the id from the data, then \n   \n        _this.grid.footer.onClick('first');\n        Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        // get the id from the data, then start editing it..\n        Roo.log(data);\n            _this.dialog.show(data,  function() {\n            _this.grid.footer.onClick('refresh');\n            Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        }); \n        \n   }); \n}\n"
-                                                    },
-                                                    "cls": "x-btn-text-icon",
-                                                    "text": "Copy",
-                                                    "xtype": "Button",
-                                                    "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
-                                                    "|xns": "Roo.Toolbar"
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}",
-                                            "dataIndex": "cohead_orderdate",
-                                            "header": "Ordered",
-                                            "sortable": true,
-                                            "width": 75,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            "dataIndex": "cohead_targetdate",
-                                            "header": "Target Delivery",
-                                            "hidden": true,
-                                            "sortable": true,
-                                            "width": 75,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}",
-                                            "dataIndex": "cohead_salesrep_id_salesrep_name",
-                                            "header": "Staff IC.",
-                                            "sortable": true,
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v,x,r) { \n\n    if (r.data.cohead_display_salesrep_id) {\n        return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);\n    }\n    return String.format('{0}', v );\n    \n    \n }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            "dataIndex": "cohead_number",
-                                            "header": "#order",
-                                            "sortable": true,
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v,x,r) {\n\n      \n      // we want to show more detail about status..\n      // like payment status / delivery etc...\n      \n      // I = invoiced\n      // R = Reserved\n      // S = shipped (or partial shipped)\n      // P = paid (or partial paid)\n      // online payment failed? >> on terms?\n      // \n      var tags = {\n        invoiced : '<span class=\"dragon-so-complete\" qtip=\"Invoiced\">I</span>',\n        invoiced_not : '<span class=\"dragon-so-complete-not\"  qtip=\"Not Invoiced\">I</span>',\n        stock_not : '<span class=\"dragon-so-complete-not\" qtip=\"Stock not reserved or shipped\">S</span>',        \n        stock_reserved : '<span class=\"dragon-so-complete-part\" qtip=\"Stock Reserved / Not shipped\">R</span>',\n        stock_shipped : '<span class=\"dragon-so-complete\" qtip=\"Shipped\">S</span>',\n        paid : '<span class=\"dragon-so-complete\" qtip=\"Paid\">P</span>',\n        paid_not : '<span class=\"dragon-so-complete-not\" qtip=\"Not Paid\">P</span>'\n    };        \n     \n     // invoiced\n     var tg = '';\n     \n       // stock status...\n     if (r.data.cohead_qtyunshipped > 0) {\n          \n          tg +=  (r.data.shipitem_qty*1 > 0)  ? tags.stock_reserved :tags.stock_not;\n     }     else {\n     \n         tg +=  tags.stock_shipped;\n    }\n     \n     tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;\n     // ?? partially invoiced??\n     \n     \n     if (r.data.cohead_qtyuninvoiced*1 < 1) {\n          tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;\n      }\n     \n     \n     \n    // payment status??\n\n      if (r.data.cohead_status == 'C') {\n          return tg + ' ' + String.format('<i qtip=\"closed\">{0}</i>', v); \n      }\n      if (r.data.cohead_status == 'X') {\n          return tg + ' ' +  String.format('<s qtip=\"void\">{0}</s>', v)  ; \n      }\n      return tg + ' ' + String.format('{0}', v); \n }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}",
-                                            "dataIndex": "cohead_cust_id_cust_number",
-                                            "header": "Customer#",
-                                            "sortable": true,
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}",
-                                            "dataIndex": "cohead_cust_id_cust_name",
-                                            "header": "Customer",
-                                            "sortable": true,
-                                            "width": 200,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"}",
-                                            "dataIndex": "cohead_custponumber",
-                                            "header": "Cust. PO#",
-                                            "width": 50,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"}",
-                                            "dataIndex": "cohead_type",
-                                            "header": "Type",
-                                            "width": 50,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            "dataIndex": "cohead_src_locations",
-                                            "header": "From",
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"}",
-                                            "dataIndex": "cohead_shiptoaddress1",
-                                            "header": "Ship to",
-                                            "width": 200,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            ".builderCfg": "{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"}",
-                                            "dataIndex": "cohead_terms_id_terms_descrip",
-                                            "header": "Terms",
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            "dataIndex": "cohead_ordercomments",
-                                            "header": "Notes",
-                                            "hidden": true,
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v) { return String.format('{0}', v); }",
-                                            "|xns": "Roo.grid"
-                                        },
-                                        {
-                                            "*prop": "colModel[]",
-                                            "align": "right",
-                                            "dataIndex": "cohead_total",
-                                            "header": "Total",
-                                            "width": 100,
-                                            "xtype": "ColumnModel",
-                                            "|renderer": "function(v,x,r) { \n    var ret =  String.format('{0} {1}',\n         r.data.cohead_curr_id_curr_name, v ?   parseFloat(v).toFixed(3) : '---'\n     ); \n     \n     if (parseInt(r.data.cohead_qtyordered)  != 0 && \n        parseInt(r.data.cohead_unshipped) == 0 && \n         parseInt(r.data.cohead_qtyunshipped) == 0 &&\n         parseInt(r.data.cohead_qtyuninvoiced) == 0 &&         \n          parseInt(r.data.cohead_unshipped) == 0 &&\n         parseInt(r.data.cohead_uninvoiced) == 0 \n     ) {\n        return ret;\n    }\n     \n     return String.format('<b style=\"color:red\" ' + \n            'qtip=\"Products: {3} ({4}) &lt;BR/&gt;Unshipped: {1} ({5})&lt;BR&gt;Uninvoiced: {2} ({6})\">{0}</b>',\n         ret, \n            r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,\n            r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced\n         );\n     \n }",
-                                            "|xns": "Roo.grid"
-                                        }
-                                    ]
-                                }
-                            ]
-                        },
-                        {
-                            "background": false,
-                            "region": "west",
-                            "xtype": "ContentPanel",
-                            "|xns": "Roo",
-                            "items": [
-                                {
-                                    "|xns": "Roo",
-                                    "xtype": "Toolbar",
-                                    "*prop": "toolbar",
-                                    "items": [
-                                        {
-                                            "|xns": "Roo.Toolbar",
-                                            "xtype": "Fill"
-                                        },
-                                        {
-                                            "listeners": {
-                                                "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
-                                            },
-                                            "cls": "x-btn-icon",
-                                            "xtype": "Button",
-                                            "|icon": "rootURL + '/Pman/templates/images/search.gif'",
-                                            "|xns": "Roo.Toolbar"
-                                        },
-                                        {
-                                            "listeners": {
-                                                "|click": "function (_self, e)\n{\n    _this.form.reset('');\n\n    \n    _this.grid.footer.onClick('first');\n}"
-                                            },
-                                            "cls": "x-btn-icon",
-                                            "xtype": "Button",
-                                            "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'",
-                                            "|xns": "Roo.Toolbar"
-                                        }
-                                    ]
-                                },
-                                {
-                                    "listeners": {
-                                        "|rendered": "function (form)\n{\n    _this.form= form;\n}\n"
-                                    },
-                                    "labelAlign": "top",
-                                    "method": "POST",
-                                    "style": "margin:5px;",
-                                    "xtype": "Form",
-                                    "|xns": "Roo.form",
-                                    "items": [
-                                        {
-                                            "listeners": {
-                                                "|select": "function (combo, record, index)\n{\n  _this.grid.footer.onClick('first');\n}",
-                                                "|render": "function (_self)\n{\n  _this.viewtypeSel = _self;\n}"
-                                            },
-                                            "allowBlank": false,
-                                            "displayField": "value",
-                                            "editable": false,
-                                            "emptyText": "View type",
-                                            "fieldLabel": "View",
-                                            "forceSelection": true,
-                                            "listWidth": 200,
-                                            "loadingText": "Searching...",
-                                            "minChars": 2,
-                                            "name": "viewtype",
-                                            "pageSize": 20,
-                                            "qtip": "Select Action",
-                                            "queryParam": "query[action]",
-                                            "selectOnFocus": true,
-                                            "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{value}</b> </div>",
-                                            "triggerAction": "all",
-                                            "typeAhead": true,
-                                            "value": "MYOPEN",
-                                            "valueField": "key",
-                                            "width": 150,
-                                            "xtype": "ComboBox",
-                                            "|xns": "Roo.form",
-                                            "items": [
-                                                {
-                                                    "*prop": "store",
-                                                    "id": 0,
-                                                    "xtype": "SimpleStore",
-                                                    "|data": "[\n  [ 'MYOPEN', 'My Open orders' ],\n  [ 'MYCLOSED', 'My Closed orders' ],\n  [ 'MYALL', 'My orders (all)' ],    \n  [ 'MYVOID', 'My Voided orders' ],      \n  [ 'OPEN', 'All Open orders' ],\n  [ 'NOTSHIPPED', 'All Un-shipped orders' ],\n  [ 'NOTPAID', 'All Un-paid orders' ],\n  [ 'PAIDNOTSHIPPED', 'All paid / not shipped orders' ],  \n  [ 'CLOSED', 'All Closed orders' ],\n  \n  [ 'ALL', 'All orders' ],\n  [ 'VOID', 'Voided orders' ],\n  [ 'INCOMPLETE', 'Incomplete orders' ],  \n  [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],\n//  [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],  \n//  [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,\n  [ 'FIFOBUG', 'Problems with FIFO' ] \n    \n]",
-                                                    "|fields": "[ 'key', 'value' ]",
-                                                    "|xns": "Roo.data"
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "listeners": {
-                                                "select": "function (combo, record, index)\n{\n    (function() { _this.grid.footer.onClick('first'); }).defer(100);\n}",
-                                                "specialkey": "function (_self, e)\n{\n    //Roo.log(e.getKey());\n    if (e.getKey() == 13) {\n        (function() { _this.grid.footer.onClick('first'); }).defer(100);\n        e.stopEvent();\n        _this.rsearch = true;\n    }\n    \n}",
-                                                "beforequery": "function (combo, query, forceAll, cancel, e)\n{\n \n   if( _this.rsearch) {\n        _this.rsearch =false;\n        return false;\n    }\n \n}"
-                                            },
-                                            "allowBlank": true,
-                                            "displayField": "cohead_number",
-                                            "editable": true,
-                                            "emptyText": "Select Order",
-                                            "fieldLabel": "Order #",
-                                            "forceSelection": false,
-                                            "listWidth": 400,
-                                            "loadingText": "Searching...",
-                                            "minChars": 2,
-                                            "name": "query[cohead_number]",
-                                            "pageSize": 20,
-                                            "qtip": "Select Order",
-                                            "queryParam": "query[cohead_number]",
-                                            "selectOnFocus": true,
-                                            "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{cohead_number}</b> </div>",
-                                            "triggerAction": "all",
-                                            "typeAhead": false,
-                                            "valueField": "cohead_number",
-                                            "width": 180,
-                                            "xtype": "ComboBox",
-                                            "|xns": "Roo.form",
-                                            "items": [
-                                                {
-                                                    "listeners": {
-                                                        "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    o.params['_columns'] = 'cohead_number';\n    // set more here\n}\n"
-                                                    },
-                                                    "*prop": "store",
-                                                    "remoteSort": true,
-                                                    "xtype": "Store",
-                                                    "|sortInfo": "{ direction : 'ASC', field: 'cohead_number' }",
-                                                    "|xns": "Roo.data",
-                                                    "items": [
-                                                        {
-                                                            "*prop": "proxy",
-                                                            "method": "GET",
-                                                            "xtype": "HttpProxy",
-                                                            "|url": "baseURL + '/Roo/cohead.php'",
-                                                            "|xns": "Roo.data"
-                                                        },
-                                                        {
-                                                            "*prop": "reader",
-                                                            "id": "cohead_number",
-                                                            "root": "data",
-                                                            "totalProperty": "total",
-                                                            "xtype": "JsonReader",
-                                                            "|fields": "[\"cohead_number\"]",
-                                                            "|xns": "Roo.data"
-                                                        }
-                                                    ]
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "listeners": {
-                                                "select": "function (combo, record, index)\n{\n       (function() { _this.grid.footer.onClick('first'); }).defer(100);\n}"
-                                            },
-                                            "allowBlank": true,
-                                            "displayField": "cust_name",
-                                            "editable": true,
-                                            "emptyText": "Select custinfo",
-                                            "fieldLabel": "Customer",
-                                            "forceSelection": true,
-                                            "hiddenName": "cohead_cust_id",
-                                            "listWidth": 400,
-                                            "loadingText": "Searching...",
-                                            "minChars": 2,
-                                            "name": "cohead_cust_id_cust_name",
-                                            "pageSize": 20,
-                                            "qtip": "Select custinfo",
-                                            "queryParam": "query[cust_name]",
-                                            "selectOnFocus": true,
-                                            "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b>  ({cust_number})</div>",
-                                            "triggerAction": "all",
-                                            "typeAhead": false,
-                                            "valueField": "cust_id",
-                                            "width": 180,
-                                            "xtype": "ComboBox",
-                                            "|xns": "Roo.form",
-                                            "items": [
-                                                {
-                                                    "*prop": "store",
-                                                    "|xns": "Roo.data",
-                                                    "|sortInfo": "{ direction : 'ASC', field: 'cust_name' }",
-                                                    "xtype": "Store",
-                                                    "remoteSort": true,
-                                                    "listeners": {
-                                                        "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
-                                                    },
-                                                    "items": [
-                                                        {
-                                                            "*prop": "proxy",
-                                                            "xtype": "HttpProxy",
-                                                            "method": "GET",
-                                                            "|xns": "Roo.data",
-                                                            "|url": "baseURL + '/Roo/custinfo.php'"
-                                                        },
-                                                        {
-                                                            "*prop": "reader",
-                                                            "xtype": "JsonReader",
-                                                            "|xns": "Roo.data",
-                                                            "id": "cust_id",
-                                                            "root": "data",
-                                                            "totalProperty": "total",
-                                                            "|fields": "[{\"name\":\"cust_id\",\"type\":\"int\"},\"cust_name\"]"
-                                                        }
-                                                    ]
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "listeners": {
-                                                "select": "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}"
-                                            },
-                                            "fieldLabel": "From",
-                                            "format": "Y-m-d",
-                                            "name": "_fromdate",
-                                            "width": 100,
-                                            "xtype": "DateField",
-                                            "|xns": "Roo.form"
-                                        },
-                                        {
-                                            "listeners": {
-                                                "select": "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}"
-                                            },
-                                            "fieldLabel": "To",
-                                            "format": "Y-m-d",
-                                            "name": "_todate",
-                                            "width": 100,
-                                            "xtype": "DateField",
-                                            "|xns": "Roo.form"
-                                        }
-                                    ]
-                                }
-                            ]
-                        }
-                    ]
+                 "listeners" : {
+                  "click" : "function (_self, e)\n{\n   Pman.Dialog.Image.show(\n       {\n            _url : baseURL+'/Xtuple/Import/WayBill',\n            timeout : 900000\n        \n       },\n       function (data) {\n            Roo.MessageBox.alert(\"Notice\", data); \n            _this.grid.footer.onClick('first');\n       }\n   );\n}"
+                 },
+                 "text" : "Import Waybill Delivery",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu"
                 }
-            ]
+               ]
+              }
+             ]
+            },
+            {
+             "text" : "Reports",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "rootURL + '/Pman/templates/images/spreadsheet.gif'",
+             "$ xns" : "Roo.Toolbar",
+             "items" : [
+              {
+               "xtype" : "Menu",
+               "$ xns" : "Roo.menu",
+               "* prop" : "menu",
+               "items" : [
+                {
+                 "text" : "AR Aging",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu",
+                 "items" : [
+                  {
+                   "xtype" : "Menu",
+                   "$ xns" : "Roo.menu",
+                   "* prop" : "menu",
+                   "items" : [
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n    if(!from || !to){\n        Roo.Msg.alert('Error', 'Please select a date range for the report');\n        return;\n    }\n    \n    var params  =   {\n        template: 'ARAging',\n        filename : 'ARAging-' + to.format('Y-m-d'),\n        'param[0]':   \"startDate:string='\" + from.format('Y-m-d') + \"'\",\n        'param[1]':   \"relDate:string='\" + to.format('Y-m-d') + \"'\",\n        'param[2]':   \"useDocDate:number=1\"\n    };\n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['param[3]'] = 'cust_id:number=' + cust_id;\n    }\n \n    new Pman.Download({\n      url : baseURL + '/Xtuple/Print',\n      params :   params,\n      method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                     },
+                     "text" : "as PDF",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    },
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n   \n    \n    var params = {\n        '_group' : 'arAging',\n        '_name' : 'bydate',\n        'limit' : 99999,\n        \n          'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n     \n        \n        \n        'useDocDate:text' : 'TRUE',\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    \n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['cust_id:number'] = cust_id;\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
+                     },
+                     "text" : "as Excel",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    },
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n   \n    \n    var params = {\n        '_group' : 'arAging',\n        '_name' : 'summary',\n        'limit' : 99999,\n        \n        \n      \n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n     \n        \n        'useDocDate:text' : 'TRUE',\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    var cust_id =     _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 > 0) {\n        params['cust_id:number'] = cust_id;\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\r\n    \r\n}"
+                     },
+                     "text" : "Summary Excel",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    }
+                   ]
+                  }
+                 ]
+                },
+                {
+                 "text" : "Customer History",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu",
+                 "items" : [
+                  {
+                   "xtype" : "Menu",
+                   "$ xns" : "Roo.menu",
+                   "* prop" : "menu",
+                   "items" : [
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n    if(!from || !to){\n        Roo.Msg.alert('Error', 'Please select a date range for the report');\n        return;\n    }\n    \n    var params  =   {\n        template: 'customer_ar_history',\n        filename : 'customer_ar_history-' + to.format('Y-m-d'),\n        'param[0]':   \"startDate:string='\" + from.format('Y-m-d') + \"'\",\n        'param[1]':   \"endDate:string='\" + to.format('Y-m-d') + \"'\",\n        'param[2]':   \"cust_id:number=\" + cust_id\n    };\n         \n    new Pman.Download({\n        url : baseURL + '/Xtuple/Print',\n        params :   params,\n        method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                     },
+                     "text" : "as PDF",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    },
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n  \n    \n    var params = {\n        '_group' : 'customerHistory',\n        '_name' : 'detail',\n        'limit' : 99999,\n        \n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n       \n        'cust_id:number' : cust_id,\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n    \n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                     },
+                     "text" : "as Excel",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    }
+                   ]
+                  }
+                 ]
+                },
+                {
+                 "text" : "Customer Statement",
+                 "xtype" : "Item",
+                 "$ xns" : "Roo.menu",
+                 "items" : [
+                  {
+                   "xtype" : "Menu",
+                   "$ xns" : "Roo.menu",
+                   "* prop" : "menu",
+                   "items" : [
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n    var from = _this.form.findField('_fromdate').getValue();\n    var to = _this.form.findField('_todate').getValue();\n    \n \n     \n    var params  =   {\n        template: 'customer_ar_statement',\n        filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),\n        'param[0]':   \"startDate:string='\" + (from ? from.format('Y-m-d') : '2000-01-01') + \"'\",\n        'param[1]':   \"asofdate:string='\" + (to ? to.format('Y-m-d') : '2100-01-01')+ \"'\",\n        'param[2]':   \"cust_id:number=\" + cust_id\n    };\n    \n    new Pman.Download({\n        url : baseURL + '/Xtuple/Print',\n        params :   params,\n        method : 'GET'\n    });\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                     },
+                     "text" : "as PDF",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    },
+                    {
+                     "listeners" : {
+                      "click" : "function (_self, e)\n{\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if (cust_id * 1 < 1) {\n        Roo.Msg.alert('Error', 'Please select a customer');\n        return;\n    }\n    \n   var from = _this.form.findField('_fromdate').getValue();\n   var to = _this.form.findField('_todate').getValue();\n\n    //if(!from || !to){\n    //    Roo.Msg.alert('Error', 'Please select a date range for the report');\n    //    return;\n    //}\n    \n    var params = {\n        '_group' : 'customerStatement',\n        '_name' : 'detail',\n        'limit' : 99999,\n        'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,\n        'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',\n        'cust_id:number' : cust_id,\n        'csvTitles' : '*',\n        'csvCols' : '*'\n    };\n\n    \n    new Pman.Download({\r\n      url : baseURL + '/Roo/Metasql',\r\n      params :   params,\r\n      method : 'GET'\r\n    });\r\n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+                     },
+                     "text" : "as Excel",
+                     "xtype" : "Item",
+                     "$ xns" : "Roo.menu"
+                    }
+                   ]
+                  }
+                 ]
+                }
+               ]
+              }
+             ]
+            },
+            {
+             "listeners" : {
+              "|click" : "function (_self, e)\n{\n    var sels = _this.grid.getSelectionModel().getSelections();\n    \n    if (!sels.length) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order\");\n        return;\n    }\n    var ids = [];\n    for (var i =0; i < sels.length; i++) {\n        var s = sels[i];    \n        \n        if(s.data.cohead_qtyuninvoiced * 1 > 0){\n            Roo.MessageBox.alert(\"Error\", \"Order has not been invoiced! - \" + s.data.cohead_number);\n            return;\n        }\n        \n        if(s.data.aropen_unpaid * 1 > 0){\n            Roo.MessageBox.alert(\"Error\", \"Order has not been paid! - \"  + s.data.cohead_number);\n            return;\n        }\n        ids.push(s.data.cohead_id);\n    }\n    \n    new Pman.Download({\r\n      url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',\r\n      params :   {\n            cohead_id : ids.join(',')\n      },\r\n      method : 'GET'\r\n    });\r\n    \n    Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n}"
+             },
+             "text" : "Email to warehouse",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "Roo.rootURL + 'images/default/dd/email.gif'",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "listeners" : {
+              "|click" : "function()\n{\n    var s = _this.grid.getSelectionModel().getSelected();\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order to close\");\n        return;\n    }\n    \n    if(s.data.cohead_status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This order has been closed\");\n        return;\n    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure?\",\n        function(v) {\n            if (v != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                url: baseURL + '/Roo/cohead',\n                method : 'POST',\n                params :  {\n                    cohead_id : s.data.cohead_id,\n                    _close : 1\n                },\n                mask : 'Sending',\n                success : function()\n                {\n                    Roo.MessageBox.alert(\"Notice\", \"DONE\");\n                    _this.grid.footer.onClick('first');\n                }\n           });\n        }\n    );\n    \n    \n}\n"
+             },
+             "text" : "Complete and Close",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "listeners" : {
+              "|click" : "function()\n{\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/cohead',\n        method : 'POST',\n        params :  {\n            _clearUnpaid : 1\n        },\n        mask : 'Clearing',\n        success : function()\n        {\n            Roo.MessageBox.alert(\"Notice\", \"DONE\");\n            _this.grid.footer.onClick('first');\n        }\n   });\n    \n}\n"
+             },
+             "text" : "Clear Unpaid Orders",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "xtype" : "Fill",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "listeners" : {
+              "|click" : "function()\n{\n   // check if the login in user have more than 25 open orders..\n   // if yes, warning...\n   new Pman.Request({\n        url : baseURL + '/Roo/cohead.php',\n        method :'GET',\n        params : {\n            viewtype : 'MYOPEN',\n            _count_order : 1 // make the search faster!\n        },\n        success : function(res) {\n            if(res.data[0].order_totals * 1 > 25){\n                Roo.MessageBox.alert(\"Warning\", \"Can you please close old orders before creating new ones\");\n            }\n        }\n    });\n   \n   Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
+             },
+             "text" : "Add",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
+             "$ xns" : "Roo.Toolbar"
+            },
+            {
+             "listeners" : {
+              "|click" : "function()\n{\n   var s = _this.grid.getSelectionModel().getSelected();\n   if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an order to copy\");\n        return;\n   }\n   \n   \n   Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {\n   \n        // get the id from the data, then \n   \n        _this.grid.footer.onClick('first');\n        Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        // get the id from the data, then start editing it..\n        Roo.log(data);\n            _this.dialog.show(data,  function() {\n            _this.grid.footer.onClick('refresh');\n            Pman.Tab.XtupleSales.grid.footer.onClick('first');\n        }); \n        \n   }); \n}\n"
+             },
+             "text" : "Copy",
+             "xtype" : "Button",
+             "cls" : "x-btn-text-icon",
+             "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
+             "$ xns" : "Roo.Toolbar"
+            }
+           ]
+          },
+          {
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "Ordered",
+           "width" : 75,
+           "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_orderdate",
+           "# builderCfg" : "{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}"
+          },
+          {
+           "hidden" : true,
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "Target Delivery",
+           "width" : 75,
+           "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_targetdate"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "Staff IC.",
+           "width" : 100,
+           "$ renderer" : "function(v,x,r) { \n\n    if (r.data.cohead_display_salesrep_id) {\n        return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);\n    }\n    return String.format('{0}', v );\n    \n    \n }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_salesrep_id_salesrep_name",
+           "# builderCfg" : "{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "#order",
+           "width" : 100,
+           "$ renderer" : "function(v,x,r) {\n\n      \n      // we want to show more detail about status..\n      // like payment status / delivery etc...\n      \n      // I = invoiced\n      // R = Reserved\n      // S = shipped (or partial shipped)\n      // P = paid (or partial paid)\n      // online payment failed? >> on terms?\n      // \n      var tags = {\n        invoiced : '<span class=\"dragon-so-complete\" qtip=\"Invoiced\">I</span>',\n        invoiced_not : '<span class=\"dragon-so-complete-not\"  qtip=\"Not Invoiced\">I</span>',\n        stock_not : '<span class=\"dragon-so-complete-not\" qtip=\"Stock not reserved or shipped\">S</span>',        \n        stock_reserved : '<span class=\"dragon-so-complete-part\" qtip=\"Stock Reserved / Not shipped\">R</span>',\n        stock_shipped : '<span class=\"dragon-so-complete\" qtip=\"Shipped\">S</span>',\n        paid : '<span class=\"dragon-so-complete\" qtip=\"Paid\">P</span>',\n        paid_not : '<span class=\"dragon-so-complete-not\" qtip=\"Not Paid\">P</span>'\n    };        \n     \n     // invoiced\n     var tg = '';\n     \n       // stock status...\n     if (r.data.cohead_qtyunshipped > 0) {\n          \n          tg +=  (r.data.shipitem_qty*1 > 0)  ? tags.stock_reserved :tags.stock_not;\n     }     else {\n     \n         tg +=  tags.stock_shipped;\n    }\n     \n     tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;\n     // ?? partially invoiced??\n     \n     \n     if (r.data.cohead_qtyuninvoiced*1 < 1) {\n          tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;\n      }\n     \n     \n     \n    // payment status??\n\n      if (r.data.cohead_status == 'C') {\n          return tg + ' ' + String.format('<i qtip=\"closed\">{0}</i>', v); \n      }\n      if (r.data.cohead_status == 'X') {\n          return tg + ' ' +  String.format('<s qtip=\"void\">{0}</s>', v)  ; \n      }\n      return tg + ' ' + String.format('{0}', v); \n }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_number"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "Customer#",
+           "width" : 100,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_cust_id_cust_number",
+           "# builderCfg" : "{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "sortable" : true,
+           "header" : "Customer",
+           "width" : 200,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_cust_id_cust_name",
+           "# builderCfg" : "{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "header" : "Cust. PO#",
+           "width" : 50,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_custponumber",
+           "# builderCfg" : "{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "header" : "Type",
+           "width" : 50,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_type",
+           "# builderCfg" : "{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "header" : "From",
+           "width" : 100,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_src_locations"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "header" : "Ship to",
+           "width" : 200,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_shiptoaddress1",
+           "# builderCfg" : "{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"}"
+          },
+          {
+           "xtype" : "ColumnModel",
+           "header" : "Terms",
+           "width" : 100,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_terms_id_terms_descrip",
+           "# builderCfg" : "{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"}"
+          },
+          {
+           "hidden" : true,
+           "xtype" : "ColumnModel",
+           "header" : "Notes",
+           "width" : 100,
+           "$ renderer" : "function(v) { return String.format('{0}', v); }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_ordercomments"
+          },
+          {
+           "align" : "right",
+           "xtype" : "ColumnModel",
+           "header" : "Total",
+           "width" : 100,
+           "$ renderer" : "function(v,x,r) { \n    var ret =  String.format('{0} {1}',\n         r.data.cohead_curr_id_curr_name, v ?   parseFloat(v).toFixed(3) : '---'\n     ); \n     \n     if (parseInt(r.data.cohead_qtyordered)  != 0 && \n        parseInt(r.data.cohead_unshipped) == 0 && \n         parseInt(r.data.cohead_qtyunshipped) == 0 &&\n         parseInt(r.data.cohead_qtyuninvoiced) == 0 &&         \n          parseInt(r.data.cohead_unshipped) == 0 &&\n         parseInt(r.data.cohead_uninvoiced) == 0 \n     ) {\n        return ret;\n    }\n     \n     return String.format('<b style=\"color:red\" ' + \n            'qtip=\"Products: {3} ({4}) &lt;BR/&gt;Unshipped: {1} ({5})&lt;BR&gt;Uninvoiced: {2} ({6})\">{0}</b>',\n         ret, \n            r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,\n            r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced\n         );\n     \n }",
+           "$ xns" : "Roo.grid",
+           "* prop" : "colModel[]",
+           "dataIndex" : "cohead_total"
+          }
+         ]
+        }
+       ]
+      },
+      {
+       "background" : false,
+       "region" : "west",
+       "xtype" : "ContentPanel",
+       "$ xns" : "Roo",
+       "items" : [
+        {
+         "xtype" : "Toolbar",
+         "$ xns" : "Roo",
+         "* prop" : "toolbar",
+         "items" : [
+          {
+           "xtype" : "Fill",
+           "$ xns" : "Roo.Toolbar"
+          },
+          {
+           "listeners" : {
+            "|click" : "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
+           },
+           "xtype" : "Button",
+           "cls" : "x-btn-icon",
+           "$ icon" : "rootURL + '/Pman/templates/images/search.gif'",
+           "$ xns" : "Roo.Toolbar"
+          },
+          {
+           "listeners" : {
+            "|click" : "function (_self, e)\n{\n    _this.form.reset('');\n\n    \n    _this.grid.footer.onClick('first');\n}"
+           },
+           "xtype" : "Button",
+           "cls" : "x-btn-icon",
+           "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
+           "$ xns" : "Roo.Toolbar"
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
+         },
+         "labelAlign" : "top",
+         "style" : "margin:5px;",
+         "method" : "POST",
+         "xtype" : "Form",
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "|render" : "function (_self)\n{\n  _this.viewtypeSel = _self;\n}",
+            "|select" : "function (combo, record, index)\n{\n  _this.grid.footer.onClick('first');\n}"
+           },
+           "listWidth" : 200,
+           "triggerAction" : "all",
+           "fieldLabel" : "View",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "value",
+           "emptyText" : "View type",
+           "minChars" : 2,
+           "value" : "MYOPEN",
+           "valueField" : "key",
+           "xtype" : "ComboBox",
+           "allowBlank" : false,
+           "typeAhead" : true,
+           "editable" : false,
+           "width" : 150,
+           "$ xns" : "Roo.form",
+           "name" : "viewtype",
+           "qtip" : "Select Action",
+           "queryParam" : "query[action]",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{value}</b> </div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "id" : 0,
+             "xtype" : "SimpleStore",
+             "$ data" : "[\n  [ 'MYOPEN', 'My Open orders' ],\n  [ 'MYCLOSED', 'My Closed orders' ],\n  [ 'MYALL', 'My orders (all)' ],    \n  [ 'MYVOID', 'My Voided orders' ],      \n  [ 'OPEN', 'All Open orders' ],\n  [ 'NOTSHIPPED', 'All Un-shipped orders' ],\n  [ 'NOTPAID', 'All Un-paid orders' ],\n  [ 'PAIDNOTSHIPPED', 'All paid / not shipped orders' ],  \n  [ 'CLOSED', 'All Closed orders' ],\n  \n  [ 'ALL', 'All orders' ],\n  [ 'VOID', 'Voided orders' ],\n  [ 'INCOMPLETE', 'Incomplete orders' ],  \n  [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],\n//  [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],  \n//  [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,\n  [ 'FIFOBUG', 'Problems with FIFO' ] \n    \n]",
+             "$ fields" : "[ 'key', 'value' ]",
+             "$ xns" : "Roo.data",
+             "* prop" : "store"
+            }
+           ]
+          },
+          {
+           "listeners" : {
+            "specialkey" : "function (_self, e)\n{\n    //Roo.log(e.getKey());\n    if (e.getKey() == 13) {\n        (function() { _this.grid.footer.onClick('first'); }).defer(100);\n        e.stopEvent();\n        _this.rsearch = true;\n    }\n    \n}",
+            "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n \n   if( _this.rsearch) {\n        _this.rsearch =false;\n        return false;\n    }\n \n}",
+            "select" : "function (combo, record, index)\n{\n    (function() { _this.grid.footer.onClick('first'); }).defer(100);\n}"
+           },
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Order #",
+           "forceSelection" : false,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "cohead_number",
+           "emptyText" : "Select Order",
+           "minChars" : 2,
+           "valueField" : "cohead_number",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : false,
+           "editable" : true,
+           "width" : 180,
+           "$ xns" : "Roo.form",
+           "name" : "query[cohead_number]",
+           "qtip" : "Select Order",
+           "queryParam" : "query[cohead_number]",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{cohead_number}</b> </div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    o.params['_columns'] = 'cohead_number';\n    // set more here\n}\n"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ direction : 'ASC', field: 'cohead_number' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/cohead.php'",
+               "xtype" : "HttpProxy",
+               "method" : "GET",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "cohead_number",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[\"cohead_number\"]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "listeners" : {
+            "select" : "function (combo, record, index)\n{\n       (function() { _this.grid.footer.onClick('first'); }).defer(100);\n}"
+           },
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Customer",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "cust_name",
+           "emptyText" : "Select custinfo",
+           "hiddenName" : "cohead_cust_id",
+           "minChars" : 2,
+           "valueField" : "cust_id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : false,
+           "editable" : true,
+           "width" : 180,
+           "$ xns" : "Roo.form",
+           "name" : "cohead_cust_id_cust_name",
+           "qtip" : "Select custinfo",
+           "queryParam" : "query[cust_name]",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b>  ({cust_number})</div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ direction : 'ASC', field: 'cust_name' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/custinfo.php'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "cust_id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ xns" : "Roo.data",
+               "$ fields" : "[{\"name\":\"cust_id\",\"type\":\"int\"},\"cust_name\"]",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "listeners" : {
+            "select" : "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}"
+           },
+           "fieldLabel" : "From",
+           "format" : "Y-m-d",
+           "xtype" : "DateField",
+           "width" : 100,
+           "$ xns" : "Roo.form",
+           "name" : "_fromdate"
+          },
+          {
+           "listeners" : {
+            "select" : "function (combo, date)\n{\n    _this.grid.footer.onClick('first');\n}"
+           },
+           "fieldLabel" : "To",
+           "format" : "Y-m-d",
+           "xtype" : "DateField",
+           "width" : 100,
+           "$ xns" : "Roo.form",
+           "name" : "_todate"
+          }
+         ]
         }
-    ],
-    "permname": "",
-    "modOrder": "001"
+       ]
+      }
+     ]
+    }
+   ]
+  }
+ ]
 }
\ No newline at end of file
index 1cc3fad..6c03ca1 100644 (file)
 
 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
 
+Roo.namespace('Pman.Tab');
+
 Pman.Tab.XtupleSalesOrder = new Roo.XComponent({
-    part     :  ["Xtuple","SalesOrder"],
-    order    : '001-Pman.Tab.XtupleSalesOrder',
-    region   : 'center',
-    parent   : 'Pman.Tab.XtupleSales',
-    name     : "unnamed module",
-    disabled : false, 
-    permname : '', 
-    _tree : function()
-    {
-        var _this = this;
-        var MODULE = this;
-        return {
-            xtype: 'NestedLayoutPanel',
-            xns: Roo,
-            listeners : {
-                activate : function (_self)
-                {
-                    this.setTitle('Sales Orders (' + Pman.Login.authUser.dbname +')');
+
+ _strings : {
+  'fdb35c1a9883acaa94378144a114dfe6' :"Cust. PO#",
+  'a8929eb5c1553d3f70497f862d25d0ce' :"Select Action",
+  '3bd9a9f36601eeb35d5afce4dcfbfce5' :"No cohead found",
+  '6f1bf85c9ebb3c7fa26251e1e335e032' :"Terms",
+  'd2fd3c49554ebcce7e57b85dfa682160' :"Displaying cohead{0} - {1} of {2}",
+  '72d6d7a1885885bb55a565fd1070581a' :"Import",
+  '36dc4ac22a9c9aa45d359e55937499da' :"as PDF",
+  '051f291b80c3336fc75368454ca2a8d2' :"Import HSBC csv file",
+  'f313afd5710eeea203821d3201cc27d8' :"Email to warehouse",
+  'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
+  'd1228f5476d15142b1358ae4b5fa2454' :"Order #",
+  'bf2234cf486127ba73efe4b2986eed78' :"Customer Statement",
+  'bcc3c81377e8aef6878f3048ad3e1845' :"cohead",
+  'be99bd9be2f6204e18d9be098b1cec84' :"AR Aging",
+  'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
+  'ce26601dac0dea138b7295f02b7620a7' :"Customer",
+  '1243daf593fa297e07ab03bf06d925af' :"Searching...",
+  '3f7488c396d3d4e015d8886452db4110' :"Staff IC.",
+  '4351cfebe4b61d8aa5efa1d020710005' :"View",
+  'f38ab62162b94b4978679aeca58a270c' :"Select Order",
+  '8f3e1295a3a1d30b6ee5d8de6e0b8c0a' :"as Excel",
+  '13348442cc6a27032d2b4aa28b75a5d3' :"Search",
+  '26e09a1ee1517389c7b07f42df65561a' :"Ordered",
+  '8db91c5e3376bc85414ebca9c53fb53f' :"MYOPEN",
+  '904062c33353866aa5234f35ed29e114' :"Download Results",
+  '959462c653dede23e7152b97b45a8aa5' :"Clear Unpaid Orders",
+  '3e208ad5d41ca414bb432adbb7d39c33' :"View type",
+  '4d02be4779719ea23232946e4a34aa82' :"Magento Upload",
+  '74002cb040b036511b8d031da591364a' :"Ship to",
+  '5da618e8e4b89c66fe86e32cdafde142' :"From",
+  'ebe043e4c90950fe50c8a95d96af10f5' :"Quick Stock Check",
+  '54ca6e7fdb43298ae82cd9cb04e77f9b' :"#order",
+  'c91c7b93c28cd18741b71f727ee81ee3' :"Reports",
+  '96b0141273eabab320119c467cdcaf17' :"Total",
+  '99360e60ce244a99256c131555f20d4e' :"Sales Orders",
+  '1c5b744a085a30924e4436c89a79027e' :"Complete and Close",
+  'a2fdeac60e3c5b6c51a92e027fb9d533' :"Target Delivery",
+  '5fb63579fc981698f97d55bfecb213ea' :"Copy",
+  'b155bf2beaeeb2018389eded7c74b56f' :"Customer History",
+  'b0ca9fe87723f63f290ec66b891ec9ee' :"Import Waybill Delivery",
+  '2d899459cc25ea99ea2573d592860ec8' :"Customer#",
+  'fce6d3795b41b54dc0dab82df50517c1' :"Select custinfo",
+  'e12167aa0a7698e6ebc92b4ce3909b53' :"To",
+  'd720bb04db44a8269a09bea3b90352f4' :"Summary Excel",
+  'f4c6f851b00d5518bf888815de279aba' :"Notes"
+ },
+
+  part     :  ["Xtuple", "SalesOrder" ],
+  order    : '001-Pman.Tab.XtupleSalesOrder',
+  region   : 'center',
+  parent   : 'Pman.Tab.XtupleSales',
+  name     : "unnamed module",
+  disabled : false, 
+  permname : '', 
+  _tree : function()
+  {
+   var _this = this;
+   var MODULE = this;
+   return {
+   region : 'center',
+   title : _this._strings['99360e60ce244a99256c131555f20d4e'] /* Sales Orders */,
+   xns : Roo,
+   '|xns' : 'Roo',
+   xtype : 'NestedLayoutPanel',
+   listeners : {
+    activate : function (_self)
+     {
+         this.setTitle('Sales Orders (' + Pman.Login.authUser.dbname +')');
+     }
+   },
+   layout : {
+    xns : Roo,
+    '|xns' : 'Roo',
+    xtype : 'BorderLayout',
+    center : {
+     xns : Roo,
+     '|xns' : 'Roo',
+     xtype : 'LayoutRegion'
+    },
+    west : {
+     split : true,
+     title : _this._strings['13348442cc6a27032d2b4aa28b75a5d3'] /* Search */,
+     width : 200,
+     xns : Roo,
+     '|xns' : 'Roo',
+     xtype : 'LayoutRegion'
+    },
+    items  : [
+     {
+      background : true,
+      builderCfg : '{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
+      fitContainer : true,
+      fitToframe : true,
+      region : 'center',
+      tableName : 'cohead',
+      title : _this._strings['bcc3c81377e8aef6878f3048ad3e1845'] /* cohead */,
+      xns : Roo,
+      '|xns' : 'Roo',
+      xtype : 'GridPanel',
+      listeners : {
+       activate : function() {
+            _this.panel = this;
+            if (_this.grid) {
+                _this.grid.footer.onClick('first');
+            }
+        }
+      },
+      grid : {
+       autoExpandColumn : 'cohead_cust_id_cust_name',
+       loadMask : true,
+       xns : Roo.grid,
+       '|xns' : 'Roo.grid',
+       xtype : 'Grid',
+       listeners : {
+        render : function() 
+         {
+             _this.grid = this; 
+             try { 
+                 _this.dialog = Pman.Dialog.XtupleSalesOrder;
+             } catch(e) {}
+             if (_this.panel.active) {
+                this.footer.onClick('first');
+             }
+         },
+        rowdblclick : function (_self, rowIndex, e)
+         {
+             if (!_this.dialog) return;
+             _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
+                 _this.grid.footer.onClick('refresh');
+                 Pman.Tab.XtupleSales.grid.footer.onClick('first');
+             }); 
+         }
+       },
+       footer : {
+        displayInfo : true,
+        displayMsg : _this._strings['d2fd3c49554ebcce7e57b85dfa682160'] /* Displaying cohead{0} - {1} of {2} */,
+        emptyMsg : _this._strings['3bd9a9f36601eeb35d5afce4dcfbfce5'] /* No cohead found */,
+        pageSize : 25,
+        xns : Roo,
+        '|xns' : 'Roo',
+        xtype : 'PagingToolbar',
+        items  : [
+         {
+          cls : 'x-btn-text-icon',
+          icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
+          text : _this._strings['904062c33353866aa5234f35ed29e114'] /* Download Results */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function ()
+            {
+                new Pman.Download({
+                    grid : _this.grid,
+                    newWindow : true,
+                    timeout : 6000000,
+                    method : 'POST'
+                });     
+               
+            }
+          }
+         }
+        ]
+       },
+       toolbar : {
+        xns : Roo,
+        '|xns' : 'Roo',
+        xtype : 'Toolbar',
+        items  : [
+         {
+          text : _this._strings['ebe043e4c90950fe50c8a95d96af10f5'] /* Quick Stock Check */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function (_self, e)
+            {
+             Pman.Dialog.XtupleInvHistory.show({
+             
+             
+                });
+            }
+          }
+         },
+         {
+          text : _this._strings['72d6d7a1885885bb55a565fd1070581a'] /* Import */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          menu : {
+           xns : Roo.menu,
+           '|xns' : 'Roo.menu',
+           xtype : 'Menu',
+           items  : [
+            {
+             text : _this._strings['4d02be4779719ea23232946e4a34aa82'] /* Magento Upload */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             listeners : {
+              click : function (_self, e)
+               {
+                  Pman.Dialog.Image.show(
+                      {
+                           _url : baseURL+'/Xtuple/Import/Magento',
+                           timeout : 90000
+                       
+                      },
+                      function (data) {
+                           Roo.MessageBox.alert("Notice", data); 
+                           _this.grid.footer.onClick('first');
+               
+                      }
+                  );
+               }
+             }
+            },
+            {
+             text : _this._strings['051f291b80c3336fc75368454ca2a8d2'] /* Import HSBC csv file */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             listeners : {
+              click : function (_self, e)
+               {
+                   Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
+                       Pman.Dialog.Image.show({
+                           timeout : 900000,
+                           _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
+                       }, function(data) {
+                           Roo.MessageBox.alert('Success', data);
+                           _this.grid.footer.onClick('first');
+                       });
+                   }); 
+               }
+             }
+            },
+            {
+             text : _this._strings['b0ca9fe87723f63f290ec66b891ec9ee'] /* Import Waybill Delivery */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             listeners : {
+              click : function (_self, e)
+               {
+                  Pman.Dialog.Image.show(
+                      {
+                           _url : baseURL+'/Xtuple/Import/WayBill',
+                           timeout : 900000
+                       
+                      },
+                      function (data) {
+                           Roo.MessageBox.alert("Notice", data); 
+                           _this.grid.footer.onClick('first');
+                      }
+                  );
+               }
+             }
+            }
+           ]
+          }
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
+          text : _this._strings['c91c7b93c28cd18741b71f727ee81ee3'] /* Reports */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          menu : {
+           xns : Roo.menu,
+           '|xns' : 'Roo.menu',
+           xtype : 'Menu',
+           items  : [
+            {
+             text : _this._strings['be99bd9be2f6204e18d9be098b1cec84'] /* AR Aging */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             menu : {
+              xns : Roo.menu,
+              '|xns' : 'Roo.menu',
+              xtype : 'Menu',
+              items  : [
+               {
+                text : _this._strings['36dc4ac22a9c9aa45d359e55937499da'] /* as PDF */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                      if(!from || !to){
+                          Roo.Msg.alert('Error', 'Please select a date range for the report');
+                          return;
+                      }
+                      
+                      var params  =   {
+                          template: 'ARAging',
+                          filename : 'ARAging-' + to.format('Y-m-d'),
+                          'param[0]':   "startDate:string='" + from.format('Y-m-d') + "'",
+                          'param[1]':   "relDate:string='" + to.format('Y-m-d') + "'",
+                          'param[2]':   "useDocDate:number=1"
+                      };
+                      var cust_id =     _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 > 0) {
+                          params['param[3]'] = 'cust_id:number=' + cust_id;
+                      }
+                   
+                      new Pman.Download({
+                        url : baseURL + '/Xtuple/Print',
+                        params :   params,
+                        method : 'GET'
+                      });
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");
+                  }
+                }
+               },
+               {
+                text : _this._strings['8f3e1295a3a1d30b6ee5d8de6e0b8c0a'] /* as Excel */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                     
+                      
+                      var params = {
+                          '_group' : 'arAging',
+                          '_name' : 'bydate',
+                          'limit' : 99999,
+                          
+                            'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
+                          'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
+                       
+                          
+                          
+                          'useDocDate:text' : 'TRUE',
+                          'csvTitles' : '*',
+                          'csvCols' : '*'
+                      };
+                      
+                      
+                      var cust_id =     _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 > 0) {
+                          params['cust_id:number'] = cust_id;
+                      }
+                      
+                      new Pman.Download({\r
+                        url : baseURL + '/Roo/Metasql',\r
+                        params :   params,\r
+                        method : 'GET'\r
+                      });\r
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");\r
+                      \r
+                  }
                 }
+               },
+               {
+                text : _this._strings['d720bb04db44a8269a09bea3b90352f4'] /* Summary Excel */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                     
+                      
+                      var params = {
+                          '_group' : 'arAging',
+                          '_name' : 'summary',
+                          'limit' : 99999,
+                          
+                          
+                        
+                          'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
+                          'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
+                       
+                          
+                          'useDocDate:text' : 'TRUE',
+                          'csvTitles' : '*',
+                          'csvCols' : '*'
+                      };
+                      
+                      var cust_id =     _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 > 0) {
+                          params['cust_id:number'] = cust_id;
+                      }
+                      
+                      new Pman.Download({\r
+                        url : baseURL + '/Roo/Metasql',\r
+                        params :   params,\r
+                        method : 'GET'\r
+                      });\r
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");\r
+                      \r
+                  }
+                }
+               }
+              ]
+             }
             },
-            region : 'center',
-            title : "Sales Orders",
-            layout : {
-                xtype: 'BorderLayout',
-                xns: Roo,
-                items : [
-                    {
-                        xtype: 'GridPanel',
-                        xns: Roo,
-                        listeners : {
-                            activate : function() {
-                                _this.panel = this;
-                                if (_this.grid) {
-                                    _this.grid.footer.onClick('first');
-                                }
-                            }
-                        },
-                        background : true,
-                        fitContainer : true,
-                        fitToframe : true,
-                        region : 'center',
-                        tableName : 'cohead',
-                        title : "cohead",
-                        grid : {
-                            xtype: 'Grid',
-                            xns: Roo.grid,
-                            listeners : {
-                                render : function() 
-                                {
-                                    _this.grid = this; 
-                                    try { 
-                                        _this.dialog = Pman.Dialog.XtupleSalesOrder;
-                                    } catch(e) {}
-                                    if (_this.panel.active) {
-                                       this.footer.onClick('first');
-                                    }
-                                },
-                                rowdblclick : function (_self, rowIndex, e)
-                                {
-                                    if (!_this.dialog) return;
-                                    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
-                                        _this.grid.footer.onClick('refresh');
-                                        Pman.Tab.XtupleSales.grid.footer.onClick('first');
-                                    }); 
-                                }
-                            },
-                            autoExpandColumn : 'cohead_cust_id_cust_name',
-                            loadMask : true,
-                            dataSource : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                listeners : {
-                                    beforeload : function (_self, options)
-                                    {
-                                        var vl;
-                                        try { 
-                                             vl = _this.form.getFieldValues();
-                                         } catch (e) {
-                                            vl = {};
-                                         }
-                                    
-                                         
-                                         
-                                        for(var x in vl) {
-                                            if (!(new String(vl[x])).length) {
-                                                continue;
-                                            }
-                                            options.params[x] = vl[x];
-                                            
-                                        }
-                                        try {
-                                            if (options.params['query[cohead_number]'].length) {
-                                                options.params.viewtype = 'REALALL';
-                                            }
-                                        } catch (e) {}
-                                    }
-                                },
-                                remoteSort : true,
-                                sortInfo : { field : 'cohead_orderdate', direction: 'DESC' },
-                                proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
-                                    method : 'GET',
-                                    timeout : 60000,
-                                    url : baseURL + '/Roo/cohead.php'
-                                },
-                                reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
-                                    totalProperty : 'total',
-                                    root : 'data',
-                                    id : 'id',
-                                    fields : [
-                                        {
-                                            'name': 'cohead_number',
-                                            'type': 'string'
-                                        },
-                                        {
-                                            'name': 'cohead_cust_id_cust_name',
-                                            'type': 'string'
-                                        },
-                                        {
-                                            'name': 'cohead_custponumber',
-                                            'type': 'string'
-                                        },
-                                        {
-                                            'name': 'cohead_type'
-                                        },
-                                        {
-                                            'name': 'cohead_orderdate',
-                                            'type': 'date'
-                                        },
-                                        {
-                                            'name': 'cohead_shipto_id_shipto_name',
-                                            'type': 'string'
-                                        },
-                                        {
-                                            'name': 'cohead_terms_id_terms_descrip',
-                                            'type': 'string'
-                                        },
-                                        {
-                                            'name': 'cohead_curr_id_curr_name',
-                                            'type': 'string'
-                                        }
-                                    ]
-                                }
-                            },
-                            footer : {
-                                xtype: 'PagingToolbar',
-                                xns: Roo,
-                                pageSize : 25,
-                                displayInfo : true,
-                                displayMsg : "Displaying cohead{0} - {1} of {2}",
-                                emptyMsg : "No cohead found",
-                                items : [
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function ()
-                                            {
-                                                new Pman.Download({
-                                                    grid : _this.grid,
-                                                    newWindow : true,
-                                                    timeout : 6000000,
-                                                    method : 'POST'
-                                                });     
-                                               
-                                            }
-                                        },
-                                        cls : 'x-btn-text-icon',
-                                        text : "Download Results",
-                                        icon : rootURL + '/Pman/templates/images/spreadsheet.gif'
-                                    }
-                                ]
-                            },
-                            toolbar : {
-                                xtype: 'Toolbar',
-                                xns: Roo,
-                                items : [
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function (_self, e)
-                                            {
-                                             Pman.Dialog.XtupleInvHistory.show({
-                                             
-                                             
-                                                });
-                                            }
-                                        },
-                                        text : "Quick Stock Check"
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        text : "Import",
-                                        menu : {
-                                            xtype: 'Menu',
-                                            xns: Roo.menu,
-                                            items : [
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                           Pman.Dialog.Image.show(
-                                                               {
-                                                                    _url : baseURL+'/Xtuple/Import/Magento',
-                                                                    timeout : 90000
-                                                                
-                                                               },
-                                                               function (data) {
-                                                                    Roo.MessageBox.alert("Notice", data); 
-                                                                    _this.grid.footer.onClick('first');
-                                                        
-                                                               }
-                                                           );
-                                                        }
-                                                    },
-                                                    text : "Magento Upload"
-                                                },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                            Pman.Dialog.XtupleUploadHSBC.show( {} , function(res) {
-                                                                Pman.Dialog.Image.show({
-                                                                    timeout : 900000,
-                                                                    _url : baseURL + '/Xtuple/Import/HSBC?' + Roo.urlEncode(res)
-                                                                }, function(data) {
-                                                                    Roo.MessageBox.alert('Success', data);
-                                                                    _this.grid.footer.onClick('first');
-                                                                });
-                                                            }); 
-                                                        }
-                                                    },
-                                                    text : "Import HSBC csv file"
-                                                },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    listeners : {
-                                                        click : function (_self, e)
-                                                        {
-                                                           Pman.Dialog.Image.show(
-                                                               {
-                                                                    _url : baseURL+'/Xtuple/Import/WayBill',
-                                                                    timeout : 900000
-                                                                
-                                                               },
-                                                               function (data) {
-                                                                    Roo.MessageBox.alert("Notice", data); 
-                                                                    _this.grid.footer.onClick('first');
-                                                               }
-                                                           );
-                                                        }
-                                                    },
-                                                    text : "Import Waybill Delivery"
-                                                }
-                                            ]
-                                        }
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        cls : 'x-btn-text-icon',
-                                        text : "Reports",
-                                        icon : rootURL + '/Pman/templates/images/spreadsheet.gif',
-                                        menu : {
-                                            xtype: 'Menu',
-                                            xns: Roo.menu,
-                                            items : [
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "AR Aging",
-                                                    menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
-                                                        items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                        if(!from || !to){
-                                                                            Roo.Msg.alert('Error', 'Please select a date range for the report');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        var params  =   {
-                                                                            template: 'ARAging',
-                                                                            filename : 'ARAging-' + to.format('Y-m-d'),
-                                                                            'param[0]':   "startDate:string='" + from.format('Y-m-d') + "'",
-                                                                            'param[1]':   "relDate:string='" + to.format('Y-m-d') + "'",
-                                                                            'param[2]':   "useDocDate:number=1"
-                                                                        };
-                                                                        var cust_id =     _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 > 0) {
-                                                                            params['param[3]'] = 'cust_id:number=' + cust_id;
-                                                                        }
-                                                                     
-                                                                        new Pman.Download({
-                                                                          url : baseURL + '/Xtuple/Print',
-                                                                          params :   params,
-                                                                          method : 'GET'
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "as PDF"
-                                                            },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                       
-                                                                        
-                                                                        var params = {
-                                                                            '_group' : 'arAging',
-                                                                            '_name' : 'bydate',
-                                                                            'limit' : 99999,
-                                                                            
-                                                                              'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
-                                                                            'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
-                                                                         
-                                                                            
-                                                                            
-                                                                            'useDocDate:text' : 'TRUE',
-                                                                            'csvTitles' : '*',
-                                                                            'csvCols' : '*'
-                                                                        };
-                                                                        
-                                                                        
-                                                                        var cust_id =     _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 > 0) {
-                                                                            params['cust_id:number'] = cust_id;
-                                                                        }
-                                                                        
-                                                                        new Pman.Download({\r
-                                                                          url : baseURL + '/Roo/Metasql',\r
-                                                                          params :   params,\r
-                                                                          method : 'GET'\r
-                                                                        });\r
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");\r
-                                                                        \r
-                                                                    }
-                                                                },
-                                                                text : "as Excel"
-                                                            },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                       
-                                                                        
-                                                                        var params = {
-                                                                            '_group' : 'arAging',
-                                                                            '_name' : 'summary',
-                                                                            'limit' : 99999,
-                                                                            
-                                                                            
-                                                                          
-                                                                            'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
-                                                                            'relDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
-                                                                         
-                                                                            
-                                                                            'useDocDate:text' : 'TRUE',
-                                                                            'csvTitles' : '*',
-                                                                            'csvCols' : '*'
-                                                                        };
-                                                                        
-                                                                        var cust_id =     _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 > 0) {
-                                                                            params['cust_id:number'] = cust_id;
-                                                                        }
-                                                                        
-                                                                        new Pman.Download({\r
-                                                                          url : baseURL + '/Roo/Metasql',\r
-                                                                          params :   params,\r
-                                                                          method : 'GET'\r
-                                                                        });\r
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");\r
-                                                                        \r
-                                                                    }
-                                                                },
-                                                                text : "Summary Excel"
-                                                            }
-                                                        ]
-                                                    }
-                                                },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "Customer History",
-                                                    menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
-                                                        items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var cust_id = _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 < 1) {
-                                                                            Roo.Msg.alert('Error', 'Please select a customer');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                        if(!from || !to){
-                                                                            Roo.Msg.alert('Error', 'Please select a date range for the report');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        var params  =   {
-                                                                            template: 'customer_ar_history',
-                                                                            filename : 'customer_ar_history-' + to.format('Y-m-d'),
-                                                                            'param[0]':   "startDate:string='" + from.format('Y-m-d') + "'",
-                                                                            'param[1]':   "endDate:string='" + to.format('Y-m-d') + "'",
-                                                                            'param[2]':   "cust_id:number=" + cust_id
-                                                                        };
-                                                                             
-                                                                        new Pman.Download({
-                                                                            url : baseURL + '/Xtuple/Print',
-                                                                            params :   params,
-                                                                            method : 'GET'
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "as PDF"
-                                                            },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var cust_id = _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 < 1) {
-                                                                            Roo.Msg.alert('Error', 'Please select a customer');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                      
-                                                                        
-                                                                        var params = {
-                                                                            '_group' : 'customerHistory',
-                                                                            '_name' : 'detail',
-                                                                            'limit' : 99999,
-                                                                            
-                                                                            'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
-                                                                            'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
-                                                                           
-                                                                            'cust_id:number' : cust_id,
-                                                                            'csvTitles' : '*',
-                                                                            'csvCols' : '*'
-                                                                        };
-                                                                        
-                                                                        
-                                                                        new Pman.Download({\r
-                                                                          url : baseURL + '/Roo/Metasql',\r
-                                                                          params :   params,\r
-                                                                          method : 'GET'\r
-                                                                        });\r
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "as Excel"
-                                                            }
-                                                        ]
-                                                    }
-                                                },
-                                                {
-                                                    xtype: 'Item',
-                                                    xns: Roo.menu,
-                                                    text : "Customer Statement",
-                                                    menu : {
-                                                        xtype: 'Menu',
-                                                        xns: Roo.menu,
-                                                        items : [
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var cust_id = _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 < 1) {
-                                                                            Roo.Msg.alert('Error', 'Please select a customer');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                        var from = _this.form.findField('_fromdate').getValue();
-                                                                        var to = _this.form.findField('_todate').getValue();
-                                                                        
-                                                                     
-                                                                         
-                                                                        var params  =   {
-                                                                            template: 'customer_ar_statement',
-                                                                            filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
-                                                                            'param[0]':   "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
-                                                                            'param[1]':   "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
-                                                                            'param[2]':   "cust_id:number=" + cust_id
-                                                                        };
-                                                                        
-                                                                        new Pman.Download({
-                                                                            url : baseURL + '/Xtuple/Print',
-                                                                            params :   params,
-                                                                            method : 'GET'
-                                                                        });
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "as PDF"
-                                                            },
-                                                            {
-                                                                xtype: 'Item',
-                                                                xns: Roo.menu,
-                                                                listeners : {
-                                                                    click : function (_self, e)
-                                                                    {
-                                                                        var cust_id = _this.form.findField('cohead_cust_id').getValue();
-                                                                        if (cust_id * 1 < 1) {
-                                                                            Roo.Msg.alert('Error', 'Please select a customer');
-                                                                            return;
-                                                                        }
-                                                                        
-                                                                       var from = _this.form.findField('_fromdate').getValue();
-                                                                       var to = _this.form.findField('_todate').getValue();
-                                                                    
-                                                                        //if(!from || !to){
-                                                                        //    Roo.Msg.alert('Error', 'Please select a date range for the report');
-                                                                        //    return;
-                                                                        //}
-                                                                        
-                                                                        var params = {
-                                                                            '_group' : 'customerStatement',
-                                                                            '_name' : 'detail',
-                                                                            'limit' : 99999,
-                                                                            'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
-                                                                            'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
-                                                                            'cust_id:number' : cust_id,
-                                                                            'csvTitles' : '*',
-                                                                            'csvCols' : '*'
-                                                                        };
-                                                                    
-                                                                        
-                                                                        new Pman.Download({\r
-                                                                          url : baseURL + '/Roo/Metasql',\r
-                                                                          params :   params,\r
-                                                                          method : 'GET'\r
-                                                                        });\r
-                                                                        Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                                                    }
-                                                                },
-                                                                text : "as Excel"
-                                                            }
-                                                        ]
-                                                    }
-                                                }
-                                            ]
-                                        }
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function (_self, e)
-                                            {
-                                                var sels = _this.grid.getSelectionModel().getSelections();
-                                                
-                                                if (!sels.length) {
-                                                    Roo.MessageBox.alert("Error", "Select an order");
-                                                    return;
-                                                }
-                                                var ids = [];
-                                                for (var i =0; i < sels.length; i++) {
-                                                    var s = sels[i];    
-                                                    
-                                                    if(s.data.cohead_qtyuninvoiced * 1 > 0){
-                                                        Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
-                                                        return;
-                                                    }
-                                                    
-                                                    if(s.data.aropen_unpaid * 1 > 0){
-                                                        Roo.MessageBox.alert("Error", "Order has not been paid! - "  + s.data.cohead_number);
-                                                        return;
-                                                    }
-                                                    ids.push(s.data.cohead_id);
-                                                }
-                                                
-                                                new Pman.Download({\r
-                                                  url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',\r
-                                                  params :   {
-                                                        cohead_id : ids.join(',')
-                                                  },\r
-                                                  method : 'GET'\r
-                                                });\r
-                                                
-                                                Roo.MessageBox.alert("Notice", "Report will download shortly");
-                                            }
-                                        },
-                                        cls : 'x-btn-text-icon',
-                                        text : "Email to warehouse",
-                                        icon : Roo.rootURL + 'images/default/dd/email.gif'
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function()
-                                            {
-                                                var s = _this.grid.getSelectionModel().getSelected();
-                                                if (!s) {
-                                                    Roo.MessageBox.alert("Error", "Select an order to close");
-                                                    return;
-                                                }
-                                                
-                                                if(s.data.cohead_status == 'C'){
-                                                    Roo.MessageBox.alert("Error", "This order has been closed");
-                                                    return;
-                                                }
-                                                
-                                                Roo.MessageBox.confirm("Confirm", "Are you sure?",
-                                                    function(v) {
-                                                        if (v != 'yes') {
-                                                            return;
-                                                        }
-                                                        new Pman.Request({
-                                                            url: baseURL + '/Roo/cohead',
-                                                            method : 'POST',
-                                                            params :  {
-                                                                cohead_id : s.data.cohead_id,
-                                                                _close : 1
-                                                            },
-                                                            mask : 'Sending',
-                                                            success : function()
-                                                            {
-                                                                Roo.MessageBox.alert("Notice", "DONE");
-                                                                _this.grid.footer.onClick('first');
-                                                            }
-                                                       });
-                                                    }
-                                                );
-                                                
-                                                
-                                            }
-                                        },
-                                        cls : 'x-btn-text-icon',
-                                        text : "Complete and Close",
-                                        icon : Roo.rootURL + 'images/default/tree/leaf.gif'
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function()
-                                            {
-                                                
-                                                new Pman.Request({
-                                                    url: baseURL + '/Roo/cohead',
-                                                    method : 'POST',
-                                                    params :  {
-                                                        _clearUnpaid : 1
-                                                    },
-                                                    mask : 'Clearing',
-                                                    success : function()
-                                                    {
-                                                        Roo.MessageBox.alert("Notice", "DONE");
-                                                        _this.grid.footer.onClick('first');
-                                                    }
-                                               });
-                                                
-                                            }
-                                        },
-                                        cls : 'x-btn-text-icon',
-                                        text : "Clear Unpaid Orders",
-                                        icon : Roo.rootURL + 'images/default/tree/leaf.gif'
-                                    },
-                                    {
-                                        xtype: 'Fill',
-                                        xns: Roo.Toolbar
-                                    },
-                                    {
-                                        xtype: 'Button',
-                                        xns: Roo.Toolbar,
-                                        listeners : {
-                                            click : function()
-                                            {
-                                               // check if the login in user have more than 25 open orders..
-                                               // if yes, warning...
-                                               new Pman.Request({
-                                                    url : baseURL + '/Roo/cohead.php',
-                                                    method :'GET',
-                                                    params : {
-                                                        viewtype : 'MYOPEN',
-                                                        _count_order : 1 // make the search faster!
-                                                    },
-                                                    success : function(res) {
-                                                        if(res.data[0].order_totals * 1 > 25){
-                                                            Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
-                                                        }
-                                                    }
-                                                });
-                                               
-                                               Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
-                                                    _this.grid.footer.onClick('first');
-                                               }); 
-                                            }
-                                        },
-                                        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 s = _this.grid.getSelectionModel().getSelected();
-                                               if (!s) {
-                                                    Roo.MessageBox.alert("Error", "Select an order to copy");
-                                                    return;
-                                               }
-                                               
-                                               
-                                               Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
-                                               
-                                                    // get the id from the data, then 
-                                               
-                                                    _this.grid.footer.onClick('first');
-                                                    Pman.Tab.XtupleSales.grid.footer.onClick('first');
-                                                    // get the id from the data, then start editing it..
-                                                    Roo.log(data);
-                                                        _this.dialog.show(data,  function() {
-                                                        _this.grid.footer.onClick('refresh');
-                                                        Pman.Tab.XtupleSales.grid.footer.onClick('first');
-                                                    }); 
-                                                    
-                                               }); 
-                                            }
-                                        },
-                                        cls : 'x-btn-text-icon',
-                                        text : "Copy",
-                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
-                                    }
-                                ]
-                            },
-                            colModel : [
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_orderdate',
-                                    header : 'Ordered',
-                                    sortable : true,
-                                    width : 75,
-                                    renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_targetdate',
-                                    header : 'Target Delivery',
-                                    hidden : true,
-                                    sortable : true,
-                                    width : 75,
-                                    renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_salesrep_id_salesrep_name',
-                                    header : 'Staff IC.',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                    
-                                        if (r.data.cohead_display_salesrep_id) {
-                                            return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
-                                        }
-                                        return String.format('{0}', v );
-                                        
-                                        
-                                     }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_number',
-                                    header : '#order',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v,x,r) {
-                                    
-                                          
-                                          // we want to show more detail about status..
-                                          // like payment status / delivery etc...
-                                          
-                                          // I = invoiced
-                                          // R = Reserved
-                                          // S = shipped (or partial shipped)
-                                          // P = paid (or partial paid)
-                                          // online payment failed? >> on terms?
-                                          // 
-                                          var tags = {
-                                            invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
-                                            invoiced_not : '<span class="dragon-so-complete-not"  qtip="Not Invoiced">I</span>',
-                                            stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',        
-                                            stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
-                                            stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
-                                            paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
-                                            paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
-                                        };        
-                                         
-                                         // invoiced
-                                         var tg = '';
-                                         
-                                           // stock status...
-                                         if (r.data.cohead_qtyunshipped > 0) {
-                                              
-                                              tg +=  (r.data.shipitem_qty*1 > 0)  ? tags.stock_reserved :tags.stock_not;
-                                         }     else {
-                                         
-                                             tg +=  tags.stock_shipped;
-                                        }
-                                         
-                                         tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
-                                         // ?? partially invoiced??
-                                         
-                                         
-                                         if (r.data.cohead_qtyuninvoiced*1 < 1) {
-                                              tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
-                                          }
-                                         
-                                         
-                                         
-                                        // payment status??
-                                    
-                                          if (r.data.cohead_status == 'C') {
-                                              return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v); 
-                                          }
-                                          if (r.data.cohead_status == 'X') {
-                                              return tg + ' ' +  String.format('<s qtip="void">{0}</s>', v)  ; 
-                                          }
-                                          return tg + ' ' + String.format('{0}', v); 
-                                     }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_cust_id_cust_number',
-                                    header : 'Customer#',
-                                    sortable : true,
-                                    width : 100,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_cust_id_cust_name',
-                                    header : 'Customer',
-                                    sortable : true,
-                                    width : 200,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_custponumber',
-                                    header : 'Cust. PO#',
-                                    width : 50,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_type',
-                                    header : 'Type',
-                                    width : 50,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_src_locations',
-                                    header : 'From',
-                                    width : 100,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_shiptoaddress1',
-                                    header : 'Ship to',
-                                    width : 200,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_terms_id_terms_descrip',
-                                    header : 'Terms',
-                                    width : 100,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    dataIndex : 'cohead_ordercomments',
-                                    header : 'Notes',
-                                    hidden : true,
-                                    width : 100,
-                                    renderer : function(v) { return String.format('{0}', v); }
-                                },
-                                {
-                                    xtype: 'ColumnModel',
-                                    xns: Roo.grid,
-                                    align : 'right',
-                                    dataIndex : 'cohead_total',
-                                    header : 'Total',
-                                    width : 100,
-                                    renderer : function(v,x,r) { 
-                                        var ret =  String.format('{0} {1}',
-                                             r.data.cohead_curr_id_curr_name, v ?   parseFloat(v).toFixed(3) : '---'
-                                         ); 
-                                         
-                                         if (parseInt(r.data.cohead_qtyordered)  != 0 && 
-                                            parseInt(r.data.cohead_unshipped) == 0 && 
-                                             parseInt(r.data.cohead_qtyunshipped) == 0 &&
-                                             parseInt(r.data.cohead_qtyuninvoiced) == 0 &&         
-                                              parseInt(r.data.cohead_unshipped) == 0 &&
-                                             parseInt(r.data.cohead_uninvoiced) == 0 
-                                         ) {
-                                            return ret;
-                                        }
-                                         
-                                         return String.format('<b style="color:red" ' + 
-                                                'qtip="Products: {3} ({4}) &lt;BR/&gt;Unshipped: {1} ({5})&lt;BR&gt;Uninvoiced: {2} ({6})">{0}</b>',
-                                             ret, 
-                                                r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
-                                                r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
-                                             );
-                                         
-                                     }
-                                }
-                            ]
+            {
+             text : _this._strings['b155bf2beaeeb2018389eded7c74b56f'] /* Customer History */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             menu : {
+              xns : Roo.menu,
+              '|xns' : 'Roo.menu',
+              xtype : 'Menu',
+              items  : [
+               {
+                text : _this._strings['36dc4ac22a9c9aa45d359e55937499da'] /* as PDF */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var cust_id = _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 < 1) {
+                          Roo.Msg.alert('Error', 'Please select a customer');
+                          return;
+                      }
+                      
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                      if(!from || !to){
+                          Roo.Msg.alert('Error', 'Please select a date range for the report');
+                          return;
+                      }
+                      
+                      var params  =   {
+                          template: 'customer_ar_history',
+                          filename : 'customer_ar_history-' + to.format('Y-m-d'),
+                          'param[0]':   "startDate:string='" + from.format('Y-m-d') + "'",
+                          'param[1]':   "endDate:string='" + to.format('Y-m-d') + "'",
+                          'param[2]':   "cust_id:number=" + cust_id
+                      };
+                           
+                      new Pman.Download({
+                          url : baseURL + '/Xtuple/Print',
+                          params :   params,
+                          method : 'GET'
+                      });
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");
+                  }
+                }
+               },
+               {
+                text : _this._strings['8f3e1295a3a1d30b6ee5d8de6e0b8c0a'] /* as Excel */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var cust_id = _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 < 1) {
+                          Roo.Msg.alert('Error', 'Please select a customer');
+                          return;
+                      }
+                      
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                    
+                      
+                      var params = {
+                          '_group' : 'customerHistory',
+                          '_name' : 'detail',
+                          'limit' : 99999,
+                          
+                          'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
+                          'endDate:text' : to ? to.format('Y-m-d') : '2100-01-01',
+                         
+                          'cust_id:number' : cust_id,
+                          'csvTitles' : '*',
+                          'csvCols' : '*'
+                      };
+                      
+                      
+                      new Pman.Download({\r
+                        url : baseURL + '/Roo/Metasql',\r
+                        params :   params,\r
+                        method : 'GET'\r
+                      });\r
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");
+                  }
+                }
+               }
+              ]
+             }
+            },
+            {
+             text : _this._strings['bf2234cf486127ba73efe4b2986eed78'] /* Customer Statement */,
+             xns : Roo.menu,
+             '|xns' : 'Roo.menu',
+             xtype : 'Item',
+             menu : {
+              xns : Roo.menu,
+              '|xns' : 'Roo.menu',
+              xtype : 'Menu',
+              items  : [
+               {
+                text : _this._strings['36dc4ac22a9c9aa45d359e55937499da'] /* as PDF */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var cust_id = _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 < 1) {
+                          Roo.Msg.alert('Error', 'Please select a customer');
+                          return;
+                      }
+                      
+                      var from = _this.form.findField('_fromdate').getValue();
+                      var to = _this.form.findField('_todate').getValue();
+                      
+                   
+                       
+                      var params  =   {
+                          template: 'customer_ar_statement',
+                          filename : 'customer_ar_statement-' +(to ? to.format('Y-m-d') : '2100-01-01'),
+                          'param[0]':   "startDate:string='" + (from ? from.format('Y-m-d') : '2000-01-01') + "'",
+                          'param[1]':   "asofdate:string='" + (to ? to.format('Y-m-d') : '2100-01-01')+ "'",
+                          'param[2]':   "cust_id:number=" + cust_id
+                      };
+                      
+                      new Pman.Download({
+                          url : baseURL + '/Xtuple/Print',
+                          params :   params,
+                          method : 'GET'
+                      });
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");
+                  }
+                }
+               },
+               {
+                text : _this._strings['8f3e1295a3a1d30b6ee5d8de6e0b8c0a'] /* as Excel */,
+                xns : Roo.menu,
+                '|xns' : 'Roo.menu',
+                xtype : 'Item',
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var cust_id = _this.form.findField('cohead_cust_id').getValue();
+                      if (cust_id * 1 < 1) {
+                          Roo.Msg.alert('Error', 'Please select a customer');
+                          return;
+                      }
+                      
+                     var from = _this.form.findField('_fromdate').getValue();
+                     var to = _this.form.findField('_todate').getValue();
+                  
+                      //if(!from || !to){
+                      //    Roo.Msg.alert('Error', 'Please select a date range for the report');
+                      //    return;
+                      //}
+                      
+                      var params = {
+                          '_group' : 'customerStatement',
+                          '_name' : 'detail',
+                          'limit' : 99999,
+                          'startDate:text' : from ? from.format('Y-m-d') : '2000-01-01' ,
+                          'asofdate:text' : to ? to.format('Y-m-d') : '2100-01-01',
+                          'cust_id:number' : cust_id,
+                          'csvTitles' : '*',
+                          'csvCols' : '*'
+                      };
+                  
+                      
+                      new Pman.Download({\r
+                        url : baseURL + '/Roo/Metasql',\r
+                        params :   params,\r
+                        method : 'GET'\r
+                      });\r
+                      Roo.MessageBox.alert("Notice", "Report will download shortly");
+                  }
+                }
+               }
+              ]
+             }
+            }
+           ]
+          }
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/dd/email.gif',
+          text : _this._strings['f313afd5710eeea203821d3201cc27d8'] /* Email to warehouse */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function (_self, e)
+            {
+                var sels = _this.grid.getSelectionModel().getSelections();
+                
+                if (!sels.length) {
+                    Roo.MessageBox.alert("Error", "Select an order");
+                    return;
+                }
+                var ids = [];
+                for (var i =0; i < sels.length; i++) {
+                    var s = sels[i];    
+                    
+                    if(s.data.cohead_qtyuninvoiced * 1 > 0){
+                        Roo.MessageBox.alert("Error", "Order has not been invoiced! - " + s.data.cohead_number);
+                        return;
+                    }
+                    
+                    if(s.data.aropen_unpaid * 1 > 0){
+                        Roo.MessageBox.alert("Error", "Order has not been paid! - "  + s.data.cohead_number);
+                        return;
+                    }
+                    ids.push(s.data.cohead_id);
+                }
+                
+                new Pman.Download({\r
+                  url : baseURL + '/Xtuple/Reports/SalesOrderBookingDetail',\r
+                  params :   {
+                        cohead_id : ids.join(',')
+                  },\r
+                  method : 'GET'\r
+                });\r
+                
+                Roo.MessageBox.alert("Notice", "Report will download shortly");
+            }
+          }
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/tree/leaf.gif',
+          text : _this._strings['1c5b744a085a30924e4436c89a79027e'] /* Complete and Close */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function()
+            {
+                var s = _this.grid.getSelectionModel().getSelected();
+                if (!s) {
+                    Roo.MessageBox.alert("Error", "Select an order to close");
+                    return;
+                }
+                
+                if(s.data.cohead_status == 'C'){
+                    Roo.MessageBox.alert("Error", "This order has been closed");
+                    return;
+                }
+                
+                Roo.MessageBox.confirm("Confirm", "Are you sure?",
+                    function(v) {
+                        if (v != 'yes') {
+                            return;
                         }
-                    },
-                    {
-                        xtype: 'ContentPanel',
-                        xns: Roo,
-                        background : false,
-                        region : 'west',
-                        items : [
+                        new Pman.Request({
+                            url: baseURL + '/Roo/cohead',
+                            method : 'POST',
+                            params :  {
+                                cohead_id : s.data.cohead_id,
+                                _close : 1
+                            },
+                            mask : 'Sending',
+                            success : function()
                             {
-                                xtype: 'Form',
-                                xns: Roo.form,
-                                listeners : {
-                                    rendered : function (form)
-                                    {
-                                        _this.form= form;
-                                    }
-                                },
-                                labelAlign : 'top',
-                                method : 'POST',
-                                style : 'margin:5px;',
-                                items : [
-                                    {
-                                        xtype: 'ComboBox',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            select : function (combo, record, index)
-                                            {
-                                              _this.grid.footer.onClick('first');
-                                            },
-                                            render : function (_self)
-                                            {
-                                              _this.viewtypeSel = _self;
-                                            }
-                                        },
-                                        allowBlank : false,
-                                        displayField : 'value',
-                                        editable : false,
-                                        emptyText : "View type",
-                                        fieldLabel : 'View',
-                                        forceSelection : true,
-                                        listWidth : 200,
-                                        loadingText : "Searching...",
-                                        minChars : 2,
-                                        name : 'viewtype',
-                                        pageSize : 20,
-                                        qtip : "Select Action",
-                                        queryParam : 'query[action]',
-                                        selectOnFocus : true,
-                                        tpl : '<div class="x-grid-cell-text x-btn button"><b>{value}</b> </div>',
-                                        triggerAction : 'all',
-                                        typeAhead : true,
-                                        value : "MYOPEN",
-                                        valueField : 'key',
-                                        width : 150,
-                                        store : {
-                                            xtype: 'SimpleStore',
-                                            xns: Roo.data,
-                                            id : 0,
-                                            data : [
-                                              [ 'MYOPEN', 'My Open orders' ],
-                                              [ 'MYCLOSED', 'My Closed orders' ],
-                                              [ 'MYALL', 'My orders (all)' ],    
-                                              [ 'MYVOID', 'My Voided orders' ],      
-                                              [ 'OPEN', 'All Open orders' ],
-                                              [ 'NOTSHIPPED', 'All Un-shipped orders' ],
-                                              [ 'NOTPAID', 'All Un-paid orders' ],
-                                              [ 'PAIDNOTSHIPPED', 'All paid / not shipped orders' ],  
-                                              [ 'CLOSED', 'All Closed orders' ],
-                                              
-                                              [ 'ALL', 'All orders' ],
-                                              [ 'VOID', 'Voided orders' ],
-                                              [ 'INCOMPLETE', 'Incomplete orders' ],  
-                                              [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
-                                            //  [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],  
-                                            //  [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
-                                              [ 'FIFOBUG', 'Problems with FIFO' ] 
-                                                
-                                            ],
-                                            fields : [ 'key', 'value' ]
-                                        }
-                                    },
-                                    {
-                                        xtype: 'ComboBox',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            select : function (combo, record, index)
-                                            {
-                                                (function() { _this.grid.footer.onClick('first'); }).defer(100);
-                                            },
-                                            specialkey : function (_self, e)
-                                            {
-                                                //Roo.log(e.getKey());
-                                                if (e.getKey() == 13) {
-                                                    (function() { _this.grid.footer.onClick('first'); }).defer(100);
-                                                    e.stopEvent();
-                                                    _this.rsearch = true;
-                                                }
-                                                
-                                            },
-                                            beforequery : function (combo, query, forceAll, cancel, e)
-                                            {
-                                             
-                                               if( _this.rsearch) {
-                                                    _this.rsearch =false;
-                                                    return false;
-                                                }
-                                             
-                                            }
-                                        },
-                                        allowBlank : true,
-                                        displayField : 'cohead_number',
-                                        editable : true,
-                                        emptyText : "Select Order",
-                                        fieldLabel : 'Order #',
-                                        forceSelection : false,
-                                        listWidth : 400,
-                                        loadingText : "Searching...",
-                                        minChars : 2,
-                                        name : 'query[cohead_number]',
-                                        pageSize : 20,
-                                        qtip : "Select Order",
-                                        queryParam : 'query[cohead_number]',
-                                        selectOnFocus : true,
-                                        tpl : '<div class="x-grid-cell-text x-btn button"><b>{cohead_number}</b> </div>',
-                                        triggerAction : 'all',
-                                        typeAhead : false,
-                                        valueField : 'cohead_number',
-                                        width : 180,
-                                        store : {
-                                            xtype: 'Store',
-                                            xns: Roo.data,
-                                            listeners : {
-                                                beforeload : function (_self, o){
-                                                    o.params = o.params || {};
-                                                    o.params['_columns'] = 'cohead_number';
-                                                    // set more here
-                                                }
-                                            },
-                                            remoteSort : true,
-                                            sortInfo : { direction : 'ASC', field: 'cohead_number' },
-                                            proxy : {
-                                                xtype: 'HttpProxy',
-                                                xns: Roo.data,
-                                                method : 'GET',
-                                                url : baseURL + '/Roo/cohead.php'
-                                            },
-                                            reader : {
-                                                xtype: 'JsonReader',
-                                                xns: Roo.data,
-                                                id : 'cohead_number',
-                                                root : 'data',
-                                                totalProperty : 'total',
-                                                fields : ["cohead_number"]
-                                            }
-                                        }
-                                    },
-                                    {
-                                        xtype: 'ComboBox',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            select : function (combo, record, index)
-                                            {
-                                                   (function() { _this.grid.footer.onClick('first'); }).defer(100);
-                                            }
-                                        },
-                                        allowBlank : true,
-                                        displayField : 'cust_name',
-                                        editable : true,
-                                        emptyText : "Select custinfo",
-                                        fieldLabel : 'Customer',
-                                        forceSelection : true,
-                                        hiddenName : 'cohead_cust_id',
-                                        listWidth : 400,
-                                        loadingText : "Searching...",
-                                        minChars : 2,
-                                        name : 'cohead_cust_id_cust_name',
-                                        pageSize : 20,
-                                        qtip : "Select custinfo",
-                                        queryParam : 'query[cust_name]',
-                                        selectOnFocus : true,
-                                        tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b>  ({cust_number})</div>',
-                                        triggerAction : 'all',
-                                        typeAhead : false,
-                                        valueField : 'cust_id',
-                                        width : 180,
-                                        store : {
-                                            xtype: 'Store',
-                                            xns: Roo.data,
-                                            sortInfo : { direction : 'ASC', field: 'cust_name' },
-                                            remoteSort : true,
-                                            listeners : {
-                                                beforeload : function (_self, o){
-                                                    o.params = o.params || {};
-                                                    // set more here
-                                                }
-                                            },
-                                            proxy : {
-                                                xtype: 'HttpProxy',
-                                                xns: Roo.data,
-                                                method : 'GET',
-                                                url : baseURL + '/Roo/custinfo.php'
-                                            },
-                                            reader : {
-                                                xtype: 'JsonReader',
-                                                xns: Roo.data,
-                                                id : 'cust_id',
-                                                root : 'data',
-                                                totalProperty : 'total',
-                                                fields : [{"name":"cust_id","type":"int"},"cust_name"]
-                                            }
-                                        }
-                                    },
-                                    {
-                                        xtype: 'DateField',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            select : function (combo, date)
-                                            {
-                                                _this.grid.footer.onClick('first');
-                                            }
-                                        },
-                                        fieldLabel : 'From',
-                                        format : 'Y-m-d',
-                                        name : '_fromdate',
-                                        width : 100
-                                    },
-                                    {
-                                        xtype: 'DateField',
-                                        xns: Roo.form,
-                                        listeners : {
-                                            select : function (combo, date)
-                                            {
-                                                _this.grid.footer.onClick('first');
-                                            }
-                                        },
-                                        fieldLabel : 'To',
-                                        format : 'Y-m-d',
-                                        name : '_todate',
-                                        width : 100
-                                    }
-                                ]
+                                Roo.MessageBox.alert("Notice", "DONE");
+                                _this.grid.footer.onClick('first');
                             }
-                        ],
-                        toolbar : {
-                            xtype: 'Toolbar',
-                            xns: Roo,
-                            items : [
-                                {
-                                    xtype: 'Fill',
-                                    xns: Roo.Toolbar
-                                },
-                                {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    listeners : {
-                                        click : function (_self, e)
-                                        {
-                                        _this.grid.footer.onClick('first');
-                                        }
-                                    },
-                                    cls : 'x-btn-icon',
-                                    icon : rootURL + '/Pman/templates/images/search.gif'
-                                },
-                                {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    listeners : {
-                                        click : function (_self, e)
-                                        {
-                                            _this.form.reset('');
-                                        
-                                            
-                                            _this.grid.footer.onClick('first');
-                                        }
-                                    },
-                                    cls : 'x-btn-icon',
-                                    icon : rootURL + '/Pman/templates/images/edit-clear.gif'
-                                }
-                            ]
+                       });
+                    }
+                );
+                
+                
+            }
+          }
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/tree/leaf.gif',
+          text : _this._strings['959462c653dede23e7152b97b45a8aa5'] /* Clear Unpaid Orders */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function()
+            {
+                
+                new Pman.Request({
+                    url: baseURL + '/Roo/cohead',
+                    method : 'POST',
+                    params :  {
+                        _clearUnpaid : 1
+                    },
+                    mask : 'Clearing',
+                    success : function()
+                    {
+                        Roo.MessageBox.alert("Notice", "DONE");
+                        _this.grid.footer.onClick('first');
+                    }
+               });
+                
+            }
+          }
+         },
+         {
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Fill'
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+          text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function()
+            {
+               // check if the login in user have more than 25 open orders..
+               // if yes, warning...
+               new Pman.Request({
+                    url : baseURL + '/Roo/cohead.php',
+                    method :'GET',
+                    params : {
+                        viewtype : 'MYOPEN',
+                        _count_order : 1 // make the search faster!
+                    },
+                    success : function(res) {
+                        if(res.data[0].order_totals * 1 > 25){
+                            Roo.MessageBox.alert("Warning", "Can you please close old orders before creating new ones");
                         }
                     }
-                ],
-                west : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo,
-                    width : '200',
-                    split : true,
-                    title : "Search"
-                },
-                center : {
-                    xtype: 'LayoutRegion',
-                    xns: Roo
+                });
+               
+               Pman.Dialog.XtupleSalesOrderNew.show( { id : 0 } , function() {
+                    _this.grid.footer.onClick('first');
+               }); 
+            }
+          }
+         },
+         {
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+          text : _this._strings['5fb63579fc981698f97d55bfecb213ea'] /* Copy */,
+          xns : Roo.Toolbar,
+          '|xns' : 'Roo.Toolbar',
+          xtype : 'Button',
+          listeners : {
+           click : function()
+            {
+               var s = _this.grid.getSelectionModel().getSelected();
+               if (!s) {
+                    Roo.MessageBox.alert("Error", "Select an order to copy");
+                    return;
+               }
+               
+               
+               Pman.Dialog.XtupleSalesOrderCopy.show( { _copy_cohead_id : s.data.cohead_id } , function(data) {
+               
+                    // get the id from the data, then 
+               
+                    _this.grid.footer.onClick('first');
+                    Pman.Tab.XtupleSales.grid.footer.onClick('first');
+                    // get the id from the data, then start editing it..
+                    Roo.log(data);
+                        _this.dialog.show(data,  function() {
+                        _this.grid.footer.onClick('refresh');
+                        Pman.Tab.XtupleSales.grid.footer.onClick('first');
+                    }); 
+                    
+               }); 
+            }
+          }
+         }
+        ]
+       },
+       dataSource : {
+        builderCfg : '{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
+        remoteSort : true,
+        sortInfo : { field : 'cohead_orderdate', direction: 'DESC' },
+        xns : Roo.data,
+        '|xns' : 'Roo.data',
+        xtype : 'Store',
+        listeners : {
+         beforeload : function (_self, options)
+          {
+              var vl;
+              try { 
+                   vl = _this.form.getFieldValues();
+               } catch (e) {
+                  vl = {};
+               }
+          
+               
+               
+              for(var x in vl) {
+                  if (!(new String(vl[x])).length) {
+                      continue;
+                  }
+                  options.params[x] = vl[x];
+                  
+              }
+              try {
+                  if (options.params['query[cohead_number]'].length) {
+                      options.params.viewtype = 'REALALL';
+                  }
+              } catch (e) {}
+          }
+        },
+        proxy : {
+         method : 'GET',
+         timeout : 60000,
+         url : baseURL + '/Roo/cohead.php',
+         xns : Roo.data,
+         '|xns' : 'Roo.data',
+         xtype : 'HttpProxy'
+        },
+        reader : {
+         builderCfg : '{\"cols\":[{\"table\":\"cohead\",\"column\":\"cohead_number\",\"columnshort\":\"cohead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#order\"},{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"},{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"},{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"},{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"},{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"},{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"},{\"table\":\"curr_symbol\",\"column\":\"cohead_curr_id_curr_name\",\"columnshort\":\"curr_name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Currency\"}],\"cols_ex\":[\"cohead_cust_id_cust_name\"],\"table\":\"cohead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}',
+         fields : [
+             {
+                 'name': 'cohead_number',
+                 'type': 'string'
+             },
+             {
+                 'name': 'cohead_cust_id_cust_name',
+                 'type': 'string'
+             },
+             {
+                 'name': 'cohead_custponumber',
+                 'type': 'string'
+             },
+             {
+                 'name': 'cohead_type'
+             },
+             {
+                 'name': 'cohead_orderdate',
+                 'type': 'date'
+             },
+             {
+                 'name': 'cohead_shipto_id_shipto_name',
+                 'type': 'string'
+             },
+             {
+                 'name': 'cohead_terms_id_terms_descrip',
+                 'type': 'string'
+             },
+             {
+                 'name': 'cohead_curr_id_curr_name',
+                 'type': 'string'
+             }
+         ],
+         id : 'id',
+         root : 'data',
+         totalProperty : 'total',
+         xns : Roo.data,
+         '|xns' : 'Roo.data',
+         xtype : 'JsonReader'
+        }
+       },
+       colModel : [
+        {
+         builderCfg : '{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}',
+         dataIndex : 'cohead_orderdate',
+         header : _this._strings['26e09a1ee1517389c7b07f42df65561a'] /* Ordered */,
+         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+         sortable : true,
+         width : 75,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         dataIndex : 'cohead_targetdate',
+         header : _this._strings['a2fdeac60e3c5b6c51a92e027fb9d533'] /* Target Delivery */,
+         hidden : true,
+         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+         sortable : true,
+         width : 75,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"cohead\",\"column\":\"cohead_orderdate\",\"columnshort\":\"cohead_orderdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ordered\"}',
+         dataIndex : 'cohead_salesrep_id_salesrep_name',
+         header : _this._strings['3f7488c396d3d4e015d8886452db4110'] /* Staff IC. */,
+         renderer : function(v,x,r) { 
+         
+             if (r.data.cohead_display_salesrep_id) {
+                 return String.format('{0} ({1})', v, r.data.cohead_display_salesrep_id_salesrep_name);
+             }
+             return String.format('{0}', v );
+             
+             
+          },
+         sortable : true,
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         dataIndex : 'cohead_number',
+         header : _this._strings['54ca6e7fdb43298ae82cd9cb04e77f9b'] /* #order */,
+         renderer : function(v,x,r) {
+         
+               
+               // we want to show more detail about status..
+               // like payment status / delivery etc...
+               
+               // I = invoiced
+               // R = Reserved
+               // S = shipped (or partial shipped)
+               // P = paid (or partial paid)
+               // online payment failed? >> on terms?
+               // 
+               var tags = {
+                 invoiced : '<span class="dragon-so-complete" qtip="Invoiced">I</span>',
+                 invoiced_not : '<span class="dragon-so-complete-not"  qtip="Not Invoiced">I</span>',
+                 stock_not : '<span class="dragon-so-complete-not" qtip="Stock not reserved or shipped">S</span>',        
+                 stock_reserved : '<span class="dragon-so-complete-part" qtip="Stock Reserved / Not shipped">R</span>',
+                 stock_shipped : '<span class="dragon-so-complete" qtip="Shipped">S</span>',
+                 paid : '<span class="dragon-so-complete" qtip="Paid">P</span>',
+                 paid_not : '<span class="dragon-so-complete-not" qtip="Not Paid">P</span>'
+             };        
+              
+              // invoiced
+              var tg = '';
+              
+                // stock status...
+              if (r.data.cohead_qtyunshipped > 0) {
+                   
+                   tg +=  (r.data.shipitem_qty*1 > 0)  ? tags.stock_reserved :tags.stock_not;
+              }     else {
+              
+                  tg +=  tags.stock_shipped;
+             }
+              
+              tg += (r.data.cohead_qtyuninvoiced > 0) ? tags.invoiced_not : tags.invoiced;
+              // ?? partially invoiced??
+              
+              
+              if (r.data.cohead_qtyuninvoiced*1 < 1) {
+                   tg += (r.data.aropen_unpaid*1 > 0) ? tags.paid_not : tags.paid;
+               }
+              
+              
+              
+             // payment status??
+         
+               if (r.data.cohead_status == 'C') {
+                   return tg + ' ' + String.format('<i qtip="closed">{0}</i>', v); 
+               }
+               if (r.data.cohead_status == 'X') {
+                   return tg + ' ' +  String.format('<s qtip="void">{0}</s>', v)  ; 
+               }
+               return tg + ' ' + String.format('{0}', v); 
+          },
+         sortable : true,
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}',
+         dataIndex : 'cohead_cust_id_cust_number',
+         header : _this._strings['2d899459cc25ea99ea2573d592860ec8'] /* Customer# */,
+         renderer : function(v) { return String.format('{0}', v); },
+         sortable : true,
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}',
+         dataIndex : 'cohead_cust_id_cust_name',
+         header : _this._strings['ce26601dac0dea138b7295f02b7620a7'] /* Customer */,
+         renderer : function(v) { return String.format('{0}', v); },
+         sortable : true,
+         width : 200,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"cohead\",\"column\":\"cohead_custponumber\",\"columnshort\":\"cohead_custponumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust. PO#\"}',
+         dataIndex : 'cohead_custponumber',
+         header : _this._strings['fdb35c1a9883acaa94378144a114dfe6'] /* Cust. PO# */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 50,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"cohead\",\"column\":\"cohead_type\",\"columnshort\":\"cohead_type\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Type\"}',
+         dataIndex : 'cohead_type',
+         header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 50,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         dataIndex : 'cohead_src_locations',
+         header : _this._strings['5da618e8e4b89c66fe86e32cdafde142'] /* From */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"shiptoinfo\",\"column\":\"cohead_shipto_id_shipto_name\",\"columnshort\":\"shipto_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Ship to\"}',
+         dataIndex : 'cohead_shiptoaddress1',
+         header : _this._strings['74002cb040b036511b8d031da591364a'] /* Ship to */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 200,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         builderCfg : '{\"table\":\"terms\",\"column\":\"cohead_terms_id_terms_descrip\",\"columnshort\":\"terms_descrip\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Terms\"}',
+         dataIndex : 'cohead_terms_id_terms_descrip',
+         header : _this._strings['6f1bf85c9ebb3c7fa26251e1e335e032'] /* Terms */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         dataIndex : 'cohead_ordercomments',
+         header : _this._strings['f4c6f851b00d5518bf888815de279aba'] /* Notes */,
+         hidden : true,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        },
+        {
+         align : 'right',
+         dataIndex : 'cohead_total',
+         header : _this._strings['96b0141273eabab320119c467cdcaf17'] /* Total */,
+         renderer : function(v,x,r) { 
+             var ret =  String.format('{0} {1}',
+                  r.data.cohead_curr_id_curr_name, v ?   parseFloat(v).toFixed(3) : '---'
+              ); 
+              
+              if (parseInt(r.data.cohead_qtyordered)  != 0 && 
+                 parseInt(r.data.cohead_unshipped) == 0 && 
+                  parseInt(r.data.cohead_qtyunshipped) == 0 &&
+                  parseInt(r.data.cohead_qtyuninvoiced) == 0 &&         
+                   parseInt(r.data.cohead_unshipped) == 0 &&
+                  parseInt(r.data.cohead_uninvoiced) == 0 
+              ) {
+                 return ret;
+             }
+              
+              return String.format('<b style="color:red" ' + 
+                     'qtip="Products: {3} ({4}) &lt;BR/&gt;Unshipped: {1} ({5})&lt;BR&gt;Uninvoiced: {2} ({6})">{0}</b>',
+                  ret, 
+                     r.data.cohead_unshipped, r.data.cohead_uninvoiced, r.data.cohead_subtotal,
+                     r.data.cohead_qtyordered, r.data.cohead_qtyunshipped, r.data.cohead_qtyuninvoiced
+                  );
+              
+          },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         xtype : 'ColumnModel'
+        }
+       ]
+      }
+     },
+     {
+      background : false,
+      region : 'west',
+      xns : Roo,
+      '|xns' : 'Roo',
+      xtype : 'ContentPanel',
+      toolbar : {
+       xns : Roo,
+       '|xns' : 'Roo',
+       xtype : 'Toolbar',
+       items  : [
+        {
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
+         xtype : 'Fill'
+        },
+        {
+         cls : 'x-btn-icon',
+         icon : rootURL + '/Pman/templates/images/search.gif',
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
+         xtype : 'Button',
+         listeners : {
+          click : function (_self, e)
+           {
+           _this.grid.footer.onClick('first');
+           }
+         }
+        },
+        {
+         cls : 'x-btn-icon',
+         icon : rootURL + '/Pman/templates/images/edit-clear.gif',
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar',
+         xtype : 'Button',
+         listeners : {
+          click : function (_self, e)
+           {
+               _this.form.reset('');
+           
+               
+               _this.grid.footer.onClick('first');
+           }
+         }
+        }
+       ]
+      },
+      items  : [
+       {
+        labelAlign : 'top',
+        method : 'POST',
+        style : 'margin:5px;',
+        xns : Roo.form,
+        '|xns' : 'Roo.form',
+        xtype : 'Form',
+        listeners : {
+         rendered : function (form)
+          {
+              _this.form= form;
+          }
+        },
+        items  : [
+         {
+          allowBlank : false,
+          displayField : 'value',
+          editable : false,
+          emptyText : _this._strings['3e208ad5d41ca414bb432adbb7d39c33'] /* View type */,
+          fieldLabel : _this._strings['4351cfebe4b61d8aa5efa1d020710005'] /* View */,
+          forceSelection : true,
+          listWidth : 200,
+          loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+          minChars : 2,
+          name : 'viewtype',
+          pageSize : 20,
+          qtip : _this._strings['a8929eb5c1553d3f70497f862d25d0ce'] /* Select Action */,
+          queryParam : 'query[action]',
+          selectOnFocus : true,
+          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{value}</b> </div>',
+          triggerAction : 'all',
+          typeAhead : true,
+          value : _this._strings['8db91c5e3376bc85414ebca9c53fb53f'] /* MYOPEN */,
+          valueField : 'key',
+          width : 150,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'ComboBox',
+          listeners : {
+           render : function (_self)
+            {
+              _this.viewtypeSel = _self;
+            },
+           select : function (combo, record, index)
+            {
+              _this.grid.footer.onClick('first');
+            }
+          },
+          store : {
+           data : [
+             [ 'MYOPEN', 'My Open orders' ],
+             [ 'MYCLOSED', 'My Closed orders' ],
+             [ 'MYALL', 'My orders (all)' ],    
+             [ 'MYVOID', 'My Voided orders' ],      
+             [ 'OPEN', 'All Open orders' ],
+             [ 'NOTSHIPPED', 'All Un-shipped orders' ],
+             [ 'NOTPAID', 'All Un-paid orders' ],
+             [ 'PAIDNOTSHIPPED', 'All paid / not shipped orders' ],  
+             [ 'CLOSED', 'All Closed orders' ],
+             
+             [ 'ALL', 'All orders' ],
+             [ 'VOID', 'Voided orders' ],
+             [ 'INCOMPLETE', 'Incomplete orders' ],  
+             [ 'DRAFTSHIP', 'Have Un-confirmed Shipments' ],
+           //  [ 'SHIPPOSTBUG', 'Bugs with Posted transactions' ],  
+           //  [ 'SHIPQTYBUG', 'Bugs with Shipment Qty' ] ,
+             [ 'FIFOBUG', 'Problems with FIFO' ] 
+               
+           ],
+           fields : [ 'key', 'value' ],
+           id : 0,
+           xns : Roo.data,
+           '|xns' : 'Roo.data',
+           xtype : 'SimpleStore'
+          }
+         },
+         {
+          allowBlank : true,
+          displayField : 'cohead_number',
+          editable : true,
+          emptyText : _this._strings['f38ab62162b94b4978679aeca58a270c'] /* Select Order */,
+          fieldLabel : _this._strings['d1228f5476d15142b1358ae4b5fa2454'] /* Order # */,
+          forceSelection : false,
+          listWidth : 400,
+          loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+          minChars : 2,
+          name : 'query[cohead_number]',
+          pageSize : 20,
+          qtip : _this._strings['f38ab62162b94b4978679aeca58a270c'] /* Select Order */,
+          queryParam : 'query[cohead_number]',
+          selectOnFocus : true,
+          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{cohead_number}</b> </div>',
+          triggerAction : 'all',
+          typeAhead : false,
+          valueField : 'cohead_number',
+          width : 180,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'ComboBox',
+          listeners : {
+           beforequery : function (combo, query, forceAll, cancel, e)
+            {
+             
+               if( _this.rsearch) {
+                    _this.rsearch =false;
+                    return false;
                 }
+             
+            },
+           select : function (combo, record, index)
+            {
+                (function() { _this.grid.footer.onClick('first'); }).defer(100);
+            },
+           specialkey : function (_self, e)
+            {
+                //Roo.log(e.getKey());
+                if (e.getKey() == 13) {
+                    (function() { _this.grid.footer.onClick('first'); }).defer(100);
+                    e.stopEvent();
+                    _this.rsearch = true;
+                }
+                
+            }
+          },
+          store : {
+           remoteSort : true,
+           sortInfo : { direction : 'ASC', field: 'cohead_number' },
+           xns : Roo.data,
+           '|xns' : 'Roo.data',
+           xtype : 'Store',
+           listeners : {
+            beforeload : function (_self, o){
+                 o.params = o.params || {};
+                 o.params['_columns'] = 'cohead_number';
+                 // set more here
+             }
+           },
+           proxy : {
+            method : 'GET',
+            url : baseURL + '/Roo/cohead.php',
+            xns : Roo.data,
+            '|xns' : 'Roo.data',
+            xtype : 'HttpProxy'
+           },
+           reader : {
+            fields : ["cohead_number"],
+            id : 'cohead_number',
+            root : 'data',
+            totalProperty : 'total',
+            xns : Roo.data,
+            '|xns' : 'Roo.data',
+            xtype : 'JsonReader'
+           }
+          }
+         },
+         {
+          allowBlank : true,
+          displayField : 'cust_name',
+          editable : true,
+          emptyText : _this._strings['fce6d3795b41b54dc0dab82df50517c1'] /* Select custinfo */,
+          fieldLabel : _this._strings['ce26601dac0dea138b7295f02b7620a7'] /* Customer */,
+          forceSelection : true,
+          hiddenName : 'cohead_cust_id',
+          listWidth : 400,
+          loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+          minChars : 2,
+          name : 'cohead_cust_id_cust_name',
+          pageSize : 20,
+          qtip : _this._strings['fce6d3795b41b54dc0dab82df50517c1'] /* Select custinfo */,
+          queryParam : 'query[cust_name]',
+          selectOnFocus : true,
+          tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b>  ({cust_number})</div>',
+          triggerAction : 'all',
+          typeAhead : false,
+          valueField : 'cust_id',
+          width : 180,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'ComboBox',
+          listeners : {
+           select : function (combo, record, index)
+            {
+                   (function() { _this.grid.footer.onClick('first'); }).defer(100);
+            }
+          },
+          store : {
+           remoteSort : true,
+           sortInfo : { direction : 'ASC', field: 'cust_name' },
+           xns : Roo.data,
+           '|xns' : 'Roo.data',
+           xtype : 'Store',
+           listeners : {
+            beforeload : function (_self, o){
+                 o.params = o.params || {};
+                 // set more here
+             }
+           },
+           proxy : {
+            method : 'GET',
+            url : baseURL + '/Roo/custinfo.php',
+            xns : Roo.data,
+            '|xns' : 'Roo.data',
+            xtype : 'HttpProxy'
+           },
+           reader : {
+            fields : [{"name":"cust_id","type":"int"},"cust_name"],
+            id : 'cust_id',
+            root : 'data',
+            totalProperty : 'total',
+            xns : Roo.data,
+            '|xns' : 'Roo.data',
+            xtype : 'JsonReader'
+           }
+          }
+         },
+         {
+          fieldLabel : _this._strings['5da618e8e4b89c66fe86e32cdafde142'] /* From */,
+          format : 'Y-m-d',
+          name : '_fromdate',
+          width : 100,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'DateField',
+          listeners : {
+           select : function (combo, date)
+            {
+                _this.grid.footer.onClick('first');
+            }
+          }
+         },
+         {
+          fieldLabel : _this._strings['e12167aa0a7698e6ebc92b4ce3909b53'] /* To */,
+          format : 'Y-m-d',
+          name : '_todate',
+          width : 100,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          xtype : 'DateField',
+          listeners : {
+           select : function (combo, date)
+            {
+                _this.grid.footer.onClick('first');
             }
-        };
-    }
+          }
+         }
+        ]
+       }
+      ]
+     }
+    ]
+   }
+  };  }
 });