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-donation-agent.php
<?php session_start();
/**
 * @package 	WordPress
 * @subpackage 	Children Charity
 * @version		1.0.7
 * 
 * Template Name: Agent Donation
 * 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 !='agent') {
  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("agent/sidebar.php"); ?>
      <main class="tw-col-md-9 p-l-50 common_sec">
        <header class="dFlex vCenter">
          <h1 class="sec_title">Donations</h1>
          <?php include("agent/popup-btn.php"); ?>
        </header>             
        <section class="donation_lists">
          <ul class="list_wrapper">
            <?php
            $user = wp_get_current_user(); 
              $posts = get_posts(array(
                'posts_per_page'    => -1,
                'post_type'=> 'donations',
                'meta_query' => array(
                    array(
                    'key' => 'agency',
                    'value' => $user->ID
                    )
              )
            ));

            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);
           // $user = get_field('user_name',$post->ID);
            ?>
            <li>
              <div class="don_items tw-row">
                <div class="user_name col">
                  <?php echo $user->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>
                <?php
                $feedback_details = get_field('feedback_details',$post->ID);
                if($feedback_details['agent_feedback'] == '' && $feedback_details['approve_agent_feedback'] == 'no' || $feedback_details['approve_agent_feedback'] == '') { ?>

                <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" enctype="multipart/form-data">
                  <div class="tw-row">
                    <div class="">
                      <div class="input-holder">
                        <input type="file" name="file" id="upload_file"/>
                        <label><small>Upload Photo/Video/Documents</small></label>
                      </div>
                    </div>
                    <div class="">
                      <div class="input-holder">
                        <textarea placeholder="Updates Your Suggestions" class="required" title="Suggestions" id="feedback"></textarea>
                      </div>
                    </div>
                    <div class="">
                      <div class="input-holder btn-group hRight">                        
                        <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>
                 
                  <?php if($user_feedback != "") {?>
                  <div class="user_feedback-bx">
                    <div class="user_Ftit">User</div><?php echo $user_feedback;?>
                  </div>
                <?php } ?>
                <?php } if($feedback_details['agent_feedback'] != '' && $feedback_status == 'no')  { ?>

                  <div>Waiting for admin approval</div>

                <?php }?>
              </div>

            </li>
           <?php endforeach; ?>
              </ul>
                  <?php wp_reset_postdata(); ?>

          <?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) {
  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 feedback = document.getElementById("feedback").value;
     // var file_upload = jQuery('#upload_file')[0].files[0];
     //  var donation_id = document.getElementById("donation_id").value; 
     var fd = new FormData();
                var files = jQuery(this).closest('form').find('#upload_file')[0].files[0];
                var feedback = jQuery(this).closest('form').find('#feedback').val();
 var donation_id = jQuery(this).closest('form').find('#donation_id').val();
                fd.append('file', files);
                fd.append('action','agent-feedback');
                fd.append('feedback',feedback);
                fd.append('donation_id',donation_id);


console.log(files);
      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) {
                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);
              // if (data = "updatefeedback") {
              //     alert("feedback send Successfully!");
              // }
          }
      });
} 
  // Prevent form submission
  e.preventDefault();
});
</script>