<?php
function cip_buy_package_function(){
	
$heading='Corporate Plastic Neutrality It\'s the RIGHT thing to do';
$point1='Every corporation around the world has the obligation to remove their plastic waste footprint and adhere to Corporate Social Responsibility requirements.';
$point2='Every man, woman and child in the western world is responsible for the creation of 50kg of Plastic Waste every year whilst corporations create a variable amount, potentially 100\'s of thousands of kgs daily';
$priceText='Price €';
$hall_of_fame_price_type = ( !empty( get_option('hall_of_fame_price_type') ) ) ? get_option('hall_of_fame_price_type') : 'csr' ;
$inclusive_CSR='Receipted '.strtoupper($hall_of_fame_price_type).' : ';
$kgText='kg';
$confirm='Confirm and Buy';

if(isset($_POST['submit'])){
	$select_plastic_waste=$_POST['plastic_waste-range'];
}
?>
<style>
    button.rounded-circle{
        padding: .2rem .45rem !important;
    }
	 button.rounded-circle:focus{
       outline:none;
    }
</style>
<div class="row">
    <div class="col-12 col-md-6 col-lg-8 mt-4">
        <div data-role="page">
            <div data-role="main" class="mainDiv">
                <div class="plasticHead">
                    <?php _e('Tell us more about your Plastic Waste Footprint',CIP_TXTDOMAIN); ?>
                </div>
                <div class="selPlasticFreq">
                    <?php _e('Select your Plastic Waste Footprint Frequency',CIP_TXTDOMAIN); ?>
                </div>
                <form method="post" id="buyfrm" action="<?php echo get_permalink(4250); ?>">
                    <p id="radioGroup">
                        <input type="radio" id="one_time" name="plastic_waste" value="One Time" checked>
                        <span><?php _e('Single Payment',CIP_TXTDOMAIN); ?></span>
                        <input type="radio" id="month_ly" name="plastic_waste" value="Monthly" >
                        <span><?php _e('Monthly',CIP_TXTDOMAIN); ?></span>
                        <input type="radio" id="year_ly" name="plastic_waste" value="Yearly">
                        <span><?php _e('Yearly',CIP_TXTDOMAIN); ?></span>
						
                    </p>
					<?php
					$selling_price_csr = ( !empty( get_option('selling_price_csr') ) ) ? get_option('selling_price_csr') : 1;
					// $max_price = 25000;
					$max_price = 50000;
					$default_price = $max_price / 2;
					?>

					<div class="row">
						<div class="col-12"><?php __('Select your Plastic Waste Removal Amount', CIP_TXTDOMAIN); ?></div>
						<div class="col-6 col-md-3 card1">
							<button type="button" data-kgslide="10" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 10 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€10 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 10 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card2">
							<button type="button" data-kgslide="50" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 50 ) ); ?>" ><?php echo sprintf( __('Plastic Neutrality Package<br/>€50 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 50 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card3">
							<button type="button" data-kgslide="100" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 100 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€100 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 100 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card4">
							<button type="button" data-kgslide="300" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 300 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€300 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 300 ) ); ?></button>
						</div>
					</div>
					<br/>
					<div class="row">
						<div class="col-6 col-md-3 card5">
							<button type="button" data-kgslide="500" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 500 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€500 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 500 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card6">
							<button type="button" data-kgslide="1000" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 1000 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€1000 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 1000 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card7">
							<button type="button" data-kgslide="2000" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 2000 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€2000 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 2000 ) ); ?></button>
						</div>
						<div class="col-6 col-md-3 card8">
							<button type="button" data-kgslide="5000" class="presetskgs btn text-white" data-togglenot="tooltip" data-placement="top" title="<?php echo sprintf( __('Removal of %s kg of Plastic Waste',CIP_TXTDOMAIN),cip_convert_kgs_by_price( 5000 ) ); ?>"><?php echo sprintf( __('Plastic Neutrality Package<br/>€5000 (%s kg of removed plastic waste)' ,CIP_TXTDOMAIN), cip_convert_kgs_by_price( 5000 ) ); ?></button>
						</div>
					</div>
					
					<br/>
					<div class="row">
						<div class="custom_amount_section col-12">
						<div class="input-group mb-3">
							<div class="input-group-prepend">
							<span class="input-group-text"><?php _e('Insert custom Euro amount', CIP_TXTDOMAIN); ?></span>
							</div>
							<input type="text" class="form-control" name="custom_amount" id="custom_amount">
							<div class="invalid-feedback max"><?php echo sprintf( __('Maximum amount is %s'), number_format( 500000 ) ); ?></div>
							<div class="invalid-feedback min"><?php echo sprintf( __('Minimum amount is %s'), number_format( 10 ) ); ?></div>
						</div>
						</div>
					</div>
					
					<div class="form-group"  id="monthly">
					  <label for="plasticRange"><?php _e('KGs of Plastic Waste (Slide to customize your PNP)',CIP_TXTDOMAIN); ?></label>
					  <input type="range" class="form-control-range" min="10" max="<?php echo $max_price; ?>" name="plastic_waste-rangem" id="plasticRange" step="10" value="<?php echo $default_price; ?>">
						<button type="button" class="monthly_previous my-1 float-left   rounded-circle text-white"><i class="fas fa-angle-double-left"></i></button>
						<button type="button" class="monthly_next my-1 float-right   rounded-circle text-white"><i class="fas fa-angle-double-right"></i></button>
						<div id="kgText">
							 <span id="monthly_val"><?php echo cip_convert_kgs_by_price( $default_price ); ?></span><span><?php _e('kg',CIP_TXTDOMAIN); ?><br><span id="monthText"><?php _e('One Time',CIP_TXTDOMAIN); ?></span></span>
						</div>
					</div>
					<input type="hidden" name="intro" value="intro" />
					<input type="hidden" name="total_price" id="total_price" value="" />
					<input type="hidden" name="plastic_amt" id="plastic_amt" value="" />
                </form>
            </div>
        </div>
    </div>
    <div class="col-12 col-md-6 col-lg-4">
        <div class="card">
            <div class="card-header cdHeader">
                <h5 class="cdHead"><?php echo $heading; ?></h5>
            </div>
            <div class="card-body">
                <ul class="cdList">
                    <li><?php echo $point1 . '<BR><BR>'; ?></li>
                    <li><?php echo $point2; ?></li>
                </ul>
                <p class="kgPlastic"><?php echo $priceText;?><span id="kgPlastic_range"></span><span class="paymentType"> <?php _e('(One Time)',CIP_TXTDOMAIN); ?></span></p>
                <p class="inclusiveCSR"><?php echo $inclusive_CSR;?><span id="inclusive-csr"></span><span class="paymentType"> <?php _e('(One Time)',CIP_TXTDOMAIN); ?></span></p>
                <div class="plasticWaste">
                    <p><span id="monthly_plastic_waste"> </span><?php echo $kgText;?><span class="paymentType"> <?php _e('(One Time)',CIP_TXTDOMAIN); ?></span></p>
                </div>
                <div class="confirmBtn">
                    <p><?php echo $confirm; ?></p>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
jQuery(document).ready(function($){
	$('[data-toggle="tooltip"]').tooltip();
	$('body').on('click', '.presetskgs', function(){
		var thiskg = $(this).attr('data-kgslide');
		if( thiskg != "" ){
			var plastic_waste_radio = $('input[name="plastic_waste"]:checked').val();
			$('div#monthly input[type="range"]').val( thiskg );
			$('div#monthly input[type="range"]').trigger('change');
			$(`input[name='custom_amount']`).val('');
			jQuery('.confirmBtn').show();
			jQuery('.invalid-feedback').hide();
		}
	});
});
</script>
<?php
}