IV. Show Request Withdrawal Options and Withdraw Amount

(Front end: Payments -> Withdraw Moeny -> Request Withdrawal)

/**
 * Protected constructor to prevent creating a new instance of the
 * *Singleton* via the `new` operator from outside of this class.
*/
protected function __construct() {
	add_action( 'wpjobster_payments_withdraw_options', array( $this, 'show_request_withdraw_payments' ), 10, 2 );
	add_filter( 'wpjobster_withdraw_method', array( $this, 'withdraw_method' ) );
}


/*
 * Display Request Withdrawal Method for manual and automated payment withdraw in user's payment
 * This function is hooked to 'wpjobster_payments_withdraw_options' action, which is used to display Request Withdrawal Method for manual and automated payment withdraw in user's payment.
 */
function show_request_withdraw_payments( $uid, $wpjobster_currency_position ) {
	if ( get_option( 'wpjobster_enable_sample_withdraw' ) != "no" ) {
		if ( get_user_meta( $uid, 'sample_payment_email', true ) != '' ) { ?>


			<!-- Display Request Withdrawal Method for manual payment withdraw -->
			<div class="ui divider"></div>
			<div class="sixteen wide column">
				<form class="ui form" method="post" enctype="application/x-www-form-urlencoded">
					<div class="field">
						<div class="three fields no-bottom-margin">
							<input type="hidden" value="<?php echo current_time( 'timestamp', 1 ) ?>" name="tm_tm" />
							<div class="eight wide field withdraw-column">
								<div class="withdraw-title">
								<?php _e( 'Sample', 'wpjobster-sample' ); ?>
								</div>
							</div>


							<div class="four wide field">
								<div class="ui labeled input">
									<label class="ui label"><?php echo wpjobster_get_currency_symbol( wpjobster_get_currency() ); ?></label>
									<input class="" value="<?php if ( isset( $_POST['amount4'] ) ) echo $_POST['amount4']; ?>" type="text" size="10" name="amount4" />
								</div>


								<input value="<?php echo __( 'Sample Email', 'wpjobster-sample' ) . ': ' . get_user_meta( $uid, 'sample_payment_email', true ); ?>" type="hidden" size="30" name="paypal" />
							</div>


							<div class="four wide field">
								<input class="withpaypal ui button secondary nomargin fluid" data-alert-message="<?php echo __( 'Error', 'wpjobster-sample' ) ?>" type="submit" name="withdraw4" value="<?php _e( 'Withdraw', 'wpjobster-sample' ); ?>" />
							</div>
						</div>
					</div>
				</form>
			</div>


		<?php } else { ?>


			<div class="ui divider"></div>
			<div class="eight wide column"><?php _e( 'Sample', 'wpjobster' ); ?></div>
			<div class="eight wide column"><?php echo sprintf( __( 'Please fill your Sample email <a href="%s" class="fill-payment-color">here</a>.', 'wpjobster' ), get_permalink( get_option( 'wpjobster_my_account_personal_info_page_id' ) ) . 'payments/#sample-payments' ); ?></div>
				
		<?php }
	}


	if ( get_option( 'wpjobster_enable_sample_withdraw_automatic' ) == "yes" ) {
		if ( get_user_meta( $uid, 'sample_automatic_payee_id', true ) != '' ) { ?>
			
			<!-- Display Request Withdrawal Method for automated payment withdraw -->
			<div class="ui divider"></div>
			<div class="sixteen wide column">
				<form class="ui form" method="post" enctype="application/x-www-form-urlencoded">
					<div class="field">
						<div class="three fields no-bottom-margin">
							<input type="hidden" value="<?php echo current_time( 'timestamp', 1 ) ?>" name="tm_tm" />


							<div class="eight wide field withdraw-column">
								<div class="withdraw-title"><?php _e( 'Automated Sample', 'wpjobster-sample' ); ?></div>
							</div>


							<div class="four wide field">
								<div class="ui labeled input">
									<label class="ui label"><?php echo wpjobster_get_currency_symbol( wpjobster_get_currency() ); ?></label>
									<input class="" value="<?php if ( isset( $_POST['amount5'] ) ) echo $_POST['amount5']; ?>" type="text" size="10" name="amount5" />
								</div>


								<input value="<?php echo __( 'Sample Payee ID','wpjobster' ) . ': ' . get_user_meta( $uid, 'sample_automatic_payee_id', true ); ?>" type="hidden" size="30" name="paypal" />


							</div>


							<div class="four wide field">
								<input class="withpaypal ui button secondary nomargin fluid" data-alert-message="<?php echo __( 'Error', 'wpjobster-sample' ) ?>" type="submit" name="withdraw5" value="<?php _e( 'Withdraw', 'wpjobster-sample' ); ?>" />
							</div>
						</div>
					</div>
				</form>
			</div>


		<?php } else { ?>


			<div class="ui divider"></div>
			<div class="eight wide column"><?php _e( 'Automated Sample', 'wpjobster-sample' ); ?></div>
			<div class="eight wide column"><?php echo sprintf( __( 'Please fill your Sample details <a href="%s" class="fill-payment-color">here</a>.', 'wpjobster' ), get_permalink( get_option( 'wpjobster_my_account_personal_info_page_id' ) ) . 'payments/#automated-sample-payments' ); ?></div>
		
		<?php }
	}
}


/*
 * Define the withdraw method for withdrawal orders
 * This function is filtering the withdraw method name in withdrawal orders admin.
*/
function withdraw_method( $method ) {
	
	if ( isset( $_POST['withdraw4'] ) ) {
		$method = __( "Sample", 'wpjobster-sample' );
	}


	if ( isset( $_POST['withdraw5'] ) ) {
		$method = __( "Sample (automatic withdrawal)", 'wpjobster-sample' );
	}


	return $method;
}