HEX
Server: Apache
System: Linux wyse1.wyseservers.com 4.18.0-553.124.4.el8_10.x86_64 #1 SMP Fri May 15 04:14:14 EDT 2026 x86_64
User: kochikidswysewor (1061)
PHP: 8.3.33
Disabled: NONE
Upload Files
File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/template-payment-user.php
<?php session_start();
/**
 * @package 	WordPress
 * @subpackage 	Children Charity
 * @version		1.0.7
 * 
 * Template Name: User Payments
 * Created by CMSMasters
 * 
 */


get_header();

list($cmsmasters_layout) = children_charity_theme_page_layout_scheme();
$_SESSION['child_id'] = $_POST['child_id'];
$agent = wp_get_current_user(); 
$agent_id = $agent->ID;
if(!$agent_id || $agent->user_role !='sponser') {
  echo "<script>window.location.href='".get_site_url()."/login-register/'</script>";
}
?>
<section class="dashboard_page">
  <div class="container">
    <div class="tw-row v-gap-none">
      <?php include("user/sidebar.php"); ?>
      <main class="tw-col-md-9 p-l-50 common_sec">
        <header class="dFlex vCenter">
          <h1 class="sec_title">Payments</h1>
        </header>             
        <section class="donation_lists">
          <ul class="list_wrapper userPage">

            <?php
            $user = wp_get_current_user(); 

            $posts = get_posts(array(
                'posts_per_page'    => -1,
                'post_type'=> 'donations',
                'meta_query' => array(
                                        array(
                                            'key' => 'user_name',
                                            'value' => $user->ID
                                        ),
                                       array(
                                          'key' => 'payment_status',
                                          'value' => 'completed'
                                      ),
                                    )
            ));

            if( $posts ): ?>
    
        
    <?php foreach( $posts as $post ): 
        
        $amount = get_field('amount',$post->ID);
        $cause = get_field('cause',$post->ID);
        $case = get_field('case',$post->ID);
        $agency = get_field('agency',$post->ID);
        ?>

            <li>
              <div class="don_items tw-row">
                <div class="user_name col">
                 <?php echo $agency->display_name;?>
                  <div class="amount">$<?php echo $amount?> CAD</div>
                </div>
                <div class="cause_name col"><?php echo $cause->name;?></div>
                <div class="case_name col"><?php echo $case->post_title;?></div>
                  <nav class="btn-group col">
                  <a href="<?php echo get_stylesheet_directory_uri().'/mails/download-invoice.php?id='.$post->ID?>" ><button type="button" class="btn btn_sm">Invoice</button></a>
                </nav>
                <?php
                $feedback_details = get_field('feedback_details',$post->ID);
                if($feedback_details['user_feedback'] == '' && $feedback_details['approve_agent_feedback'] == 'yes') { ?>

                <nav class="btn-group col">
                  <button type="button" class="add_feeds btn btn_sm">Add Feedback</button>
                </nav>
                <?php } ?>
              </div>
              <div class="feed_wrapper">
                 <div id="result-msg"></div>
               <form action="javascript:void(0)" method="POST" name="submit-feedback" id="feedback-submit">
                  <div class="tw-row">
                    <!-- <div class="">
                      <div class="input-holder">
                        <input type="file" />
                        <label><small>Upload Photo/Video/Documents</small></label>
                      </div>
                    </div> -->
                    <div class="">
                      <div class="input-holder">
                        <textarea placeholder="Updates Your Suggestions" name="feedback" title="Suggestions" class="required" id="feedback"></textarea>
                      </div>
                    </div>
                    <div class="">
                      <div class="input-holder btn-group hRight feed_add_wrp">                       
                         <input type="hidden" id="donation_id" value="<?php echo $post->ID;?>"/>
                        <input type="submit" class="submit-feedback" value="Submit Feedback" class="btn btn_sm" />
                         <button type="button" class="feed_close">X</button>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
              <div class="Feed_Outer">
                <?php
                $feedback_details = get_field('feedback_details',$post->ID);
                $feedback_status = $feedback_details['approve_agent_feedback'];
                if($feedback_status == 'yes') {
                  $agent_feedback  = $feedback_details['agent_feedback'];
                  $file_upload  = $feedback_details['file_upload'];
                  $user_feedback  = $feedback_details['user_feedback'];
                  ?>
                  <h2 class="feed_tit p-b-0">Feedbacks:</h2>
                  <div class="agent_feedback-bx">
                    <div class="agent_Ftit">Agent</div>
                    <?php echo $agent_feedback;?>
                  <?php if($file_upload != '') { ?>
                    <div class="agent_dwnld">
                     Uploaded File: <a href="<?php echo $file_upload;?>" download>Download File</a>
                    </div>
                  <?php } ?>
                  </div>

                  <div class="user_feedback-bx">
                    <div class="user_Ftit">User</div><?php echo $user_feedback;?>
                  </div>
                <?php } ?>
              </div>
            </li>
             <?php endforeach; ?>
          </ul>
              <?php wp_reset_postdata(); 
else : ?>
<div>Hi <?php echo $user->display_name;?>,
 <p>Currently you have not sponsered any child. For sponsorship, Please <a href="<?php echo get_site_url(); ?>/donate/">Click Here</a></p></div>
           <div>
<?php endif;?>
        </section>
      </main>
    </div>
  </div>
</section>
<?php 
$post_id = $_SESSION['child_id'];
$user = wp_get_current_user(); 
$user_id = $user->ID;
if ( ! add_post_meta( $post_id, 'sponsors_', $user_id, true ) ) { 
   update_post_meta ( $post_id, 'sponsors_', $user_id );
}
?>
<?php get_footer(); ?>


<script>
jQuery('.submit-feedback').click(function(e) {
  // console.log("fdsfsf");
  var $formId = jQuery(this).parents('form');
  var formAction = $formId.attr('action');
  var $error = jQuery('<span class="error"></span>');
  jQuery('span.error').remove();
  jQuery('.input-holder').removeClass('error');
  jQuery('.required', $formId).each(function() {
    var inputVal = jQuery.trim(jQuery(this).val());
    var fieldtitle = jQuery(this).attr("title");
    var fieldname = jQuery(this).attr("name");
    var $parentTag = jQuery(this).parent();
    if (inputVal == '' || inputVal == '-1') {
        $parentTag.addClass('error').append($error.clone().text('Please enter your ' + fieldtitle + '.'));
        jQuery(this).focus();
        return false;
    }
  });

  if (jQuery('span.error').length > 0) {
    jQuery('span.error').each(function() {

        // Set the distance for the error animation
        var distance = 5;

        // Get the error dimensions
        var width = jQuery(this).outerWidth();

        // Calculate starting position
        var start = width + distance;

        // Set the initial CSS
        jQuery(this).show().css({
                display: 'block',
                opacity: 0
            })

            // Animate the error message
            .animate({
                opacity: 1
            }, 'slow');
          });
  } else {
     var fd = new FormData();
    var feedback = jQuery(this).closest('form').find('#feedback').val();
    var donation_id = jQuery(this).closest('form').find('#donation_id').val();
      fd.append('action','user-feedback');
      fd.append('feedback',feedback);
      fd.append('donation_id',donation_id);


      jQuery.ajax({
          type: "POST",
           url: "<?php echo get_stylesheet_directory_uri(); ?>/update-feedback.php",
           data: fd,
          cache: false,
            processData: false,
             contentType: false,
          success: function(data) {
                 // alert(data);
              if (data = "updatefeedback") {
                jQuery("#result-msg").attr("style", "display:block");
                jQuery("#result-msg").html('Feedback send Successfully!').delay(5000).fadeOut();
                setTimeout(function() {
                    jQuery("li.opened").removeClass("opened");
                }, 3000);
                  // alert("feedback send Successfully!");
              }
          }
      });
} 
  // Prevent form submission
  e.preventDefault();
});
</script>