1+ /**
2+ * Classe que define a window import csv de "Rate"
3+ *
4+ * =======================================
5+ * ###################################
6+ * MagnusBilling
7+ *
8+ * @package MagnusBilling
9+ * @author Adilson Leffa Magnus.
10+ * @copyright Todos os direitos reservados.
11+ * ###################################
12+ * =======================================
13+ * MagnusSolution.com <[email protected] > 14+ * 08/11/2012
15+ */
16+ Ext . define ( 'MBilling.view.did.Bulk' , {
17+ extend : 'Ext.window.Window' ,
18+ alias : 'widget.didbulk' ,
19+ autoShow : true ,
20+ modal : true ,
21+ layout : 'fit' ,
22+ iconCls : 'icon-import-csv' ,
23+ title : t ( 'Bulk destination' ) ,
24+ width : 400 ,
25+ height : window . isThemeNeptune || window . isThemeCrisp ? 295 : window . isThemeTriton ? 390 : 270 ,
26+ labelWidthFields : 120 ,
27+ htmlTipInfo : '' ,
28+ fieldsImport : [ ] ,
29+ fil : [ ] ,
30+ initComponent : function ( ) {
31+ var me = this ,
32+ filters = me . list . filters . getFilterData ( ) ;
33+ if ( ! filters || filters == 0 ) {
34+ Ext . ux . Alert . alert ( 'Alert' , t ( 'Use filters' ) , 'information' ) ;
35+ me . items = [ { } ]
36+ } else {
37+ me . fil = filters ;
38+ me . items = [ {
39+ xtype : 'form' ,
40+ reference : 'didbilkPanel' ,
41+ bodyPadding : 5 ,
42+ defaults : {
43+ anchor : '0' ,
44+ enableKeyEvents : true ,
45+ labelWidth : me . labelWidthFields ,
46+ msgTarget : 'side' ,
47+ plugins : 'markallowblank' ,
48+ allowBlank : false
49+ } ,
50+ items : [ {
51+ xtype : 'userlookup' ,
52+ name : 'id_user' ,
53+ fieldLabel : t ( 'Username' ) ,
54+ allowBlank : false
55+ } , {
56+ xtype : 'fieldset' ,
57+ style : 'margin-top:25px; overflow: visible;' ,
58+ title : t ( 'DID destination' ) ,
59+ collapsible : true ,
60+ collapsed : false ,
61+ defaults : {
62+ labelWidth : 90 ,
63+ anchor : '100%' ,
64+ labelAlign : me . labelAlignFields
65+ } ,
66+ items : [ {
67+ xtype : 'didtypecombo' ,
68+ name : 'voip_call' ,
69+ fieldLabel : t ( 'Type' ) ,
70+ listeners : {
71+ select : function ( combo , records , eOpts ) {
72+ me . onSelectMethod ( combo , records )
73+ } ,
74+ scope : this
75+ }
76+ } , {
77+ xtype : 'textfield' ,
78+ name : 'destination' ,
79+ fieldLabel : t ( 'Destination' ) ,
80+ value : '' ,
81+ allowBlank : true ,
82+ hidden : true
83+ } , {
84+ xtype : 'ivrlookup' ,
85+ name : 'id_ivr' ,
86+ fieldLabel : t ( 'IVR' ) ,
87+ allowBlank : true ,
88+ hidden : true
89+ } , {
90+ xtype : 'queuelookup' ,
91+ name : 'id_queue' ,
92+ fieldLabel : t ( 'Queue' ) ,
93+ allowBlank : true ,
94+ hidden : true
95+ } , {
96+ xtype : 'siplookup' ,
97+ name : 'id_sip' ,
98+ fieldLabel : t ( 'Sip user' ) ,
99+ allowBlank : true
100+ } , {
101+ xtype : 'textarea' ,
102+ name : 'context' ,
103+ fieldLabel : t ( 'Context' ) ,
104+ allowBlank : true ,
105+ emptyText :
t ( 'Asterisk dial plan. Example: exten => _X.=>1,Dial(SIP/[email protected] ,30); )' ) , 106+ height : 300 ,
107+ anchor : '100%' ,
108+ hidden : true
109+ } ]
110+ } ]
111+ } ] ;
112+ }
113+ me . title = me . title + ( me . titleModule ? ' - ' + me . titleModule : '' ) ;
114+ me . bbar = [ {
115+ width : 150 ,
116+ iconCls : 'icon-import-csv' ,
117+ text : t ( 'Bulk DID Destination' ) ,
118+ scope : me ,
119+ handler : me . onBulk
120+ } ] ;
121+ me . callParent ( arguments ) ;
122+ } ,
123+ onSelectMethod : function ( combo , records ) {
124+ this . showFieldsRelated ( records . getData ( ) . showFields ) ;
125+ } ,
126+ showFieldsRelated : function ( showFields ) {
127+ var me = this ,
128+ getForm = me . down ( 'form' ) ;
129+ fields = getForm . getForm ( ) . getFields ( ) ;
130+ fields . each ( function ( field ) {
131+ if ( field . name == 'id_user' ) {
132+ field . setVisible ( true ) ;
133+ } else {
134+ field . setVisible ( showFields . indexOf ( field . name ) !== - 1 ) ;
135+ }
136+ } ) ;
137+ } ,
138+ onBulk : function ( btn ) {
139+ var me = this ,
140+ store = me . list . getStore ( ) ;
141+ if ( ! me . down ( 'form' ) . isValid ( ) ) {
142+ return ;
143+ }
144+ Ext . Ajax . setTimeout ( 1000000 ) ;
145+ me . down ( 'form' ) . submit ( {
146+ url : 'index.php/diddestination/bulkdestinatintion' ,
147+ scope : me ,
148+ params : {
149+ filters : Ext . encode ( me . fil )
150+ } ,
151+ success : function ( form , action ) {
152+ var obj = Ext . decode ( action . response . responseText ) ;
153+ if ( obj . success ) {
154+ Ext . ux . Alert . alert ( t ( 'Success' ) , obj . msg , 'success' ) ;
155+ } else {
156+ Ext . ux . Alert . alert ( t ( 'Error' ) , obj . errors , 'error' ) ;
157+ }
158+ btn . enable ( ) ;
159+ me . list . setLoading ( false ) ;
160+ store . load ( ) ;
161+ me . close ( ) ;
162+ } ,
163+ failure : function ( form , action ) {
164+ var obj = Ext . decode ( action . response . responseText ) ,
165+ errors = Helper . Util . convertErrorsJsonToString ( obj . errors ) ;
166+ if ( ! Ext . isObject ( obj . errors ) ) {
167+ Ext . ux . Alert . alert ( me . titleError , t ( errors ) , 'error' ) ;
168+ } else {
169+ form . markInvalid ( obj . errors ) ;
170+ Ext . ux . Alert . alert ( me . titleWarning , t ( errors ) , 'error' ) ;
171+ }
172+ }
173+ } ) ;
174+ }
175+ } ) ;
0 commit comments