<?php if ($wo['config']['credit_card'] == 'yes') { ?>
<script src="https://checkout.stripe.com/checkout.js"></script>
<?php } ?>
<div class="page-margin"> 
	<div class="row">
		<div class="col-md-8">
			<div class="fund_raise">
				<img src="<?php echo($wo['fund']['image']); ?>" class="fund_main_img">
				<h2 class="fund_title"><a href="<?php echo $wo['config']['site_url'].'/show_fund/'. $wo['fund']['hashed_id']; ?>" data-ajax="?link1=show_fund&id=<?php echo($wo['fund']['hashed_id']) ?>" style="text-decoration: none;"><?php echo stripslashes($wo['fund']['title']); ?></a></h2>
				<div class="read-blog-info-user">
					<div class="postMeta--author-avatar">
						<a href="<?php echo $wo['fund']['user_data']['url']?>">
							<img src="<?php echo $wo['fund']['user_data']['avatar']?>" alt="User Image">
						</a>
					</div>
					<div class="postMeta--author-text">
						<a href="<?php echo $wo['fund']['user_data']['url']; ?>" data-ajax="?link1=timeline&u=<?php echo $wo['fund']['user_data']['username']; ?>"><?php echo $wo['fund']['user_data']['name']; ?></a>
						<span class="middot">·</span>
						<time><?php echo date("d M Y",$wo['fund']['time']); ?></time>
					</div>
				</div>
				<hr class="fund_raise_hr">
				<div class="fund_raise_btns">
					<?php if ($wo['user']['id'] != $wo['fund']['user_id'] && $wo['fund']['amount'] > $wo['fund']['raised']) { ?>
						<button type="button" class="btn btn-main" data-toggle="modal" data-target="#dont_modal"><?php echo $wo['lang']['donate']; ?></button>
					<?php } ?>
					<div class="dropdown">
						<button class="btn btn-secondary dropdown-toggle" type="button" id="shr_dropdwn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo $wo['lang']['share'];?></button>
						<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="shr_dropdwn">
							<li><a class="dropdown-item" href="https://www.facebook.com/sharer.php?u=<?php echo $wo['config']['site_url'].'/show_fund/'. $wo['fund']['hashed_id']; ?>" target="_blank"><?php echo $wo['lang']['facebook'];?></a></li>
							<li><a class="dropdown-item" href="http://twitter.com/intent/tweet?text=<?php echo $wo['fund']['title'] ?>&amp;url=<?php echo $wo['config']['site_url'].'/show_fund/'. $wo['fund']['hashed_id']; ?>" target="_blank"><?php echo $wo['lang']['twitter'];?></a></li>
							<li><a class="dropdown-item" href="https://www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo $wo['config']['site_url'].'/show_fund/'. $wo['fund']['hashed_id']; ?>" target="_blank"><?php echo $wo['lang']['linkedin'];?></a></li>
							<li><a class="dropdown-item" href="http://pinterest.com/pin/create/button/?url=<?php echo $wo['config']['site_url'].'/show_fund/'. $wo['fund']['hashed_id']; ?>" target="_blank"><?php echo $wo['lang']['pinterest'];?></a></li>
						</ul>
					</div>
				</div>
				<div class="fund_raise_bar">
					<p><?php echo $wo['config']['currency_symbol_array'][$wo['config']['currency']].$wo['fund']['raised']; ?>  <?php echo $wo['lang']['raised_of']; ?> <?php echo $wo['config']['currency_symbol_array'][$wo['config']['currency']].$wo['fund']['amount']; ?></p>
					<div class="progress">
						<div class="progress-bar" role="progressbar" style="width: <?php echo $wo['fund']['bar']; ?>%" aria-valuenow="<?php echo $wo['fund']['bar']; ?>" aria-valuemin="0" aria-valuemax="<?php echo($wo['fund']['amount']) ?>"></div>
					</div>
				</div>
			</div>
			<div class="fund_raise">
				<h4 class="fund_widget_title"><?php echo $wo['lang']['info'];?></h4>
				<?php echo stripslashes($wo['fund']['description']); ?>
			</div>
			
		</div>
		<div class="col-md-4">
			<?php echo Wo_LoadPage('show_fund/sidebar') ?>
		</div>
		<div class="clear"></div>
		<br>		
           <?php echo Wo_LoadPage('footer/content'); ?>
	</div>
	<!-- .row -->
</div>

<div class="modal fade" id="dont_modal" tabindex="-1" role="dialog">
	<div class="modal-dialog modal-sm" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span></button>
				<h4 class="modal-title"><?php echo $wo['lang']['donate']; ?></h4>
			</div>
			<div class="modal-body">
				<h3 class="text-center fund_dnt_hd"><span><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9.06,1.93C7.17,1.92 5.33,3.74 6.17,6H3A2,2 0 0,0 1,8V10A1,1 0 0,0 2,11H11V8H13V11H22A1,1 0 0,0 23,10V8A2,2 0 0,0 21,6H17.83C19,2.73 14.6,0.42 12.57,3.24L12,4L11.43,3.22C10.8,2.33 9.93,1.94 9.06,1.93M9,4C9.89,4 10.34,5.08 9.71,5.71C9.08,6.34 8,5.89 8,5A1,1 0 0,1 9,4M15,4C15.89,4 16.34,5.08 15.71,5.71C15.08,6.34 14,5.89 14,5A1,1 0 0,1 15,4M2,12V20A2,2 0 0,0 4,22H20A2,2 0 0,0 22,20V12H13V20H11V12H2Z"></path></svg></span><?php echo $wo['lang']['amount']; ?></h3>
				<div id="amount_fund_alert"></div>
				<div class="fund_input">
					<input type="number" name="amount" class="form-control" placeholder="0.00" id="fund_donate_amount" onkeyup="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
					<div id="place"></div>
				</div>
				<div class="fund_butns">
					<button class="bank_payment btn btn-main" onclick="Wo_GetPaymentMethods(this);"><?php echo $wo['lang']['donate']; ?></button>
					<input type="hidden" class="form-control" id="fund_donate_id" value="<?php echo $wo['fund']['id']; ?>">
				</div>
			</div>
		</div>
	</div>
</div>

<div id="donate_for_fund_modal"></div>

<div class="modal fade" id="bank_transfer_donate_modal" role="dialog" data-keyboard="false" style="overflow-y: auto;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span></button>
				<h4 class="modal-title"><i class="fa fa-money"></i> <?php echo $wo['lang']['bank_transfer'] ?></h4>
			</div>
			<form class="form form-horizontal" method="post" id="bank_transfer_form_donate">
			<div class="modal-body dt_bank_trans_modal">
				<div id="blog-alert"></div>
				<p><?php echo $wo['config']['bank_description'];?></p>
				<?php if (!empty($wo['config']['bank_transfer_note'])) { ?>
					<div class="dt_user_profile hide_alert_info_bank_trans">
							<span class="valign-wrapper">
								<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"></path></svg> Note:
							</span>
							<ul class="dt_prof_vrfy">
								<li><?php echo $wo['config']['bank_transfer_note'];?></li>
							</ul>
						</div>
				<?php } ?>
				<p class="dt_bank_trans_upl_rec"><a href="javascript:void(0);" onclick="$('#bank_transfer_donate_modal').addClass('up_rec_active'); return false"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z"></path></svg> <?php echo $wo['lang']['upload'] ?></a></p>
					<div class="upload_bank_receipts">
						<div onclick="document.getElementById('upload').click(); return false">
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z"></path></svg>
							<p><?php echo $wo['lang']['browse_to_upload']; ?></p>
							<img id="receipt_img_preview" src="">
						</div>
					</div>
					<input name="price" type="hidden" id="bank_donate_price" class="hidden">
					<input name="fund_id" type="hidden" id="bank_donate_fund_id" class="hidden">
					<input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
					<input name="thumbnail" type="file" id="upload" class="hidden" accept="image/*">
					<input type="reset" id="configreset" value="Reset" class="hidden">
			</div>
			<div class="modal-footer">
					<div class="ball-pulse"><div></div><div></div><div></div></div>
					<button type="submit" class="btn btn-main"><?php echo $wo['lang']['publish']; ?></button>
				</div>
				</form>
		</div>
	</div>
</div>



<div class="modal fade" id="2checkout_wallet_donate_modal" role="dialog" data-keyboard="false" style="overflow-y: auto;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></span></button>
				<h4 class="modal-title"><?php echo $wo['lang']['2checkout'] ?></h4>
			</div>
			<form class="form form-horizontal" method="post" id="2checkout_form_donate_wallet" action="#">
				<div class="modal-body twocheckout_modal">
					<div id="2checkout_alert_donate_wallet"></div>
					<div class="clear"></div>
					<div class="sun_input col-md-6">
						<input id="card_name" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['name']; ?>" value="<?php echo($wo['user']['name']) ?>">
						<label class="plr15" for="card_name"><?php echo $wo['lang']['name']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_address" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['address']; ?>" value="<?php echo($wo['user']['address']) ?>">
						<label class="plr15" for="card_address"><?php echo $wo['lang']['address']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_city" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['city']; ?>" value="<?php echo($wo['user']['city']) ?>">
						<label class="plr15" for="card_city"><?php echo $wo['lang']['city']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_state" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['state']; ?>" value="<?php echo($wo['user']['state']) ?>">
						<label class="plr15" for="card_state"><?php echo $wo['lang']['state']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_zip" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['zip']; ?>" value="<?php echo($wo['user']['zip']) ?>">
						<label class="plr15" for="card_zip"><?php echo $wo['lang']['zip']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<select id="card_country" name="card_country" class="form-control">
							<?php 
								foreach ($wo['countries_name'] as $country_ids => $country) { 
									$country_id = $wo['user']['country_id'];
									$selected_contry = ($country_ids == $country_id) ? ' selected' : '' ;
							?>
								<option value="<?php echo $country_ids;?>" <?php echo $selected_contry;?> ><?php echo $country;?></option>
							<?php } ?>
						</select>
						<label class="plr15" for="card_country"><?php echo $wo['lang']['country']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_email" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['email']; ?>" value="<?php echo($wo['user']['email']) ?>">
						<label class="plr15" for="card_email"><?php echo $wo['lang']['email']; ?></label>  
					</div>
					<div class="sun_input col-md-6">
						<input id="card_phone" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['phone_number']; ?>" value="<?php echo($wo['user']['phone_number']) ?>">
						<label class="plr15" for="card_phone"><?php echo $wo['lang']['phone_number']; ?></label>  
					</div>
					<div class="clear"></div>
					<hr>
					<div class="row two_check_card">
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M20,8H4V6H20M20,18H4V12H20M20,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V6C22,4.89 21.1,4 20,4Z" /></svg>
						<div class="sun_input col-lg-12">
							<input id="_number_" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['card_number']; ?>">
							<input id="card_number" name="card_number" type="hidden" class="form-control input-md" autocomplete="off">
						</div>
						<div class="sun_input col-xs-4">
							<select id="card_month" name="card_month" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['month']; ?> (01)">
								<option value="01">01</option>
								<option value="02">02</option>
								<option value="03">03</option>
								<option value="04">04</option>
								<option value="05">05</option>
								<option value="06">06</option>
								<option value="07">07</option>
								<option value="08">08</option>
								<option value="09">09</option>
								<option value="10">10</option>
								<option value="11">11</option>
								<option value="12">12</option>
							</select>
							<!-- <input id="card_month" name="card_month" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['month']; ?> (01)"> -->
						</div>
						<div class="sun_input col-xs-4 no-padding-both">
							<select id="card_year" name="card_year" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['year']; ?> (2019)">
								<?php for ($i=date('Y'); $i <= date('Y')+15; $i++) {  ?>
									<option value="<?php echo($i) ?>"><?php echo($i) ?></option>
								<?php } ?>
							</select>
							<!-- <input id="card_year" name="card_year" type="text" class="form-control input-md" autocomplete="off" placeholder="<?php echo $wo['lang']['year']; ?> (2019)"> -->
						</div>
						<div class="sun_input col-xs-4">
							<input id="card_cvc" name="card_cvc" type="text" class="form-control input-md" autocomplete="off" placeholder="CVC" maxlength="3" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
						</div>
					</div>
					<div class="clear"></div>
					<input id="card_token" name="token" type="hidden" value="">
					<input id="donate_check_amount" name="amount" type="hidden" value="">
					<input id="donate_check_fund_id" name="fund_id" type="hidden" value="">
				</div>
				<div class="clear"></div>
				<div class="modal-footer">
					<div class="ball-pulse"><div></div><div></div><div></div></div>
					<button type="button" class="btn btn-main" onclick="tokenRequest()" id="2checkout_btn_wallet"><?php echo $wo['lang']['pay']; ?></button>
				</div>
			</form>
		</div>
	</div>
</div>







<script type="text/javascript">
	$(document).on('change', '#upload', function(event) {
		let imgPath = $(this)[0].files[0].name;
	    if (typeof(FileReader) != "undefined") {
	        let reader = new FileReader();
	        reader.onload = function(e) {
				$('#receipt_img_preview').attr('src', e.target.result);
	        }
	        reader.readAsDataURL(this.files[0]);
	    }
		$('#bank_transfer_donate_modal').addClass('up_rec_img_ready');
	});

	
jQuery(document).ready(function($) {
  $('#bank_transfer_donate_modal').ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=funding&s=bank',
    beforeSend: function() {
    $('#bank_transfer_donate_modal').find('.ball-pulse').fadeIn(100);
  },
  success: function(data) {
    if (data['status'] == 200) {
      $("#blog-alert").html('<div class="alert alert-success">'+ data['message'] +'</div>');
      setTimeout(function () {
        window.location = "<?php echo $wo['config']['site_url'];?>";
        $(".prv-img").html('<div class="thumbnail-rendderer"><div><h4 class="bold"><?php echo $wo['lang']['drop_img_here']; ?></h4><div class="error-text-renderer"></div><div><span><?php echo $wo['lang']['or']; ?></span><p><?php echo $wo['lang']['browse_to_upload']; ?></p></div></div> </div>');
        $("#blog-alert").html('');
        $('#configreset').click();

      },3000)
    } else if (data['message']) {
      $("#blog-alert").html('<div class="alert alert-danger">' + data['message'] + '</div>');
    } 
    $('#bank_transfer_donate_modal').find('.ball-pulse').fadeOut(100);
  }});
});






// Called when token created successfully.
var successCallback = function(data) {
	console.log(data);
    var myForm = document.getElementById('2checkout_form_donate_wallet');
    $.post(Wo_Ajax_Requests_File() + '?f=funding&s=2checkout', {card_number: $("#card_number").val(),card_cvc: $("#card_cvc").val(),card_month: $("#card_month").val(),card_year: $("#card_year").val(),card_name: $("#card_name").val(),card_address: $("#card_address").val(),card_city: $("#card_city").val(),card_state: $("#card_state").val(),card_zip: $("#card_zip").val(),card_country: $("#card_country").val(),card_email: $("#card_email").val(),card_phone: $("#card_phone").val(),amount: $('#donate_check_amount').val(),fund_id: $('#donate_check_fund_id').val(),token: data.response.token.token}, function(data, textStatus, xhr) {
    	$('#2checkout_btn_wallet').html("<?php echo($wo['lang']['pay']) ?>");
    	$('#2checkout_btn_wallet').attr('disabled');
    	$('#2checkout_btn_wallet').removeAttr('disabled');
    	$('#2checkout_form_donate_wallet').find('.ball-pulse').fadeOut(100);
    	if (data.status == 200) {
      	 	window.location.href = data.location;
      	} else {
      	 	$('#2checkout_alert_donate_wallet').html("<div class='alert alert-danger'>"+data.error+"</div>");
			setTimeout(function () {
				$('#2checkout_alert_donate_wallet').html("");
			},3000);
      	}
    	/*optional stuff to do after success */
    });
};

// Called when token creation fails.
var errorCallback = function(data) {
	$('#2checkout_btn_wallet').html("<?php echo($wo['lang']['pay']) ?>");
	$('#2checkout_btn_wallet').removeAttr('disabled');
	$('#2checkout_form_donate_wallet').find('.ball-pulse').fadeOut(100);
    if (data.errorCode === 200) {
        tokenRequest();
    } else {
    	$('#2checkout_alert_donate_wallet').html("<div class='alert alert-danger'>"+data.errorMsg+"</div>");
		setTimeout(function () {
			$('#2checkout_alert_donate_wallet').html("");
		},3000);
    }
};

var tokenRequest = function() {
	$('#card_number').val($('#_number_').val());
	$('#2checkout_btn_wallet').html("<?php echo($wo['lang']['please_wait']) ?>");
	$('#2checkout_btn_wallet').attr('disabled','true');
	if ($("#card_number").val() != '' && $("#card_cvc").val() != '' && $("#card_month").val() != '' && $("#card_year").val() != '' && $("#card_name").val() != '' && $("#card_address").val() != '' && $("#card_city").val() != '' && $("#card_state").val() != '' && $("#card_zip").val() != '' && $("#card_country").val() != 0 && $("#card_email").val() != '' && $("#card_phone").val() != '') {
		$('#2checkout_form_donate_wallet').find('.ball-pulse').fadeIn(100);
		// Setup token request arguments
	    var args = {
	        sellerId: "<?php echo($wo['config']['checkout_seller_id']) ?>",
	        publishableKey: "<?php echo($wo['config']['checkout_publishable_key']) ?>",
	        ccNo: $("#card_number").val(),
	        cvv: $("#card_cvc").val(),
	        expMonth: $("#card_month").val(),
	        expYear: $("#card_year").val()
	    };

	    // Make the token request
	    TCO.requestToken(successCallback, errorCallback, args);
	}
	else{
		$('#2checkout_btn_wallet').html("<?php echo($wo['lang']['pay']) ?>");
		$('#2checkout_btn_wallet').removeAttr('disabled');
		$('#2checkout_alert_donate_wallet').html("<div class='alert alert-danger'><?php echo($wo['lang']['please_check_details']) ?></div>");
		setTimeout(function () {
			$('#2checkout_alert_donate_wallet').html("");
		},3000);

	}
	
    
};

$(function() {
    // Pull in the public encryption key for our environment
    TCO.loadPubKey("<?php echo($wo['config']['checkout_mode']) ?>");
});
</script>