1jQuery( document ).ready( 2 function ($) { 3 function wwpToggleAgentsCustomerOrderBodyClass() { 4 $( 'body' ).toggleClass( 'wwp-agents-customer-order', window.location.hash === '#agentsCustomerOrder' ); 5 } 6 7 wwpToggleAgentsCustomerOrderBodyClass(); 8 $( window ).on( 'hashchange', wwpToggleAgentsCustomerOrderBodyClass ); 9 10 function initUserFilterSelect( $elements ) { 11 var selectConfig = { 12 ajax: { 13 url: ajax.ajax_url, 14 dataType: 'json', 15 delay: 250, 16 data: function (params) { 17 return { 18 user_filter: params.term, 19 action: 'user_search_ajax', 20 type: 'agent_customer_search', 21 nonce: ajax.nonce 22 }; 23 }, 24 processResults: function (data) { 25 var options = []; 26 if (data) { 27 $.each( 28 data, 29 function (index, text) { 30 options.push( { id: text[0], text: text[1] } ); 31 } 32 ); 33 } 34 return { 35 results: options 36 }; 37 }, 38 cache: true 39 }, 40 minimumInputLength: 1, 41 width: '400px', 42 allowClear: true, 43 }; 44 45 if ($.fn.selectWoo) { 46 $elements.selectWoo( selectConfig ); 47 } else if ($.fn.select2) { 48 $elements.select2( selectConfig ); 49 } 50 } 51 if ( typeof ajax !== 'undefined' ) { 52 initUserFilterSelect( $( '.user-filter' ) ); 53 } 54 55 $( document ).on( 56 'submit', 57 '.commission-filters-form, .payout-commission-filters-form', 58 function (e) { 59 e.preventDefault(); 60 61 var $form = $( this ); 62 var action = $form.attr( 'action' ) || $( '.wc_list_commissions_my_account' ).data( 'url' ) || window.location.href.split( '?' )[0]; 63 var url = new URL( action, window.location.origin ); 64 var params = $form.serializeArray(); 65 var fieldsToReset = $form.hasClass( 'payout-commission-filters-form' ) 66 ? [ 'page', 'agent_id', 'customer_id', 'date_from', 'date_to' ] 67 : [ 'agent_id', 'user-filter', 'date_from', 'date_to' ]; 68 69 fieldsToReset.forEach( 70 function ( fieldName ) { 71 url.searchParams.delete( fieldName ); 72 } 73 ); 74 75 params.forEach( 76 function (field) { 77 if ( ! field.name || '' === String( field.value ).trim() ) { 78 return; 79 } 80 url.searchParams.set( field.name, field.value ); 81 } 82 ); 83 84 window.location.assign( url.toString() ); 85 } 86 ); 87 88 $( document ).on( 89 'click', 90 '.submit-filters', 91 function (e) { 92 if ( $( this ).closest( '.commission-filters-form, .payout-commission-filters-form' ).length ) { 93 return; 94 } 95 96 e.preventDefault(); 97 98 var userFilter = $( this ).closest( '.filter-actions, .wc_list_commissions_my_account, .wc_list_customers_my_account' ).find( '.user-filter' ).val() || ''; 99 var url = new URL( window.location.href ); 100 101 if ( userFilter ) { 102 url.searchParams.set( 'user-filter', userFilter ); 103 } else { 104 url.searchParams.delete( 'user-filter' ); 105 } 106 107 window.location.href = url.toString(); 108 } 109 ); 110 if ( typeof select2 !== 'undefined' ) { 111 $( ".customer_country" ).select2( { width: '100%', allowClear: true } ); 112 } 113 114 $('.configure-setup').click(function() { 115 $("#SalesAgentModal").css('display','block'); 116 $('body').css('overflow', 'hidden'); 117 }); 118 119 $(".close").click(function() { 120 $("#SalesAgentModal").css('display','none'); 121 }); 122 123 $('.payment-opt:checked', function() { 124 var payment_option = $('.payment-opt:checked').val(); 125 $('.'+payment_option+'-info').show().nextAll().hide(); 126 $('.payment-info-submit').show(); 127 }); 128 129 $('.paypal-info').hide(); 130 $('.bank-info').hide(); 131 $('.payoneer-info').hide(); 132 133 $('.payment-opt').click(function() { 134 var payment_option = $(this).val(); 135 $('.payment-info').children().hide(); 136 $('.'+payment_option+'-info').show().nextAll().hide(); 137 $('.payment-info-submit').show(); 138 }); 139 140 $( "#commission_date_from" ).datepicker( 141 { 142 dateFormat: 'yy-mm-dd', 143 maxDate: -0, 144 } 145 ); 146 147 $( "#commission_date_to" ).datepicker( 148 { 149 dateFormat: 'yy-mm-dd', 150 maxDate: -0, 151 } 152 ); 153 154 $( '#commission_date_from' ).change( 155 function () { 156 var startDate = $( this ).datepicker( 'getDate' ); 157 $( "#commission_date_to" ).datepicker( "option", "minDate", startDate ); 158 } 159 ); 160 161 $( '#commission_date_to' ).change( 162 function () { 163 var endDate = $( this ).datepicker( 'getDate' ); 164 $( "#commission_date_from" ).datepicker( "option", "maxDate", endDate ); 165 } 166 ); 167 168 $( '.clear-filters' ).click( function () { 169 var clearUrl = $( this ).data( 'url' ); 170 171 if ( clearUrl ) { 172 window.location.href = clearUrl; 173 return; 174 } 175 176 var url = new URL( window.location.href ); 177 url.searchParams.delete( 'user-filter' ); 178 url.searchParams.delete( 'date_from' ); 179 url.searchParams.delete( 'date_to' ); 180 window.location.href = url.toString(); 181 } ); 182 183 $( '.form-export' ).submit( 184 function () { 185 if ($( ".agent-filter" ).length) { 186 if ($.trim( $( "#commission_date_from" ).val() ) === "" || $.trim( $( ".agent-filter" ).val() ) === "") { 187 $( '.message-fillter-error' ).show(); 188 $( "#export_commissions" ).attr( 'disabled', 'disabled' ); 189 return false;
190 } 191 } 192 } 193 ); 194 195 $( ".delete-commission" ).click( 196 function () { 197 if (confirm( ajax.delete_commission )) { 198 199 if (document.location.href.indexOf( '?' ) == -1) { 200 var url = window.location.search + "?delete_commission=" + $( this ).attr( "data-commss" ) 201 + "&delete_order=" + $( this ).attr( "data-order" ) + "&_wpnonce=" + ajax.delete_commission_nonce; 202 } else { 203 // for back end add & 204 var url = window.location.search + "&delete_commission=" + $( this ).attr( "data-commss" ) 205 + "&delete_order=" + $( this ).attr( "data-order" ) + "&_wpnonce=" + ajax.delete_commission_nonce; 206 207 } 208 history.pushState( null, null, url ); 209 location.reload(); 210 211 } 212 } 213 ); 214 215 $('#payment_form').submit(function(e) { 216 e.preventDefault(); 217 //debugger; 218 var payment_form_data = $(this).serialize(); 219 220 var flag_paypal = false; 221 var flag_bank = false; 222 223 if( payment_form_data == '' ) { 224 return false; 225 } 226 227 var payment_type = $("input[name='payout-method']:checked").val(); 228 229 if ( 'paypal' == payment_type ) { 230 231 var paypal_email = $("input[name='paypal[paypal_email]']").val(); 232 233 if ( $.trim( paypal_email ) != '' ) { 234 flag_paypal = true; 235 } else { 236 flag_paypal = false; 237 } 238 239 } else if ( 'bank' == payment_type ) { 240 241 var user_name = $("input[name='bank[full_name]']").val(); 242 var bank_city = $("input[name='bank[bank_city]']").val(); 243 var bank_name = $("input[name='bank[bank_name]']").val(); 244 var acc_num = $("input[name='bank[account_number]']").val(); 245 246 if ( $.trim( user_name ) != '' && $.trim( bank_city ) != '' && $.trim( bank_name ) != '' && $.trim( acc_num ) != '' ) { 247 flag_bank = true; 248 } else { 249 flag_bank = false; 250 } 251 252 } 253 254 if ( flag_paypal || flag_bank ) { 255 256 var ajaxurl = $('.payment-info-submit').data('ajax'); 257 258 var data = { 259 action: 'agent_payment_details', 260 agent_payout_detail: payment_form_data, 261 nonce: ajax.nonce 262 }; 263 264 if ( $(this).find('.wc-sales-agent-loader').length <= 0 ) { 265 $(this).append( `<span class="wc-sales-agent-loader">Loading...</span>` ); 266 } 267 268 $.post( ajaxurl, data, function( response ) { 269 if( response.success == true ) { 270 var thankyou_msg = "<h3>Thank you! Your Payment Detail has been Saved.</h3>" 271 $('.wc-sales-agent-loader').remove(); 272 $('.modal-body').html(thankyou_msg); 273 setTimeout(function(){ 274 location.reload(); 275 }, 1500); 276 } 277 278 }); 279 } 280 281 }); 282 283 /** 284 * export action 285 */ 286 $( '.form-export' ).submit( 287 function () { 288 289 if ($( ".agent-filter" ).length) { 290 291 if ($.trim( $( "#commission_date_from" ).val() ) === "" || $.trim( $( ".agent-filter" ).val() ) === "") { 292 $( '.message-fillter-error' ).show(); 293 $( "#export_commissions" ).attr( 'disabled', 'disabled' ); 294 return false; 295 } 296 } 297 } 298 ); 299 } 300);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.