sm : {
xtype: 'RowSelectionModel',
xns: Roo.grid,
+ listeners : {
+ afterselectionchange : function (_self)
+ {
+ _this.igrid.footer.onClick('first');
+ }
+ },
singleSelect : true
},
dataSource : {
if (_this.ipanel.active) {
//this.footer.onClick('first');
}
- },
- cellclick : function (_self, row, col, e)
- {
- var di = _this.grid.colModel.getDataIndex(col);
-
- var rec = _this.grid.ds.getAt(row);
-
- if(di == 'item_image_filename'){
- if(!rec.data.item_image_id){
- return;
- }
- var u = baseURL;
- if(rec.data.item_image_from_hk){
- u = u.split('/');
- u.pop();
- u = u.join('/') + '/hk.php';
- }
- Pman.download( {
- url: u + '/Images/Download/' + rec.data.item_image_id + '/' + rec.data.item_image_filename
- });
- return;
- }
-
- if (di == 'item_active') {
-
- var nv = rec.data.item_active ? 0 : 1;
- new Pman.Request({
- mask : 'Saving',
- url : baseURL + '/Roo/Item',
- params : {
- item_id : rec.data.item_id,
- item_active : nv
- },
- success : function() {
- rec.set('item_active', nv);
- }
- });
- return;
-
-
- }
-
- if(di == 'itemsrc_active'){
- if(!rec.data.itemsrc_active){
- Roo.MessageBox.alert('Error','Please edit it on Xtuple tool');
- return;
- }
- if(rec.data.itemsrc_active){
- Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
- function (res) {
- if(res!='yes') {
- return;
- }
- rec.commit();
- });
- }
- }
-
- _this.locgrid.footer.onClick('first');
-
-
-
-
},
afteredit : function (e)
{
+ if(e.value == e.originalValue){
+ return false;
+ }
+
+ var p = _this.grid.getSelectionModel().getSelected();
+ if(!p || p.data.ipshead_id * 1 < 1){
+ Roo.MessageBox.alert('Error','Please select a price list');
+ return false;
+ }
- Roo.log(e);
new Pman.Request({
- url : baseURL +'/Roo/Charass',
+ url : baseURL +'/Roo/Item',
+ method : 'POST',
+ marks : 'Posting',
params : {
- charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
- charass_value : e.value,
- charass_target_type : 'I',
- charass_default : 1,
- charass_target_id : e.record.data.item_id
+ update_ipshead : 1,
+ ipshead_id : p.data.ipshead_id,
+ item_id : e.record.data.item_id,
+ _price : e.value,
},
- method : 'POST'
+ success : function() {
+ _this.igrid.footer.onClick('refresh');
+ }
+
});
-
- e.record.commit();
-
-
-
},
- rowdblclick : function (_self, rowIndex, e)
+ beforeedit : function (e)
{
- if (!_this.dialog) return;
- _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
- _this.grid.footer.onClick('first');
- });
+ if(e.field != 'ipshead_price'){
+ return false;
+ }
+
}
},
- autoExpandColumn : 'item_descrip1',
+ autoExpandColumn : 'item_number',
clicksToEdit : 1,
loadMask : true,
dataSource : {
var p = _this.grid.getSelectionModel().getSelected();
- if(!p || p.ipshead_id * 1 < 1){
- this.ds.removeAll();
- return;
+ if(!p || p.data.ipshead_id * 1 < 1){
+ this.removeAll();
+ return false;
}
- o.params.item_active = 1;
+ //o.params.item_active = 1;
+ o.params._ipshead_price = 1;
+ o.params._ipshead_id = p.data.ipshead_id;
- },
- update : function (_self, record, operation)
- {
- if(operation != 'commit'){
- return;
- }
-
- var nv = record.data.itemsrc_active ? 0 : 1;
- new Pman.Request({
- mask : 'Saving',
- url : baseURL + '/Roo/Itemsrc',
- params : {
- _update_by_item : 1,
- item_id : record.data.item_id,
- itemsrc_active : nv
- },
- success : function(res) {
- record.set('itemsrc_active', nv);
- }
- });
}
},
remoteSort : true,
reader : {
xtype: 'JsonReader',
xns: Roo.data,
- totalProperty : 'total',
- root : 'data',
id : 'id',
+ root : 'data',
+ totalProperty : 'total',
fields : [
{
'name': 'item_id',
{
'name': 'item_number',
'type': 'string'
- },
- {
- 'name': 'item_descrip1',
- 'type': 'string'
- },
- {
- 'name': 'item_descrip2',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id',
- 'type': 'int'
- },
- {
- 'name': 'item_picklist',
- 'type': 'int'
- },
- {
- 'name': 'item_comments',
- 'type': 'string'
- },
- {
- 'name': 'item_sold',
- 'type': 'int'
- },
- {
- 'name': 'item_fractional',
- 'type': 'int'
- },
- {
- 'name': 'item_active',
- 'type': 'int'
- },
- {
- 'name': 'item_type',
- 'type': 'string'
- },
- {
- 'name': 'item_prodweight',
- 'type': 'float'
- },
- {
- 'name': 'item_packweight',
- 'type': 'float'
- },
- {
- 'name': 'item_prodcat_id',
- 'type': 'int'
- },
- {
- 'name': 'item_exclusive',
- 'type': 'int'
- },
- {
- 'name': 'item_listprice',
- 'type': 'float'
- },
- {
- 'name': 'item_config',
- 'type': 'int'
- },
- {
- 'name': 'item_extdescrip',
- 'type': 'string'
- },
- {
- 'name': 'item_upccode',
- 'type': 'string'
- },
- {
- 'name': 'item_maxcost',
- 'type': 'float'
- },
- {
- 'name': 'item_inv_uom_id',
- 'type': 'int'
- },
- {
- 'name': 'item_price_uom_id',
- 'type': 'int'
- },
- {
- 'name': 'item_warrdays',
- 'type': 'int'
- },
- {
- 'name': 'item_freightclass_id',
- 'type': 'int'
- },
- {
- 'name': 'item_tax_recoverable',
- 'type': 'int'
- },
- {
- 'name': 'item_price_uom_id_uom_id',
- 'type': 'int'
- },
- {
- 'name': 'item_price_uom_id_uom_name',
- 'type': 'string'
- },
- {
- 'name': 'item_price_uom_id_uom_descrip',
- 'type': 'string'
- },
- {
- 'name': 'item_price_uom_id_uom_item_weight',
- 'type': 'int'
- },
- {
- 'name': 'item_inv_uom_id_uom_id',
- 'type': 'int'
- },
- {
- 'name': 'item_inv_uom_id_uom_name',
- 'type': 'string'
- },
- {
- 'name': 'item_inv_uom_id_uom_descrip',
- 'type': 'string'
- },
- {
- 'name': 'item_inv_uom_id_uom_item_weight',
- 'type': 'int'
- },
- {
- 'name': 'item_freightclass_id_freightclass_id',
- 'type': 'int'
- },
- {
- 'name': 'item_freightclass_id_freightclass_code',
- 'type': 'string'
- },
- {
- 'name': 'item_freightclass_id_freightclass_descrip',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id_classcode_id',
- 'type': 'int'
- },
- {
- 'name': 'item_classcode_id_classcode_code',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id_classcode_descrip',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id_classcode_mfg',
- 'type': 'int'
- },
- {
- 'name': 'item_classcode_id_classcode_creator',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id_classcode_created',
- 'type': 'date'
- },
- {
- 'name': 'item_classcode_id_classcode_modifier',
- 'type': 'string'
- },
- {
- 'name': 'item_classcode_id_classcode_modified',
- 'type': 'date'
- },
- {
- 'name': 'item_classcode_id_classcode_type',
- 'type': 'string'
}
]
}
xtype: 'PagingToolbar',
xns: Roo,
displayInfo : true,
- displayMsg : "Displaying item{0} - {1} of {2}",
- emptyMsg : "No item found",
- pageSize : 50,
- items : [
- {
- xtype: 'Button',
- xns: Roo.Toolbar,
- listeners : {
- click : function (_self, e)
- {
- new Pman.Download({
- method: 'GET',
- url : baseURL + '/Roo/item',
- params : {
- _costgrid : 1
- }
- });
- }
- },
- text : "Download Standard costs"
- },
- {
- xtype: 'Button',
- xns: Roo.Toolbar,
- listeners : {
- click : function (_self, e)
- {
- Pman.Dialog.Image.show(
- {
- _url : baseURL+'/Xtuple/Import/Products'
-
- },
- function (data) {
- var msg = [];
-
- if (data.updated) {
- msg.push("Updated " + data.updated + " Products(s)");
- }
- if (data.inserted) {
- msg.push("Added " + data.inserted + " Products(s)");
- }
- if (data.skipped) {
- msg.push("Skipped " + data.skipped);
- }
-
- if (!msg.length) {
- msg.push("No data changed");
- }
- Roo.MessageBox.alert("Notice", msg.join("\n"));
-
- }
- );
- }
- },
- text : "Upload new products and costs"
- },
- {
- xtype: 'Button',
- xns: Roo.Toolbar,
- listeners : {
- click : function (_self, e)
- {
-
- var sel = _this.grid.selModel.getSelectedCell();
- if (!sel) {
- Roo.MessageBox.alert("Error", "Select a row");
- return;
- }
-
- var rec = _this.grid.ds.getAt(sel[0]);
- if(rec.data.item_id * 1 < 1){
- return;
- }
-
- Pman.Dialog.Image.show({
- id : rec.data.item_image_id ? rec.data.item_image_id : 0,
- onid : rec.data.item_id,
- ontable : 'Item'
- }, function(data) {
- if (data) {
- _this.grid.footer.onClick('first');
-
- }
-
- });
- }
- },
- text : "Upload an image"
- },
- {
- xtype: 'Button',
- xns: Roo.Toolbar,
- listeners : {
- click : function (_self, e)
- {
- Roo.MessageBox.progress ("Syncing Stock", "Sending");
-
- var offset = 0;
-
- function runSync() {
-
- new Pman.Request( {
- url : baseURL+'/Roo/Item',
- method : 'GET',
- params : {
- _syncFromHK : 1,
- offset : offset
- },
- success : function(res) {
- Roo.log(res);
- if (!res.data.total) {
- Roo.MessageBox.hide();
- return;
- }
- offset += res.data.limit;
- Roo.MessageBox.updateProgress ( offset / res.data.total, "Done " + offset + '/' + res.data.total);
- runSync();
- }
-
-
- });
- }
- runSync();
- }
- },
- text : "Sync Product Data from HK",
- hidden : (function() {
-
- return baseURL.match(/hk\.php$/) ? true : false;
- })()
- }
- ]
+ displayMsg : "",
+ emptyMsg : "",
+ pageSize : 25
},
colModel : [
{
xtype: 'ColumnModel',
xns: Roo.grid,
- dataIndex : 'item_image_filename',
- header : 'Image ( Click to download )',
+ dataIndex : 'item_number',
+ header : 'Number',
width : 150,
- renderer : function(v,x,r)\r
- {
- if(!v){
- return '';
- }
- if(r.data.item_image_from_hk){
- var url = baseURL.split('/');
- url.pop();
- url = url.join('/');
- return '<img src="' + url + '/hk.php/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';
- }\r
- return '<img src="' + baseURL + '/Images/Thumb/150x150/' + r.data.item_image_id + '/' + v + '" width="150" height="150" />';\r
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_char_brand',
- header : 'Brand',
- sortable : true,
- width : 100,
- renderer : function(v) { return String.format('{0}', v); },
- editor : {
- xtype: 'GridEditor',
- xns: Roo.grid,
- field : {
- xtype: 'ComboBox',
- xns: Roo.form,
- allowBlank : true,
- alwaysQuery : true,
- displayField : 'charass_value',
- editable : true,
- forceSelection : false,
- listWidth : 300,
- loadingText : "Searching...",
- minChars : 2,
- pageSize : 20,
- qtip : "Select Brand",
- queryParam : 'query[charass_value]',
- selectOnFocus : true,
- tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
- triggerAction : 'all',
- width : 150,
- store : {
- xtype: 'Store',
- xns: Roo.data,
- listeners : {
- beforeload : function (_self, o)
- {
- o.params = o.params || {};
- // staff can see all logs, other companies can only see their own.
- // look for all of the charass 's with the same type= eg. brand.
-
- o.params.charass_char_id_char_name = 'BRAND';
- o.params.charass_target_type ='I';
- o.params._distinct = 'charass_value';
- o.params._columns = 'charass_value';
-
- }
- },
- remoteSort : true,
- sortInfo : { field : 'charass_value' , direction : 'ASC' },
- proxy : {
- xtype: 'HttpProxy',
- xns: Roo.data,
- method : 'GET',
- url : baseURL + '/Roo/Charass.php'
- },
- reader : {
- xtype: 'JsonReader',
- xns: Roo.data,
- totalProperty : 'total',
- root : 'data',
- id : 'id',
- fields : [
- {
- 'name': 'id',
- 'type': 'int'
- },
- {
- 'name': 'person_name',
- 'type': 'string'
- },
- {
- 'name': 'event_when',
- 'type': 'date',
- 'dateFormat': 'Y-m-d'
- },
- {
- 'name': 'action',
- 'type': 'string'
- },
- {
- 'name': 'ipaddr',
- 'type': 'string'
- },
- {
- 'name': 'on_id',
- 'type': 'int'
- },
- {
- 'name': 'on_table',
- 'type': 'string'
- },
- {
- 'name': 'person_id',
- 'type': 'int'
- },
- {
- 'name': 'remarks',
- 'type': 'string'
- },
- {
- 'name': 'person_id_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_office_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_name',
- 'type': 'string'
- },
- {
- 'name': 'person_id_phone',
- 'type': 'string'
- },
- {
- 'name': 'person_id_fax',
- 'type': 'string'
- },
- {
- 'name': 'person_id_email',
- 'type': 'string'
- },
- {
- 'name': 'person_id_company_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_role',
- 'type': 'string'
- },
- {
- 'name': 'person_id_active',
- 'type': 'int'
- },
- {
- 'name': 'person_id_remarks',
- 'type': 'string'
- },
- {
- 'name': 'person_id_passwd',
- 'type': 'string'
- },
- {
- 'name': 'person_id_owner_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_lang',
- 'type': 'string'
- },
- {
- 'name': 'person_id_no_reset_sent',
- 'type': 'int'
- },
- {
- 'name': 'person_id_action_type',
- 'type': 'string'
- },
- {
- 'name': 'person_id_project_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_deleted_by',
- 'type': 'int'
- },
- {
- 'name': 'person_id_deleted_dt',
- 'type': 'date'
- }
- ]
- }
- }
- }
- }
+ renderer : function(v) { return String.format('{0}', v); }
},
{
xtype: 'ColumnModel',
xns: Roo.grid,
- dataIndex : 'item_char_productgroup',
- header : 'Product Group',
+ align : 'right',
+ dataIndex : 'ipshead_price',
+ header : 'Price',
width : 100,
- renderer : function(v) { return String.format('{0}', v); },
+ renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
editor : {
xtype: 'GridEditor',
xns: Roo.grid,
field : {
- xtype: 'ComboBox',
+ xtype: 'NumberField',
xns: Roo.form,
- allowBlank : true,
- alwaysQuery : true,
- displayField : 'charass_value',
- editable : true,
- forceSelection : false,
- listWidth : 300,
- loadingText : "Searching...",
- minChars : 2,
- pageSize : 20,
- qtip : "Select Brand",
- queryParam : 'query[charass_value]',
- selectOnFocus : true,
- tpl : '<div class="x-grid-cell-text x-btn button"><b>{charass_value}</b> </div>',
- triggerAction : 'all',
- width : 150,
- store : {
- xtype: 'Store',
- xns: Roo.data,
- listeners : {
- beforeload : function (_self, o)
- {
- o.params = o.params || {};
- // staff can see all logs, other companies can only see their own.
- // look for all of the charass 's with the same type= eg. brand.
-
- o.params.charass_char_id_char_name = 'PRODUCTGROUP';
- o.params.charass_target_type ='I';
- o.params._distinct = 'charass_value';
- o.params._columns = 'charass_value';
- }
- },
- remoteSort : true,
- sortInfo : { field : 'charass_value' , direction : 'ASC' },
- proxy : {
- xtype: 'HttpProxy',
- xns: Roo.data,
- method : 'GET',
- url : baseURL + '/Roo/Charass.php'
- },
- reader : {
- xtype: 'JsonReader',
- xns: Roo.data,
- totalProperty : 'total',
- root : 'data',
- id : 'id',
- fields : [
- {
- 'name': 'id',
- 'type': 'int'
- },
- {
- 'name': 'person_name',
- 'type': 'string'
- },
- {
- 'name': 'event_when',
- 'type': 'date',
- 'dateFormat': 'Y-m-d'
- },
- {
- 'name': 'action',
- 'type': 'string'
- },
- {
- 'name': 'ipaddr',
- 'type': 'string'
- },
- {
- 'name': 'on_id',
- 'type': 'int'
- },
- {
- 'name': 'on_table',
- 'type': 'string'
- },
- {
- 'name': 'person_id',
- 'type': 'int'
- },
- {
- 'name': 'remarks',
- 'type': 'string'
- },
- {
- 'name': 'person_id_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_office_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_name',
- 'type': 'string'
- },
- {
- 'name': 'person_id_phone',
- 'type': 'string'
- },
- {
- 'name': 'person_id_fax',
- 'type': 'string'
- },
- {
- 'name': 'person_id_email',
- 'type': 'string'
- },
- {
- 'name': 'person_id_company_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_role',
- 'type': 'string'
- },
- {
- 'name': 'person_id_active',
- 'type': 'int'
- },
- {
- 'name': 'person_id_remarks',
- 'type': 'string'
- },
- {
- 'name': 'person_id_passwd',
- 'type': 'string'
- },
- {
- 'name': 'person_id_owner_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_lang',
- 'type': 'string'
- },
- {
- 'name': 'person_id_no_reset_sent',
- 'type': 'int'
- },
- {
- 'name': 'person_id_action_type',
- 'type': 'string'
- },
- {
- 'name': 'person_id_project_id',
- 'type': 'int'
- },
- {
- 'name': 'person_id_deleted_by',
- 'type': 'int'
- },
- {
- 'name': 'person_id_deleted_dt',
- 'type': 'date'
- }
- ]
- }
- }
+ decimalPrecision : 2,
+ minValue : 1,
+ style : 'text-align:right'
}
}
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_number',
- header : 'Number',
- width : 100,
- renderer : function(v) { return String.format('{0}', v); }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_descrip1',
- header : 'Description',
- width : 200,
- renderer : function(v) { return String.format('{0}', v); }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'itemsrc_active',
- header : 'Purchased',
- width : 75,
- renderer : function(v) {
- var state = v * 1 > 0 ? '-checked' : '';
-
- return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
-
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_sold',
- header : 'is Sold?',
- width : 75,
- renderer : function(v) {
- var state = v * 1 > 0 ? '-checked' : '';
-
- return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
-
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_active',
- header : 'is Active?',
- width : 75,
- renderer : function(v) {
- var state = v * 1 > 0 ? '-checked' : '';
-
- return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
-
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'last_purchase_price',
- header : 'Last purchase price',
- width : 120,
- renderer : function(v,x,r) {
-
- return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ;
-
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_type',
- header : 'Item type',
- width : 100,
- renderer : function(v) { return String.format('{0}', v); }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- dataIndex : 'item_prodcat_id_prodcat_code',
- header : 'Item prodcat',
- width : 100,
- renderer : function(v) { return String.format('{0}', v); }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- align : 'right',
- dataIndex : 'item_actcost',
- header : 'Cost',
- width : 75,
- renderer : function(v,x,r) {
-
- return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ;
-
- }
- },
- {
- xtype: 'ColumnModel',
- xns: Roo.grid,
- align : 'right',
- dataIndex : 'item_base_cost',
- header : 'Cost (base)',
- width : 75,
- renderer : function(v,x,r) {
-
- return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ;
-
- }
}
]
}
xtype: 'LayoutRegion',
xns: Roo,
split : true,
- width : 200
+ width : 350
}
}
};