/** * Panel to manage Order. * * @class JustKnit.panel.Order * @extends Ext.Panel * @param {Object} config An object of options. * @xtype Justknit-panel-order */ JustKnit.panel.Order = function(config) { config = config || {}; Ext.applyIf(config,{ id: 'justknit-panel-order' ,title: _('justknit.order') ,layout: 'anchor' ,defaults: { border: false } ,items:[{ html: '

'+_('justknit.order_management_desc')+'

' ,xtype: 'modx-description' },{ xtype: 'justknit-grid-order'//'modx-description'// }] }); JustKnit.panel.Order.superclass.constructor.call(this,config); }; Ext.extend(JustKnit.panel.Order,Ext.Panel); Ext.reg('justknit-panel-order', JustKnit.panel.Order); //justknit-grid-order //JustKnit.grid.Order JustKnit.grid.Order = function(config) { config = config || {}; Ext.applyIf(config,{ id: 'justknit-grid-order' ,url: MODx.config.connector_url ,cls: 'main-wrapper' ,baseParams: { action: 'JustKnit\\Processors\\Order\\GetList' } ,fields:['id','client_id', 'order_id', 'product_name', 'DS24_product_id', 'quantity', 'api_mode', 'subscriptionstart', 'subscriptionend', 'product_id'] ,autoHeight: true ,paging: true ,emptyText: _('justknit.order_none') ,remoteSort: true ,save_action: 'JustKnit\\Processors\\Order\\UpdateFromGrid' ,autosave: true ,columns: [ { header: _('justknit_order.id') ,dataIndex: 'id', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.client_id') ,dataIndex: 'client_id', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.order_id') ,dataIndex: 'order_id', width: .1 ,sortable: true //https://www.digistore24-app.com/vendor/reports/transactions/order/PNF4TENE ,renderer: function(v) { return `${v}`; } // ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.product_name') ,dataIndex: 'product_name', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.DS24_product_id') ,dataIndex: 'DS24_product_id', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.quantity') ,dataIndex: 'quantity', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } //,{ header: _('justknit_order.api_mode') ,dataIndex: 'api_mode' ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.subscriptionstart') ,dataIndex: 'subscriptionstart', width: .1 //,xtype: 'datecolumn' //,renderer: Ext.util.Format.dateRenderer('m/d/Y') //,renderer : Ext.util.Format.dateRenderer('Y-m-d') //,editor: { xtype: 'datefield' } ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.subscriptionend') ,dataIndex: 'subscriptionend', width: .1 ,sortable: true ,editor: {xtype: 'textfield'} } ,{ header: _('justknit_order.product_id') ,dataIndex: 'product_id', width: .1 ,sortable: true ,editor: { xtype: 'justknit-combo-product', hiddenName: 'active_product',displayField: 'product_name',renderer: true } } ] ,tbar:[{ text: _('justknit.order_create') ,handler: this.createOrder ,scope: this },'->',{ text: _('justknit.active_order_filter') ,handler: this.filterActiveOrder ,scope: this } ,{ xtype: 'justknit-combo-product' ,id: 'justknit-product-filter' ,emptyText: _('justknit.product_filter') ,name: 'fltr_product' ,hiddenName: 'fltr_product' ,displayField: 'product_name' ,valueField: 'id' // store: new Ext.data.ArrayStore({ // }) ,listeners: { 'select': {fn: this.filterByProduct, scope: this} } } ,{ text: _('justknit.reset_filter') ,handler: this.clearFilter ,scope: this } ,{ xtype: 'textfield', emptyText: _('justknit.input_search_filter'), listeners: { 'change': {fn: this.search, scope: this} } } ] }); JustKnit.grid.Order.superclass.constructor.call(this, config); }; Ext.extend(JustKnit.grid.Order, MODx.grid.Grid, { search: function(tf,nv,ov) { var s = this.getStore(); s.baseParams.query = tf.getValue(); this.getBottomToolbar().changePage(1); this.refresh(); } ,clearFilter: function() { this.getStore().baseParams = { action: 'JustKnit\\Processors\\Order\\GetList' }; Ext.getCmp('justknit-product-filter').reset(); // Ext.getCmp('justknit-clients-category-filter').reset(); // Ext.getCmp('goodnews-clients-testdummy-filter').reset(); // Ext.getCmp('goodnews-clients-active-filter').reset(); // Ext.getCmp('goodnews-clients-search-filter').reset(); this.getBottomToolbar().changePage(1); } ,createOrder: function(btn, e) { var win = MODx.load({ xtype: 'justknit-window-order-create-update' ,title: _('justknit.order_create') ,listeners: { 'success': {fn: function() {this.refresh();}, scope: this} } }); win.show(e.target); } ,updateOrder: function(btn, e) { if (!this.menu.record || !this.menu.record.id){ return false; } var win = MODx.load({ xtype: 'justknit-window-order-create-update' ,title: _('justknit.order_update') ,action: 'JustKnit\\Processors\\Order\\Update' ,listeners: { 'success': {fn: function() {this.refresh();}, scope: this} } }); win.fp.getForm().setValues(this.menu.record); win.show(e.target); } ,getMenu:function() { var m = []; m.push({ text: _('justknit.order_update') ,handler: this.updateOrder }); m.push({ text: _('justknit.order_remove') ,handler: this.removeOrder }); m.push('-'); this.addContextMenuItem(m); } ,removeOrder: function(btn, e) { if (!this.menu.record){ return false; } MODx.msg.confirm({ title: _('justknit.order_remove') ,text: _('justknit.order_remove_confirm') ,url: this.config.url ,params: { action: 'JustKnit\\Processors\\Order\\Remove' ,id: this.menu.record.id } ,listeners:{ 'success': { fn: function() {this.refresh();}, scope: this} } }); } ,filterActiveOrder:function(btn, e){ var s = this.getStore(); s.baseParams.activeorderfilter = true; this.getBottomToolbar().changePage(1); this.refresh(); } ,filterByProduct:function(combo) { var s = this.getStore(); s.baseParams.productfilter = combo.getValue(); this.getBottomToolbar().changePage(1); this.refresh(); } }); Ext.reg('justknit-grid-order', JustKnit.grid.Order); // JustKnit.window.CreateUpdateOrder JustKnit.window.CreateUpdateOrder = function(config) { config = config || {}; Ext.applyIf(config, { width: 700 ,closeAction: 'close' ,url: MODx.config.connector_url ,preventRender: true ,action: 'JustKnit\\Processors\\Order\\Create' ,fields: [ new Ext.Panel ({ layout:"column" ,defaults:{layout:'form',style:'margin:0'} ,items:[ {columnWidth:.3,items:[{xtype: 'hidden' ,name: 'id'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.client_id') ,name: 'client_id'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.order_id') ,name: 'order_id'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.product_name') ,name: 'product_name'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.DS24_product_id') ,name: 'DS24_product_id'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.quantity') ,name: 'quantity'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.api_mode') ,name: 'api_mode'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.subscriptionstart') ,name: 'subscriptionstart'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.subscriptionend') ,name: 'subscriptionend'}]} ,{columnWidth:.3,items:[{xtype: 'textfield' ,fieldLabel: _('justknit_order.product_id') ,name: 'product_id'}]} ] }) ] }); JustKnit.window.CreateUpdateOrder.superclass.constructor.call(this, config); }; Ext.extend(JustKnit.window.CreateUpdateOrder, MODx.Window); Ext.reg('justknit-window-order-create-update', JustKnit.window.CreateUpdateOrder);