<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;

$petition_comment 			= isset($campoal_options['conikal_petition_comment_field']) ? $campoal_options['conikal_petition_comment_field'] : 1;

$give_prefix 		= '_give_';

$form_id 			= $post->ID;
$title 				= get_the_title($form_id);
$petition_id        = get_post_meta($form_id, $give_prefix . 'petition_id', true);

$sendinblue_list 	= get_post_meta($form_id, $give_prefix . 'sendinblue_list', true);

// create new and update sendinblue list
if ( empty($sendinblue_list) || (isset($_GET['action']) && $_GET['action'] == 'updated') ) {
	conikal_sendinblue_list($form_id, $sendinblue_list, $title, 'give');
}

/*
$prices 			= give_get_variable_prices($form_id);
$display_style      = give_get_meta($form_id, $give_prefix . 'display_style', true);
$custom_amount      = give_get_meta($form_id, $give_prefix . 'custom_amount', true);
$custom_amount_text = give_get_meta($form_id, $give_prefix . 'custom_amount_text', true);
if ( empty( $custom_amount_text ) ) {
	$custom_amount_text = esc_html__( 'Give a Custom Amount', 'campoal' );
}

if (empty($petition_id)) {
	$city               = get_post_meta($form_id, 'petition_city', true);
	$state              = get_post_meta($form_id, 'petition_state', true);
	$country            = get_post_meta($form_id, 'petition_country', true);
	$post_views         = conikal_format_number('%!,0i', (int) conikal_get_post_views($form_id), true);
} else {
	$city               = get_post_meta($petition_id, 'petition_city', true);
	$state              = get_post_meta($petition_id, 'petition_state', true);
	$country            = get_post_meta($petition_id, 'petition_country', true);

	$post_views         = conikal_format_number('%!,0i', (int) conikal_get_post_views($petition_id), true);
}
*/

// set view
conikal_set_post_views($form_id);
?>

<article id="post-content-<?php the_ID(); ?>" <?php post_class('wrapper read petition'); ?>>
	<!-- MANAGER MENU -->
	<?php get_template_part('templates/content/part/give', 'manage'); ?>
	
	<div class="ui very padded vertical basic secondary segment">
		<div class="ui container">
			<div class="give-feature">
				<div class="ui relaxed grid">
					<div class="sixteen wide mobile sixteen wide tablet eight wide computer column">
						<!-- CAMPAIGN THUMBNAIL -->
						<?php get_template_part('templates/content/part/give', 'thumbnail'); ?>

						<?php get_template_part('templates/content/part/give', 'location'); ?>
				    </div>
				    <div class="sixteen wide mobile sixteen wide tablet eight wide computer column">
						<!-- CAMPAIGN TITLE AND SAHRE BUTTON -->
				    	<?php get_template_part('templates/content/part/give', 'title'); ?>

						<!-- CAMPAIGN PROGRESS AND AUTHOR -->
						<?php get_template_part('templates/content/part/give', 'progress'); ?>
		                <div class="clearfix"></div>
				    </div>
			    </div>
			</div>
		</div>
	</div>
	<div class="ui container">
        <div class="ui relaxed grid">
	        <div class="sixteen wide mobile ten wide tablet ten wide computer column give-single-content" id="content<?php echo esc_attr($form_id) ?>">
				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<!-- MAIN CONTENT -->
					<?php get_template_part('templates/content/part/give', 'tab'); ?>
					
					<?php get_template_part('templates/content/part/give', 'content'); ?>

	        		<!-- TAGS AND DATE -->
                    <?php get_template_part('templates/content/part/give', 'tags'); ?>
	        	</div>
				
				<!-- BACKERS LIST -->
				<?php get_template_part('templates/content/part/give', 'backers'); ?>

	        	<!-- CAMPAIGN UPDATES -->
				<?php get_template_part('templates/content/part/give', 'update'); ?>
	        	
	            <!-- CAMPAIGN COMMENT -->
                <div class="give-comment-section">
                    <?php if(comments_open() && $petition_comment == 1) {
                        comments_template();
                    } ?>
                </div>

				<!-- NAVIGATION -->
				<?php get_template_part('templates/content/part/post', 'navigation'); ?>
	        </div>
	        <div class="sixteen wide mobile six wide tablet six wide computer column give-single-sidebar" id="give-single-sidebar">
				<!-- CONTRIBUTE PACKAGES -->
				<?php if (!wp_is_mobile()) : ?>
					<?php get_template_part('templates/content/part/give-contribute'); ?>
				<?php endif; ?>
	        </div>
	    </div>
	</div>

	<!-- SIMILAR CAMPAIGNS -->
	<?php get_template_part('templates/content/part/give', 'similar'); ?>

	<!-- DONATION MOBILE BUTTON -->
	<?php if (!wp_is_mobile()) : ?>
		<?php get_template_part('templates/content/part/give', 'button'); ?>
	<?php else : ?>
		<?php get_template_part('templates/content/part/give-contribute', 'mobile'); ?>
	<?php endif; ?>
	

<?php 
wp_nonce_field('bookmark_ajax_nonce', 'securityBookmark', true);
wp_nonce_field('update_petition_ajax_nonce', 'securityUpdate', true);
wp_nonce_field('supporters_list_ajax_nonce', 'securitySupporters', true);
wp_nonce_field('views_ajax_nonce', 'securityViews', true);
wp_nonce_field('share_ajax_nonce', 'securityShare' . $form_id, true);
?>
</article>