1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleItem = new Roo.XComponent({
6 part : ["Xtuple","Item"],
7 order : '001-Pman.Tab.XtupleItem',
9 parent : 'Pman.Tab.XtupleManage',
10 name : "Pman.Tab.XtupleItem",
18 xtype: 'NestedLayoutPanel',
24 xtype: 'BorderLayout',
31 activate : function() {
34 _this.grid.footer.onClick('first');
51 //_this.dialog = Pman.Dialog.FILL_IN
52 if (_this.panel.active) {
53 this.footer.onClick('first');
56 cellclick : function (_self, row, col, e)
58 var di = _this.grid.colModel.getDataIndex(col);
60 var rec = _this.grid.ds.getAt(row);
63 if (di == 'item_active') {
65 var nv = rec.data.item_active ? 0 : 1;
68 url : baseURL + '/Roo/Item',
70 item_id : rec.data.item_id,
73 success : function() {
74 rec.set('item_active', nv);
82 if(di == 'itemsrc_active'){
83 if(!rec.data.itemsrc_active){
84 Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
87 if(rec.data.itemsrc_active){
88 Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
98 _this.locgrid.footer.onClick('first');
104 afteredit : function (e)
110 url : baseURL +'/Roo/Charass',
112 charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
113 charass_value : e.value,
114 charass_target_type : 'I',
116 charass_target_id : e.record.data.item_id
127 celldblclick : function (_self, rowIndex, columnIndex, e)
129 var s = _this.grid.ds.getAt(rowIndex);
131 Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
132 _this.grid.footer.onClick('first');
136 autoExpandColumn : 'item_descrip1',
143 beforeload : function (_self, o)
145 o.params._with_prodcat = 1;
146 o.params._with_char = 1;
147 o.params._with_itemsrc_active = 1;
148 o.params._with_last_purchase_price = 1;
149 o.params._with_image = 1;
150 var s = _this.search.getValue();
152 o.params['query[number_or_name]'] = s;
154 if (!_this.active.pressed) {
155 o.params.item_active = 1;
157 if (_this.brandSel.getValue().length) {
158 o.params._with_brand = _this.brandSel.getValue()
161 o.params._with_stock_balance = 1;
163 update : function (_self, record, operation)
165 if(operation != 'commit'){
169 var nv = record.data.itemsrc_active ? 0 : 1;
172 url : baseURL + '/Roo/Itemsrc',
175 item_id : record.data.item_id,
178 success : function(res) {
179 record.set('itemsrc_active', nv);
183 load : function (_self, records, options)
186 var cm = _this.grid.getColumnModel();
188 cm.setColumnHeader(cm.getIndexByDataIndex('item_stock_balance'),records[0].data.default_location_name);
193 sortInfo : { field : 'item_number', direction: 'ASC' },
198 url : baseURL + '/Roo/item.php'
203 totalProperty : 'total',
212 'name': 'item_number',
216 'name': 'item_descrip1',
220 'name': 'item_descrip2',
224 'name': 'item_classcode_id',
228 'name': 'item_picklist',
232 'name': 'item_comments',
240 'name': 'item_fractional',
244 'name': 'item_active',
252 'name': 'item_prodweight',
256 'name': 'item_packweight',
260 'name': 'item_prodcat_id',
264 'name': 'item_exclusive',
268 'name': 'item_listprice',
272 'name': 'item_config',
276 'name': 'item_extdescrip',
280 'name': 'item_upccode',
284 'name': 'item_maxcost',
288 'name': 'item_inv_uom_id',
292 'name': 'item_price_uom_id',
296 'name': 'item_warrdays',
300 'name': 'item_freightclass_id',
304 'name': 'item_tax_recoverable',
308 'name': 'item_price_uom_id_uom_id',
312 'name': 'item_price_uom_id_uom_name',
316 'name': 'item_price_uom_id_uom_descrip',
320 'name': 'item_price_uom_id_uom_item_weight',
324 'name': 'item_inv_uom_id_uom_id',
328 'name': 'item_inv_uom_id_uom_name',
332 'name': 'item_inv_uom_id_uom_descrip',
336 'name': 'item_inv_uom_id_uom_item_weight',
340 'name': 'item_freightclass_id_freightclass_id',
344 'name': 'item_freightclass_id_freightclass_code',
348 'name': 'item_freightclass_id_freightclass_descrip',
352 'name': 'item_classcode_id_classcode_id',
356 'name': 'item_classcode_id_classcode_code',
360 'name': 'item_classcode_id_classcode_descrip',
364 'name': 'item_classcode_id_classcode_mfg',
368 'name': 'item_classcode_id_classcode_creator',
372 'name': 'item_classcode_id_classcode_created',
376 'name': 'item_classcode_id_classcode_modifier',
380 'name': 'item_classcode_id_classcode_modified',
384 'name': 'item_classcode_id_classcode_type',
398 render : function (_self)
400 _this.brandSel = _self;
402 select : function (combo, record, index)
404 _this.grid.footer.onClick('first');
409 displayField : 'charass_value',
411 emptyText : "Select Brand",
412 forceSelection : true,
414 loadingText : "Searching...",
417 qtip : "Select Brand",
418 queryParam : 'query[charass_value]',
419 selectOnFocus : true,
420 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
421 triggerAction : 'all',
427 beforeload : function (_self, o)
429 o.params = o.params || {};
430 // staff can see all logs, other companies can only see their own.
431 // look for all of the charass 's with the same type= eg. brand.
433 o.params.charass_char_id_char_name = 'BRAND';
434 o.params.charass_target_type ='I';
435 o.params._distinct = 'charass_value';
436 o.params._columns = 'charass_value';
441 sortInfo : { field : 'charass_value' , direction : 'ASC' },
446 url : baseURL + '/Roo/Charass.php'
451 totalProperty : 'total',
460 'name': 'person_name',
464 'name': 'event_when',
466 'dateFormat': 'Y-m-d'
493 'name': 'person_id_id',
497 'name': 'person_id_office_id',
501 'name': 'person_id_name',
505 'name': 'person_id_phone',
509 'name': 'person_id_fax',
513 'name': 'person_id_email',
517 'name': 'person_id_company_id',
521 'name': 'person_id_role',
525 'name': 'person_id_active',
529 'name': 'person_id_remarks',
533 'name': 'person_id_passwd',
537 'name': 'person_id_owner_id',
541 'name': 'person_id_lang',
545 'name': 'person_id_no_reset_sent',
549 'name': 'person_id_action_type',
553 'name': 'person_id_project_id',
557 'name': 'person_id_deleted_by',
561 'name': 'person_id_deleted_dt',
572 render : function (_self)
574 _this.search = _self;
576 specialkey : function (_self, e)
578 _this.grid.footer.onClick('first');
581 emptyText : "Search Product"
587 click : function (_self, e)
589 _this.grid.footer.onClick('first');
593 icon : rootURL + '/Pman/templates/images/search.gif'
599 click : function (_self, e)
601 _this.search.setValue('');
605 _this.grid.footer.onClick('first');
609 icon : rootURL + '/Pman/templates/images/edit-clear.gif'
619 toggle : function (_self, pressed)
622 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
623 (function() { _this.grid.footer.onClick('first'); }).defer(100);
625 render : function (_self)
627 _this.active = _self;
631 text : "Show Inactive"
644 Pman.Dialog.XtupleItem.show( { item_id : 0 } , function() {
645 _this.grid.footer.onClick('first');
649 cls : 'x-btn-text-icon',
651 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
659 var s = _this.grid.selModel.getSelectedCell();
661 Roo.MessageBox.alert("Error", "Select a product");
664 var rec = _this.grid.ds.getAt(s[0]);
668 Roo.MessageBox.prompt(
670 "Warning changing SKU names affects historical data, and should only be done if you are sure that this is ok",
678 item_id : rec.data.item_id,
691 var change = function(params){
693 url : baseURL + '/Roo/Item',
697 success : function(res) {
699 _this.grid.footer.onClick('refresh');
700 if(typeof(res.data) == 'string'){
701 Roo.MessageBox.alert("Notice", 'SKU has been renamed');
705 Roo.each(res.data, function(o){
706 offices.push(Pman.Xtuple.offices[o]);
708 Roo.MessageBox.alert("Notice", 'SKU has been renamed in ' + offices.join(", "));
711 failure : function(res) {
714 if (res.errors.confirm.length) {
716 Roo.each(res.errors.confirm, function(o){
717 offices.push(Pman.Xtuple.offices[o]);
719 Roo.MessageBox.confirm(
721 " Do you want to change the name in " + offices.join(", ") + "?",
724 Roo.MessageBox.alert("Notice", 'SKU was not changed');
727 delete params['_check'];
728 params._can_change_sku = 1;
735 Roo.MessageBox.alert("Error", res.errorMsg);
752 text : "Report start :"
758 render : function (_self)
760 _this.dateFrom = _self;
765 value : (function() { return (new Date()).format('Y') + '-01-01'; })()
771 render : function (_self)
773 _this.datespan = _self;
777 displayField : 'fname',
779 fieldLabel : 'Status',
780 hiddenName : 'cm_status',
783 name : 'cm_status_name',
784 triggerAction : 'all',
786 valueField : 'ftype',
789 xtype: 'SimpleStore',
792 [ '1', "Single Month Sales"],
793 [ '3', "Quarter Sales"],
794 [ '6', "Half year Sales"] ,
795 [ '12', "Full Year Sales"]
797 fields : [ 'ftype', 'fname']
804 click : function (_self, e)
806 if (!_this.brandSel.getValue().length) {
807 Roo.MessageBox.alert("Error", "Select a brand to download");
812 url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
814 date_from : _this.dateFrom.getValue(),
815 brand : _this.brandSel.getValue(),
816 span : _this.datespan.getValue()
823 text : "Download Sales Report"
828 xtype: 'PagingToolbar',
832 displayMsg : "Displaying item{0} - {1} of {2}",
833 emptyMsg : "No item found",
838 text : "Tools - Upload/Download",
847 click : function (_self, e)
851 url : baseURL + '/Roo/item',
858 text : "Download Standard costs"
864 click : function (_self, e)
866 // 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");
869 Pman.Dialog.Image.show(
871 _url : baseURL+'/Xtuple/Import/Products',
879 msg.push("Updated " + data.updated + " Products(s)");
882 msg.push("Added " + data.inserted + " Products(s)");
885 msg.push("Skipped " + data.skipped);
889 msg.push("No data changed");
891 Roo.MessageBox.alert("Notice", msg.join("\n"));
897 text : "Upload new products and costs"
907 click : function (_self, e)
909 Roo.MessageBox.progress ("Syncing Stock", "Sending");
916 url : baseURL+'/Roo/Item',
923 success : function(res) {
925 if (!res.data.total) {
926 Roo.MessageBox.hide();
929 offset += res.data.limit;
930 Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
940 text : "Sync Product Data from HK",
941 hidden : (function() {
943 return baseURL.match(/hk\.php$/) ? true : false;
950 click : function (_self, e)
952 Roo.MessageBox.progress ("Syncing Stock", "Sending");
959 url : baseURL+'/Roo/Item',
965 success : function(res) {
968 Roo.MessageBox.hide();
969 _this.grid.footer.onClick('refresh');
979 text : "Sync Product from HK (New Products Only)",
980 hidden : (function() {
982 return baseURL.match(/hk\.php$/) ? true : false;
989 click : function (_self, e)
991 Roo.MessageBox.progress ("Syncing Stock", "Sending");
998 url : baseURL+'/Roo/Item',
1002 item_number : _this.search.getValue()
1004 success : function(res) {
1007 Roo.MessageBox.hide();
1008 _this.grid.footer.onClick('refresh');
1018 text : "Sync Product from HK (Based on Search)",
1019 hidden : (function() {
1021 return baseURL.match(/hk\.php$/) ? true : false;
1031 xtype: 'ColumnModel',
1033 dataIndex : 'item_image_id',
1037 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.item_image_filename); }
1040 xtype: 'ColumnModel',
1042 dataIndex : 'item_char_brand',
1046 renderer : function(v) { return String.format('{0}', v); },
1048 xtype: 'GridEditor',
1055 displayField : 'charass_value',
1057 forceSelection : false,
1059 loadingText : "Searching...",
1062 qtip : "Select Brand",
1063 queryParam : 'query[charass_value]',
1064 selectOnFocus : true,
1065 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1066 triggerAction : 'all',
1072 beforeload : function (_self, o)
1074 o.params = o.params || {};
1075 // staff can see all logs, other companies can only see their own.
1076 // look for all of the charass 's with the same type= eg. brand.
1078 o.params.charass_char_id_char_name = 'BRAND';
1079 o.params.charass_target_type ='I';
1080 o.params._distinct = 'charass_value';
1081 o.params._columns = 'charass_value';
1086 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1091 url : baseURL + '/Roo/Charass.php'
1094 xtype: 'JsonReader',
1096 totalProperty : 'total',
1105 'name': 'person_name',
1109 'name': 'event_when',
1111 'dateFormat': 'Y-m-d'
1130 'name': 'person_id',
1138 'name': 'person_id_id',
1142 'name': 'person_id_office_id',
1146 'name': 'person_id_name',
1150 'name': 'person_id_phone',
1154 'name': 'person_id_fax',
1158 'name': 'person_id_email',
1162 'name': 'person_id_company_id',
1166 'name': 'person_id_role',
1170 'name': 'person_id_active',
1174 'name': 'person_id_remarks',
1178 'name': 'person_id_passwd',
1182 'name': 'person_id_owner_id',
1186 'name': 'person_id_lang',
1190 'name': 'person_id_no_reset_sent',
1194 'name': 'person_id_action_type',
1198 'name': 'person_id_project_id',
1202 'name': 'person_id_deleted_by',
1206 'name': 'person_id_deleted_dt',
1216 xtype: 'ColumnModel',
1218 dataIndex : 'item_char_productgroup',
1219 header : 'Product Group',
1222 renderer : function(v) { return String.format('{0}', v); },
1224 xtype: 'GridEditor',
1231 displayField : 'charass_value',
1233 forceSelection : false,
1235 loadingText : "Searching...",
1238 qtip : "Select Brand",
1239 queryParam : 'query[charass_value]',
1240 selectOnFocus : true,
1241 tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
1242 triggerAction : 'all',
1248 beforeload : function (_self, o)
1250 o.params = o.params || {};
1251 // staff can see all logs, other companies can only see their own.
1252 // look for all of the charass 's with the same type= eg. brand.
1254 o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1255 o.params.charass_target_type ='I';
1256 o.params._distinct = 'charass_value';
1257 o.params._columns = 'charass_value';
1261 sortInfo : { field : 'charass_value' , direction : 'ASC' },
1266 url : baseURL + '/Roo/Charass.php'
1269 xtype: 'JsonReader',
1271 totalProperty : 'total',
1280 'name': 'person_name',
1284 'name': 'event_when',
1286 'dateFormat': 'Y-m-d'
1305 'name': 'person_id',
1313 'name': 'person_id_id',
1317 'name': 'person_id_office_id',
1321 'name': 'person_id_name',
1325 'name': 'person_id_phone',
1329 'name': 'person_id_fax',
1333 'name': 'person_id_email',
1337 'name': 'person_id_company_id',
1341 'name': 'person_id_role',
1345 'name': 'person_id_active',
1349 'name': 'person_id_remarks',
1353 'name': 'person_id_passwd',
1357 'name': 'person_id_owner_id',
1361 'name': 'person_id_lang',
1365 'name': 'person_id_no_reset_sent',
1369 'name': 'person_id_action_type',
1373 'name': 'person_id_project_id',
1377 'name': 'person_id_deleted_by',
1381 'name': 'person_id_deleted_dt',
1391 xtype: 'ColumnModel',
1393 dataIndex : 'item_number',
1397 renderer : function(v) { return String.format('<B>{0}</B>', v); }
1400 xtype: 'ColumnModel',
1402 dataIndex : 'item_char_pickface_location',
1403 header : 'Pickface',
1406 renderer : function(v) { return String.format('{0}', v); },
1408 xtype: 'GridEditor',
1417 xtype: 'ColumnModel',
1419 dataIndex : 'item_char_pallet_location',
1423 renderer : function(v) { return String.format('{0}', v); },
1425 xtype: 'GridEditor',
1434 xtype: 'ColumnModel',
1436 dataIndex : 'item_descrip1',
1437 header : 'Description',
1440 renderer : function(v) { return String.format('{0}', v); }
1443 xtype: 'ColumnModel',
1445 dataIndex : 'itemsrc_active',
1446 header : 'Purchased',
1448 renderer : function(v) {
1449 var state = v * 1 > 0 ? '-checked' : '';
1451 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1456 xtype: 'ColumnModel',
1458 dataIndex : 'item_sold',
1459 header : 'is Sold?',
1461 renderer : function(v) {
1462 var state = v * 1 > 0 ? '-checked' : '';
1464 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1469 xtype: 'ColumnModel',
1471 dataIndex : 'item_active',
1472 header : 'is Active?',
1474 renderer : function(v) {
1475 var state = v * 1 > 0 ? '-checked' : '';
1477 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1482 xtype: 'ColumnModel',
1485 dataIndex : 'last_purchase_price',
1486 header : 'Last purchase price',
1488 renderer : function(v,x,r) {
1490 return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
1495 xtype: 'ColumnModel',
1497 dataIndex : 'item_prodcat_id_prodcat_code',
1498 header : 'Item prodcat',
1500 renderer : function(v,x,r) {
1501 return String.format('{0}/{1}', r.data.item_type, v);
1505 xtype: 'ColumnModel',
1508 dataIndex : 'item_actcost',
1511 renderer : function(v,x,r) {
1513 return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
1518 xtype: 'ColumnModel',
1521 dataIndex : 'item_base_cost',
1522 header : 'Cost (base)',
1524 renderer : function(v,x,r) {
1526 return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
1531 xtype: 'ColumnModel',
1534 dataIndex : 'item_stock_balance',
1537 renderer : function(v) { return String.format('{0}', v ? parseInt( v) : ''); }
1546 activate : function() {
1547 _this.locpanel = this;
1552 fitContainer : true,
1555 tableName : 'itemloc',
1563 _this.locgrid = this;
1564 //_this.dialog = Pman.Dialog.FILL_IN
1567 rowdblclick : function (_self, rowIndex, e)
1569 if (!_this.dialog) return;
1570 _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
1571 _this.grid.footer.onClick('first');
1575 autoExpandColumn : 'location_name',
1581 beforeload : function (_self, o)
1583 var sel = _this.grid.selModel.getSelectedCell();
1588 var rec = _this.grid.ds.getAt(sel[0]);
1589 o.params._stock_for_item_id = rec.data.item_id;
1590 //o.params['!itemloc_qty'] = 0;
1596 sortInfo : { field : 'location_name', direction: 'ASC' },
1601 url : baseURL + '/Roo/location.php'
1604 xtype: 'JsonReader',
1606 totalProperty : 'total',
1611 'name': 'itemloc_id',
1615 'name': 'itemloc_itemsite_id',
1619 'name': 'itemloc_location_id',
1623 'name': 'itemloc_qty',
1627 'name': 'itemloc_expiration',
1629 'dateFormat': 'Y-m-d'
1632 'name': 'itemloc_consolflag',
1636 'name': 'itemloc_ls_id',
1640 'name': 'itemloc_warrpurc',
1642 'dateFormat': 'Y-m-d'
1648 xtype: 'PagingToolbar',
1652 displayMsg : "Displaying itemloc{0} - {1} of {2}",
1653 emptyMsg : "No itemloc found"
1657 xtype: 'ColumnModel',
1659 dataIndex : 'location_name',
1660 header : 'Location',
1662 renderer : function(v) { return String.format('{0}', v); }
1665 xtype: 'ColumnModel',
1667 dataIndex : 'itemloc_realqty',
1668 header : 'Itemloc qty',
1670 renderer : function(v) { return String.format('{0}', v*1 ? (v*1).toFixed(0) : ''); }
1677 xtype: 'LayoutRegion',
1681 xtype: 'LayoutRegion',