1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Tab');
7 Pman.Tab.XtupleItem = new Roo.XComponent({
8 part : ["Xtuple", "Item" ],
9 order : '001-Pman.Tab.XtupleItem',
11 parent : 'Pman.Tab.XtupleManage',
12 name : "Pman.Tab.XtupleItem",
23 xtype : 'LayoutRegion',
28 xtype : 'LayoutRegion',
34 xtype : 'BorderLayout',
42 url : baseURL + '/Roo/item.php',
59 'name': 'item_number',
63 'name': 'item_descrip1',
67 'name': 'item_descrip2',
71 'name': 'item_classcode_id',
75 'name': 'item_picklist',
79 'name': 'item_comments',
87 'name': 'item_fractional',
91 'name': 'item_active',
99 'name': 'item_prodweight',
103 'name': 'item_packweight',
107 'name': 'item_prodcat_id',
111 'name': 'item_exclusive',
115 'name': 'item_listprice',
119 'name': 'item_config',
123 'name': 'item_extdescrip',
127 'name': 'item_upccode',
131 'name': 'item_maxcost',
135 'name': 'item_inv_uom_id',
139 'name': 'item_price_uom_id',
143 'name': 'item_warrdays',
147 'name': 'item_freightclass_id',
151 'name': 'item_tax_recoverable',
155 'name': 'item_price_uom_id_uom_id',
159 'name': 'item_price_uom_id_uom_name',
163 'name': 'item_price_uom_id_uom_descrip',
167 'name': 'item_price_uom_id_uom_item_weight',
171 'name': 'item_inv_uom_id_uom_id',
175 'name': 'item_inv_uom_id_uom_name',
179 'name': 'item_inv_uom_id_uom_descrip',
183 'name': 'item_inv_uom_id_uom_item_weight',
187 'name': 'item_freightclass_id_freightclass_id',
191 'name': 'item_freightclass_id_freightclass_code',
195 'name': 'item_freightclass_id_freightclass_descrip',
199 'name': 'item_classcode_id_classcode_id',
203 'name': 'item_classcode_id_classcode_code',
207 'name': 'item_classcode_id_classcode_descrip',
211 'name': 'item_classcode_id_classcode_mfg',
215 'name': 'item_classcode_id_classcode_creator',
219 'name': 'item_classcode_id_classcode_created',
223 'name': 'item_classcode_id_classcode_modifier',
227 'name': 'item_classcode_id_classcode_modified',
231 'name': 'item_classcode_id_classcode_type',
235 totalProperty : 'total'
240 sortInfo : { field : 'item_number', direction: 'ASC' },
243 update : function (_self, record, operation)
245 if(operation != 'commit'){
249 var nv = record.data.itemsrc_active ? 0 : 1;
252 url : baseURL + '/Roo/Itemsrc',
255 item_id : record.data.item_id,
258 success : function(res) {
259 record.set('itemsrc_active', nv);
263 beforeload : function (_self, o)
265 o.params._with_prodcat = 1;
266 o.params._with_char = 1;
267 o.params._with_itemsrc_active = 1;
268 o.params._with_last_purchase_price = 1;
269 o.params._with_image = 1;
270 var s = _this.search.getValue();
272 o.params['query[number_or_name]'] = s;
274 if (!_this.active.pressed) {
275 o.params.item_active = 1;
277 if (_this.brandSel.getValue().length) {
278 o.params._with_brand = _this.brandSel.getValue()
281 o.params._with_stock_balance = 1;
283 load : function (_self, records, options)
286 var cm = _this.grid.getColumnModel();
288 cm.setColumnHeader(cm.getIndexByDataIndex('item_stock_balance'),records[0].data.default_location_name);
306 url : baseURL + '/Roo/Charass.php',
315 xtype : 'JsonReader',
323 'name': 'person_name',
327 'name': 'event_when',
329 'dateFormat': 'Y-m-d'
356 'name': 'person_id_id',
360 'name': 'person_id_office_id',
364 'name': 'person_id_name',
368 'name': 'person_id_phone',
372 'name': 'person_id_fax',
376 'name': 'person_id_email',
380 'name': 'person_id_company_id',
384 'name': 'person_id_role',
388 'name': 'person_id_active',
392 'name': 'person_id_remarks',
396 'name': 'person_id_passwd',
400 'name': 'person_id_owner_id',
404 'name': 'person_id_lang',
408 'name': 'person_id_no_reset_sent',
412 'name': 'person_id_action_type',
416 'name': 'person_id_project_id',
420 'name': 'person_id_deleted_by',
424 'name': 'person_id_deleted_dt',
428 totalProperty : 'total'
433 sortInfo : { field : 'charass_value' , direction : 'ASC' },
436 beforeload : function (_self, o)
438 o.params = o.params || {};
439 // staff can see all logs, other companies can only see their own.
440 // look for all of the charass 's with the same type= eg. brand.
442 o.params.charass_char_id_char_name = 'BRAND';
443 o.params.charass_target_type ='I';
444 o.params._distinct = 'charass_value';
445 o.params._columns = 'charass_value';
457 triggerAction : 'all',
458 forceSelection : true,
459 selectOnFocus : true,
461 displayField : 'charass_value',
462 emptyText : "Select Brand",
469 qtip : "Select Brand",
470 queryParam : 'query[charass_value]',
471 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
472 loadingText : "Searching...",
474 render : function (_self)
476 _this.brandSel = _self;
478 select : function (combo, record, index)
480 _this.grid.footer.onClick('first');
490 emptyText : "Search Product",
494 specialkey : function (_self, e)
496 _this.grid.footer.onClick('first');
498 render : function (_self)
500 _this.search = _self;
505 '|xns' : 'Roo.Toolbar',
508 icon : rootURL + '/Pman/templates/images/search.gif',
511 click : function (_self, e)
513 _this.grid.footer.onClick('first');
518 '|xns' : 'Roo.Toolbar',
521 icon : rootURL + '/Pman/templates/images/edit-clear.gif',
524 click : function (_self, e)
526 _this.search.setValue('');
530 _this.grid.footer.onClick('first');
535 '|xns' : 'Roo.Toolbar',
540 '|xns' : 'Roo.Toolbar',
541 text : "Show Inactive",
546 toggle : function (_self, pressed)
549 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
550 (function() { _this.grid.footer.onClick('first'); }).defer(100);
552 render : function (_self)
554 _this.active = _self;
559 '|xns' : 'Roo.Toolbar',
564 '|xns' : 'Roo.Toolbar',
567 cls : 'x-btn-text-icon',
568 icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
574 Pman.Dialog.XtupleItem.show( { item_id : 0 } , function() {
575 _this.grid.footer.onClick('first');
581 '|xns' : 'Roo.Toolbar',
588 var s = _this.grid.selModel.getSelectedCell();
590 Roo.MessageBox.alert("Error", "Select a product");
593 var rec = _this.grid.ds.getAt(s[0]);
597 Roo.MessageBox.prompt(
599 "Warning changing SKU names affects historical data, and should only be done if you are sure that this is ok",
607 item_id : rec.data.item_id,
620 var change = function(params){
622 url : baseURL + '/Roo/Item',
626 success : function(res) {
628 _this.grid.footer.onClick('refresh');
629 if(typeof(res.data) == 'string'){
630 Roo.MessageBox.alert("Notice", 'SKU has been renamed');
634 Roo.each(res.data, function(o){
635 offices.push(Pman.Xtuple.offices[o]);
637 Roo.MessageBox.alert("Notice", 'SKU has been renamed in ' + offices.join(", "));
640 failure : function(res) {
643 if (res.errors.confirm.length) {
645 Roo.each(res.errors.confirm, function(o){
646 offices.push(Pman.Xtuple.offices[o]);
648 Roo.MessageBox.confirm(
650 " Do you want to change the name in " + offices.join(", ") + "?",
653 Roo.MessageBox.alert("Notice", 'SKU was not changed');
656 delete params['_check'];
657 params._can_change_sku = 1;
664 Roo.MessageBox.alert("Error", res.errorMsg);
674 '|xns' : 'Roo.Toolbar',
679 '|xns' : 'Roo.Toolbar',
680 text : "Report start :",
689 value : (function() { return (new Date()).format('Y') + '-01-01'; })(),
692 render : function (_self)
694 _this.dateFrom = _self;
701 xtype : 'SimpleStore',
703 [ '1', "Single Month Sales"],
704 [ '3', "Quarter Sales"],
705 [ '6', "Half year Sales"] ,
706 [ '12', "Full Year Sales"]
708 fields : [ 'ftype', 'fname'],
713 triggerAction : 'all',
714 fieldLabel : 'Status',
715 displayField : 'fname',
716 hiddenName : 'cm_status',
718 valueField : 'ftype',
725 name : 'cm_status_name',
727 render : function (_self)
729 _this.datespan = _self;
738 '|xns' : 'Roo.Toolbar',
739 text : "Download Sales Report",
743 click : function (_self, e)
745 if (!_this.brandSel.getValue().length) {
746 Roo.MessageBox.alert("Error", "Select a brand to download");
751 url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
753 date_from : _this.dateFrom.getValue(),
754 brand : _this.brandSel.getValue(),
755 span : _this.datespan.getValue()
769 xtype : 'PagingToolbar',
770 emptyMsg : "No item found",
773 displayMsg : "Displaying item{0} - {1} of {2}",
783 text : "Download Standard costs",
787 click : function (_self, e)
791 url : baseURL + '/Roo/item',
801 text : "Upload new products and costs",
805 click : function (_self, e)
807 // Roo.MessageBox.alert("Disabled", "Can you please send Alan the test file for this - there is a problem and we need to fix it before you use this again");
810 Pman.Dialog.Image.show(
812 _url : baseURL+'/Xtuple/Import/Products',
820 msg.push("Updated " + data.updated + " Products(s)");
823 msg.push("Added " + data.inserted + " Products(s)");
826 msg.push("Skipped " + data.skipped);
830 msg.push("No data changed");
832 Roo.MessageBox.alert("Notice", msg.join("\n"));
846 text : "Sync Product Data from HK",
849 hidden : (function() {
851 return baseURL.match(/hk\.php$/) ? true : false;
854 click : function (_self, e)
856 Roo.MessageBox.progress ("Syncing Stock", "Sending");
863 url : baseURL+'/Roo/Item',
870 success : function(res) {
872 if (!res.data.total) {
873 Roo.MessageBox.hide();
876 offset += res.data.limit;
877 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
890 text : "Sync Product from HK (New Products Only)",
893 hidden : (function() {
895 return baseURL.match(/hk\.php$/) ? true : false;
898 click : function (_self, e)
900 Roo.MessageBox.progress ("Syncing Stock", "Sending");
907 url : baseURL+'/Roo/Item',
913 success : function(res) {
916 Roo.MessageBox.hide();
917 _this.grid.footer.onClick('refresh');
930 text : "Sync Product from HK (Based on Search)",
933 hidden : (function() {
935 return baseURL.match(/hk\.php$/) ? true : false;
938 click : function (_self, e)
940 Roo.MessageBox.progress ("Syncing Stock", "Sending");
947 url : baseURL+'/Roo/Item',
951 item_number : _this.search.getValue()
953 success : function(res) {
956 Roo.MessageBox.hide();
957 _this.grid.footer.onClick('refresh');
971 '|xns' : 'Roo.Toolbar',
972 text : "Tools - Upload/Download",
984 autoExpandColumn : 'item_descrip1',
985 xtype : 'EditorGrid',
992 xtype : 'ColumnModel',
996 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/50/{1}/{2}" height="50">', baseURL, v, r.data.item_image_filename); },
998 dataIndex : 'item_image_id'
1005 '|xns' : 'Roo.data',
1006 url : baseURL + '/Roo/Charass.php',
1007 xtype : 'HttpProxy',
1012 '|xns' : 'Roo.data',
1015 xtype : 'JsonReader',
1023 'name': 'person_name',
1027 'name': 'event_when',
1029 'dateFormat': 'Y-m-d'
1048 'name': 'person_id',
1056 'name': 'person_id_id',
1060 'name': 'person_id_office_id',
1064 'name': 'person_id_name',
1068 'name': 'person_id_phone',
1072 'name': 'person_id_fax',
1076 'name': 'person_id_email',
1080 'name': 'person_id_company_id',
1084 'name': 'person_id_role',
1088 'name': 'person_id_active',
1092 'name': 'person_id_remarks',
1096 'name': 'person_id_passwd',
1100 'name': 'person_id_owner_id',
1104 'name': 'person_id_lang',
1108 'name': 'person_id_no_reset_sent',
1112 'name': 'person_id_action_type',
1116 'name': 'person_id_project_id',
1120 'name': 'person_id_deleted_by',
1124 'name': 'person_id_deleted_dt',
1128 totalProperty : 'total'
1130 '|xns' : 'Roo.data',
1133 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1136 beforeload : function (_self, o)
1138 o.params = o.params || {};
1139 // staff can see all logs, other companies can only see their own.
1140 // look for all of the charass 's with the same type= eg. brand.
1142 o.params.charass_char_id_char_name = 'BRAND';
1143 o.params.charass_target_type ='I';
1144 o.params._distinct = 'charass_value';
1145 o.params._columns = 'charass_value';
1154 '|xns' : 'Roo.form',
1157 triggerAction : 'all',
1158 forceSelection : false,
1159 selectOnFocus : true,
1161 displayField : 'charass_value',
1168 qtip : "Select Brand",
1169 queryParam : 'query[charass_value]',
1170 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
1171 loadingText : "Searching...",
1177 '|xns' : 'Roo.grid',
1178 xtype : 'GridEditor',
1185 '|xns' : 'Roo.grid',
1186 xtype : 'ColumnModel',
1190 renderer : function(v) { return String.format('{0}', v); },
1192 dataIndex : 'item_char_brand',
1203 '|xns' : 'Roo.data',
1204 url : baseURL + '/Roo/Charass.php',
1205 xtype : 'HttpProxy',
1210 '|xns' : 'Roo.data',
1213 xtype : 'JsonReader',
1221 'name': 'person_name',
1225 'name': 'event_when',
1227 'dateFormat': 'Y-m-d'
1246 'name': 'person_id',
1254 'name': 'person_id_id',
1258 'name': 'person_id_office_id',
1262 'name': 'person_id_name',
1266 'name': 'person_id_phone',
1270 'name': 'person_id_fax',
1274 'name': 'person_id_email',
1278 'name': 'person_id_company_id',
1282 'name': 'person_id_role',
1286 'name': 'person_id_active',
1290 'name': 'person_id_remarks',
1294 'name': 'person_id_passwd',
1298 'name': 'person_id_owner_id',
1302 'name': 'person_id_lang',
1306 'name': 'person_id_no_reset_sent',
1310 'name': 'person_id_action_type',
1314 'name': 'person_id_project_id',
1318 'name': 'person_id_deleted_by',
1322 'name': 'person_id_deleted_dt',
1326 totalProperty : 'total'
1328 '|xns' : 'Roo.data',
1331 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1334 beforeload : function (_self, o)
1336 o.params = o.params || {};
1337 // staff can see all logs, other companies can only see their own.
1338 // look for all of the charass 's with the same type= eg. brand.
1340 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1341 o.params.charass_target_type ='I';
1342 o.params._distinct = 'charass_value';
1343 o.params._columns = 'charass_value';
1351 '|xns' : 'Roo.form',
1354 triggerAction : 'all',
1355 forceSelection : false,
1356 selectOnFocus : true,
1358 displayField : 'charass_value',
1365 qtip : "Select Brand",
1366 queryParam : 'query[charass_value]',
1367 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
1368 loadingText : "Searching...",
1374 '|xns' : 'Roo.grid',
1375 xtype : 'GridEditor',
1382 '|xns' : 'Roo.grid',
1383 xtype : 'ColumnModel',
1385 header : 'Product Group',
1387 renderer : function(v) { return String.format('{0}', v); },
1389 dataIndex : 'item_char_productgroup',
1396 '|xns' : 'Roo.grid',
1397 xtype : 'ColumnModel',
1401 renderer : function(v) { return String.format('<B>{0}</B>', v); },
1403 dataIndex : 'item_number'
1408 '|xns' : 'Roo.form',
1409 xtype : 'TextField',
1412 '|xns' : 'Roo.grid',
1413 xtype : 'GridEditor',
1420 '|xns' : 'Roo.grid',
1421 xtype : 'ColumnModel',
1423 header : 'Pickface',
1425 renderer : function(v) { return String.format('{0}', v); },
1427 dataIndex : 'item_char_pickface_location',
1436 '|xns' : 'Roo.form',
1437 xtype : 'TextField',
1440 '|xns' : 'Roo.grid',
1441 xtype : 'GridEditor',
1448 '|xns' : 'Roo.grid',
1449 xtype : 'ColumnModel',
1453 renderer : function(v) { return String.format('{0}', v); },
1455 dataIndex : 'item_char_pallet_location',
1462 '|xns' : 'Roo.grid',
1463 xtype : 'ColumnModel',
1465 header : 'Description',
1467 renderer : function(v) { return String.format('{0}', v); },
1469 dataIndex : 'item_descrip1'
1472 '|xns' : 'Roo.grid',
1473 xtype : 'ColumnModel',
1475 header : 'Purchased',
1477 renderer : function(v) {
1478 var state = v * 1 > 0 ? '-checked' : '';
1480 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1484 dataIndex : 'itemsrc_active'
1487 '|xns' : 'Roo.grid',
1488 xtype : 'ColumnModel',
1490 header : 'is Sold?',
1492 renderer : function(v) {
1493 var state = v * 1 > 0 ? '-checked' : '';
1495 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1499 dataIndex : 'item_sold'
1502 '|xns' : 'Roo.grid',
1503 xtype : 'ColumnModel',
1505 header : 'is Active?',
1507 renderer : function(v) {
1508 var state = v * 1 > 0 ? '-checked' : '';
1510 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1514 dataIndex : 'item_active'
1517 '|xns' : 'Roo.grid',
1519 xtype : 'ColumnModel',
1520 header : 'Last purchase price',
1522 renderer : function(v,x,r) {
1524 return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
1528 dataIndex : 'last_purchase_price'
1531 '|xns' : 'Roo.grid',
1532 xtype : 'ColumnModel',
1533 header : 'Item prodcat',
1535 renderer : function(v,x,r) {
1536 return String.format('{0}/{1}', r.data.item_type, v);
1539 dataIndex : 'item_prodcat_id_prodcat_code'
1542 '|xns' : 'Roo.grid',
1544 xtype : 'ColumnModel',
1547 renderer : function(v,x,r) {
1549 return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
1553 dataIndex : 'item_actcost'
1556 '|xns' : 'Roo.grid',
1558 xtype : 'ColumnModel',
1559 header : 'Cost (base)',
1561 renderer : function(v,x,r) {
1563 return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
1567 dataIndex : 'item_base_cost'
1570 '|xns' : 'Roo.grid',
1572 xtype : 'ColumnModel',
1575 renderer : function(v) { return String.format('{0}', v ? parseInt( v) : ''); },
1577 dataIndex : 'item_stock_balance'
1584 //_this.dialog = Pman.Dialog.FILL_IN
1585 if (_this.panel.active) {
1586 this.footer.onClick('first');
1589 cellclick : function (_self, row, col, e)
1591 var di = _this.grid.colModel.getDataIndex(col);
1593 var rec = _this.grid.ds.getAt(row);
1596 if (di == 'item_active') {
1598 var nv = rec.data.item_active ? 0 : 1;
1601 url : baseURL + '/Roo/Item',
1603 item_id : rec.data.item_id,
1606 success : function() {
1607 rec.set('item_active', nv);
1615 if(di == 'itemsrc_active'){
1620 if(rec.data.itemsrc_active * 1){
1621 Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
1626 rec.set('itemsrc_active', 0);
1632 Pman.Dialog.XtupleItem.show( { item_id : rec.data.item_id } , function() {
1633 _this.grid.footer.onClick('first');
1639 _this.locgrid.footer.onClick('first');
1645 celldblclick : function (_self, rowIndex, columnIndex, e)
1647 var s = _this.grid.ds.getAt(rowIndex);
1649 Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
1650 _this.grid.footer.onClick('first');
1653 afteredit : function (e)
1659 url : baseURL +'/Roo/Charass',
1661 charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
1662 charass_value : e.value,
1663 charass_target_type : 'I',
1664 charass_default : 1,
1665 charass_target_id : e.record.data.item_id
1687 xtype : 'GridPanel',
1688 fitContainer : true,
1692 activate : function() {
1695 _this.grid.footer.onClick('first');
1708 '|xns' : 'Roo.data',
1709 url : baseURL + '/Roo/location.php',
1710 xtype : 'HttpProxy',
1715 '|xns' : 'Roo.data',
1718 xtype : 'JsonReader',
1722 'name': 'itemloc_id',
1726 'name': 'itemloc_itemsite_id',
1730 'name': 'itemloc_location_id',
1734 'name': 'itemloc_qty',
1738 'name': 'itemloc_expiration',
1740 'dateFormat': 'Y-m-d'
1743 'name': 'itemloc_consolflag',
1747 'name': 'itemloc_ls_id',
1751 'name': 'itemloc_warrpurc',
1753 'dateFormat': 'Y-m-d'
1756 totalProperty : 'total'
1758 '|xns' : 'Roo.data',
1761 sortInfo : { field : 'location_name', direction: 'ASC' },
1764 beforeload : function (_self, o)
1766 var sel = _this.grid.selModel.getSelectedCell();
1771 var rec = _this.grid.ds.getAt(sel[0]);
1772 o.params._stock_for_item_id = rec.data.item_id;
1773 //o.params['!itemloc_qty'] = 0;
1786 xtype : 'PagingToolbar',
1787 emptyMsg : "No itemloc found",
1790 displayMsg : "Displaying itemloc{0} - {1} of {2}"
1792 '|xns' : 'Roo.grid',
1793 autoExpandColumn : 'location_name',
1799 '|xns' : 'Roo.grid',
1800 xtype : 'ColumnModel',
1801 header : 'Location',
1803 renderer : function(v) { return String.format('{0}', v); },
1805 dataIndex : 'location_name'
1808 '|xns' : 'Roo.grid',
1809 xtype : 'ColumnModel',
1810 header : 'Itemloc qty',
1812 renderer : function(v) { return String.format('{0}', v*1 ? (v*1).toFixed(0) : ''); },
1814 dataIndex : 'itemloc_realqty'
1818 rowdblclick : function (_self, rowIndex, e)
1820 if (!_this.dialog) return;
1821 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
1822 _this.grid.footer.onClick('first');
1827 _this.locgrid = this;
1828 //_this.dialog = Pman.Dialog.FILL_IN
1842 xtype : 'GridPanel',
1843 fitContainer : true,
1845 tableName : 'itemloc',
1847 activate : function() {
1848 _this.locpanel = this;
1864 xtype : 'NestedLayoutPanel',