@@ -22,16 +22,18 @@ const PaymentAgentWithdraw = (() => {
2222 form : '#viewForm' ,
2323 } ;
2424 const field_ids = {
25- ddl_agents : '#ddlAgents' ,
26- frm_msg : '#form-error' ,
27- txt_agents : '#txtAgents' ,
28- txt_amount : '#txtAmount' ,
25+ ddl_agents : '#ddlAgents' ,
26+ frm_msg : '#form-error' ,
27+ txt_agents : '#txtAgents' ,
28+ txt_amount : '#txtAmount' ,
29+ txt_payment_ref : '#txtPaymentRef' ,
2930 } ;
3031
3132 let $agent_error ,
3233 $ddl_agents ,
3334 $txt_agents ,
3435 $txt_amount ,
36+ $txt_payment_ref ,
3537 $views ,
3638 agent_name ,
3739 agent_website ,
@@ -91,14 +93,16 @@ const PaymentAgentWithdraw = (() => {
9193 const min = ( ) => getAPILimit ( 'min' ) ;
9294 const max = ( ) => getAPILimit ( 'max' ) ;
9395
94- $agent_error = $ ( '.row-agent' ) . find ( '.error-msg' ) ;
95- $txt_agents = $ ( field_ids . txt_agents ) ;
96- $txt_amount = $ ( field_ids . txt_amount ) ;
96+ $agent_error = $ ( '.row-agent' ) . find ( '.error-msg' ) ;
97+ $txt_agents = $ ( field_ids . txt_agents ) ;
98+ $txt_amount = $ ( field_ids . txt_amount ) ;
99+ $txt_payment_ref = $ ( field_ids . txt_payment_ref ) ;
97100
98101 $form . find ( '.wrapper-row-agent' ) . find ( 'label' ) . append ( $ ( '<span />' , { text : '*' , class : 'required_field_asterisk' } ) ) ;
99102 $form . find ( 'label[for="txtAmount"]' ) . text ( `${ localize ( 'Amount in' ) } ${ currency } ` ) ;
100103 FormManager . init ( form_id , [
101- { selector : field_ids . txt_amount , validations : [ 'req' , [ 'number' , { type : 'float' , decimals : getDecimalPlaces ( currency ) , min, max } ] , [ 'custom' , { func : ( ) => + Client . get ( 'balance' ) >= + $txt_amount . val ( ) , message : localize ( 'Insufficient balance.' ) } ] ] , request_field : 'amount' } ,
104+ { selector : field_ids . txt_amount , validations : [ 'req' , [ 'number' , { type : 'float' , decimals : getDecimalPlaces ( currency ) , min, max } ] , [ 'custom' , { func : ( ) => + Client . get ( 'balance' ) >= + $txt_amount . val ( ) , message : localize ( 'Insufficient balance.' ) } ] ] , request_field : 'amount' } ,
105+ { selector : field_ids . txt_payment_ref , validations : [ [ 'regular' , { regex : / ^ [ 0 - 9 A - Z a - z . , ' - ] { 0 , 30 } $ / , message : localize ( 'Only letters, numbers, space, hyphen, period, comma, and apostrophe are allowed.' ) } ] , [ 'length' , { min : 0 , max : 30 } ] ] , request_field : 'description' } ,
102106
103107 { request_field : 'currency' , value : currency } ,
104108 { request_field : 'paymentagent_loginid' , value : getPALoginID } ,
@@ -134,12 +138,22 @@ const PaymentAgentWithdraw = (() => {
134138 validateAmount ( ) ;
135139 } ) ;
136140
141+ $txt_payment_ref . on ( 'change' , ( ) => {
142+ validatePaymentRef ( ) ;
143+ } ) ;
144+
137145 const validateAmount = ( ) => {
138146 if ( $txt_amount . val ( ) ) {
139147 Validation . validate ( form_id ) ;
140148 }
141149 } ;
142150
151+ const validatePaymentRef = ( ) => {
152+ if ( $txt_payment_ref . val ( ) ) {
153+ Validation . validate ( form_id ) ;
154+ }
155+ } ;
156+
143157 FormManager . handleSubmit ( {
144158 form_selector : form_id ,
145159 fnc_response_handler : withdrawResponse ,
@@ -175,6 +189,11 @@ const PaymentAgentWithdraw = (() => {
175189 $ ( '#lblCurrency' ) . text ( request . currency ) ;
176190 $ ( '#lblAmount' ) . text ( getNumberFormat ( request . amount , request . currency ) ) ;
177191
192+ if ( request . description ) {
193+ $ ( '#lblPaymentRef' ) . text ( request . description ) ;
194+ $ ( '#lblPaymentRefContainer' ) . setVisibility ( 1 ) ;
195+ }
196+
178197 FormManager . init ( view_ids . confirm , [
179198 { request_field : 'paymentagent_loginid' , value : request . paymentagent_loginid } ,
180199 { request_field : 'amount' , value : getNumberFormat ( request . amount , request . currency ) } ,
0 commit comments