<?php 
if(get_theme_mod('social_charity_causes_enable')):
  $social_charity_cause_title = get_theme_mod( 'social_charity_causes_text', __( 'Our Causes', 'social-charity' ) );
  ?>
  <section class="causes causes-slider mgb-lg">
    <div class="container">
      <div class="main-title">
        <h2><?php echo esc_html($social_charity_cause_title);?></h2>
      </div>
      <div class="row">

        <?php  
        if(social_charity_check_wp_give_plugin_activation()):
          $social_charity_causes_Category_id =  get_theme_mod('social_charity_causes_category_id');
          $social_charity_causes_number =  get_theme_mod('social_charity_causes_number');
          $social_charity_args = array(
            'post_type' => 'give_forms',
            'posts_per_page' => $causes_number,
            'post_status' => 'publish',
            'paged' => 1,
          );
          $social_charity_causesloop = new WP_Query($social_charity_args);

          if ( $social_charity_causesloop->have_posts() ) :
            while ($social_charity_causesloop->have_posts()) : $social_charity_causesloop->the_post(); 
              ?>    
              <div class="col-sm-4">
                <div class="c-card">
                  <?php if(has_post_thumbnail()):?>
                    <a href="<?php the_permalink();?>" class="img-holder">
                      <?php the_post_thumbnail('social-charity-causes-image');?>  
                    </a>
                  <?php endif;?>
                  <div class="card-body">
                    <div class="progress">
                      <?php 
                      $social_charity_goal_stats       = give_goal_progress_stats( get_the_ID() );
                      if($social_charity_goal_stats['raw_goal'] !=0){
                       $social_charity_percent_complete = round( ( $social_charity_goal_stats['raw_actual'] / $social_charity_goal_stats['raw_goal'] ), 3 ) * 100;
                     }
                     else
                     {
                       $social_charity_percent_complete = 0;
                     }
                     
                     ?>
                     <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: <?php echo esc_attr($social_charity_percent_complete);?>%" aria-valuenow="<?php echo esc_attr($social_charity_percent_complete);?>" aria-valuemin="0" aria-valuemax="100"><?php echo esc_html($social_charity_percent_complete);?>%</div>
                   </div>
                   <h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4>
                   <div class="raised-goal">
                    <span class="raised"><?php esc_html_e( 'Raised: ', 'social-charity' );?> <?php echo esc_html($social_charity_goal_stats['actual']);?></span>
                    <span class="goal"><?php esc_html_e( 'Goal: ', 'social-charity' );?> <?php echo esc_html($social_charity_goal_stats['goal']);?></span>
                  </div>
                  <?php the_excerpt(); ?>
                  <a href="<?php the_permalink();?>" class="btn btn-md btn-bordered"><?php esc_html_e( 'Donate Now!', 'social-charity' );?> </a>
                </div>
              </div>
            </div>
          <?php endwhile;
        endif;
      endif;
          wp_reset_postdata();
      ?>
    </div>
  </div>
</section>
<?php endif;?> 