<?php 

add_action('dslc_hook_register_modules',
     create_function('', 'return dslc_register_module( "Ainex_Pricing_Table" );')
);

class Ainex_Pricing_Table extends DSLC_Module {
 		
 	// Module Attributes
    var $module_id = 'Ainex_Pricing_Table';
    var $module_title = 'Pricing Table';
    var $module_icon = 'dollar';
    var $module_category = 'Ainex - Pricing Table';
 
 	// Module Options
    function options() { 
				
    	// The options array
    	$dslc_options = array(
			array(
				'label' => 'Columns Pricing Table',
				'id' => 'columns',
				'std' => '4',
				'type' => 'select',
				'section' => 'styling',
				'choices' => array(
					array(
						'label' => '3 Columns',
						'value' => '3'
					),
					array(
						'label' => '4 Columns',
						'value' => '4'
					),
				)
			),
			array(
				'label' => 'Price per month/year',
				'id' => 'price_per',
				'std' => 'per month',
				'type' => 'text',
				'section' => 'styling',
			),
			array(
				'label' => 'Price Type',
				'id' => 'price_before_affter',
				'std' => '1',
				'type' => 'select',
				'section' => 'styling',
				'choices' => array(
					array(
						'label' => 'Before',
						'value' => '1'
					),
					array(
						'label' => 'Affter',
						'value' => '2'
					),
				)
			),

			/*
			 * Column 1
			*/
			array(
				'label' => 'Title',
				'id' => 'title1',
				'std' => 'Economy',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Content',
				'id' => 'content1',
				'std' => '500 GB Disk Space
					100 Databases List
					Free Domain Registration
					1 Hosting Space
					FREE Ad Coupons
					Account Control Panel
					FREE 24/7 Support',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency1',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Price',
				'id' => 'price1',
				'std' => '3.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext1',
				'std' => 'sign up now!',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link1',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 1',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights1',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 1',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 2
			*/
			array(
				'label' => 'Title',
				'id' => 'title2',
				'std' => 'Standard',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Content',
				'id' => 'content2',
				'std' => '1000 GB Disk Space
					500 Databases List
					Free Domain Registration
					3 Hosting Space
					FREE Ad Coupons
					Account Control Panel
					FREE 24/7 Support',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency2',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Price',
				'id' => 'price2',
				'std' => '9.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext2',
				'std' => 'sign up now!',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link2',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 2',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights2',
				'std' => '1',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 2',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 3
			*/
			array(
				'label' => 'Title',
				'id' => 'title3',
				'std' => 'Professional',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Content',
				'id' => 'content3',
				'std' => 'Unlimited Disk Space
					Unlimited Databases List
					Free Domain Registration
					10 Hosting Space
					FREE Ad Coupons
					Account Control Panel
					FREE 24/7 Support',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency3',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Price',
				'id' => 'price3',
				'std' => '18.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext3',
				'std' => 'sign up now!',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link3',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 3',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights3',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 3',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),

			/*
			 * Column 4
			*/
			array(
				'label' => 'Title',
				'id' => 'title4',
				'std' => 'Ultimate',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Content',
				'id' => 'content4',
				'std' => 'Unlimited Disk Space
					Unlimited Databases List
					Free Domain Registration
					20 Hosting Space
					FREE Ad Coupons
					Account Control Panel
					FREE 24/7 Support',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Currency',
				'id' => 'currency4',
				'std' => '$',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Price',
				'id' => 'price4',
				'std' => '60.99',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Button Text',
				'id' => 'buttontext4',
				'std' => 'sign up now!',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Button Link URL',
				'id' => 'button_link4',
				'std' => '#',
				'type' => 'textarea',
				'section' => 'styling',
				'tab'		=> 'Column 4',
			),
			array(
				'label' => 'Highlights',
				'id' => 'highlights4',
				'std' => '0',
				'type' => 'select',
				'section' => 'styling',
				'tab'		=> 'Column 4',
				'choices' => array(
					array(
						'label' => 'No',
						'value' => '0'
					),
					array(
						'label' => 'Yes',
						'value' => '1'
					),
				)
			),
		);

		$dslc_options = array_merge( $dslc_options, $this->shared_options('animation_options') );
		
    	// Return the array
    	return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );

    }
 
 	// Module Output
    function output( $options ) {

    	global $dslc_active;
    	
		if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) )
			$dslc_is_admin = true;
		else
			$dslc_is_admin = false;
		
		//REQUIRED
		$this->module_start( $options );

	?>
	<div class="hosting_plans">
		<?php if($options['columns']==4){ ?>
			<?php for($i=1; $i<5; $i++){ ?>
				<div class="one_fourth<?php if($i==4){ echo ' last'; } ?>">
		        	<div class="plan<?php if($options['highlights'.$i]==1){ echo ' active'; } ?>">
		            	<div class="title">
		                	<h4><?php echo $options['title'.$i]; ?></h4>
		                    <strong><?php echo $options['currency'.$i].$options['price'.$i]; ?> <em>/ <?php echo $options['price_per']; ?></em></strong>              
		                </div>
		                <ul>
		                    <?php 
								$content = stripcslashes( $options['content'.$i] );
								$items = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								$dem    = 1;
								foreach($items as $item){
									$output .= '<li class="fa fa-check">' . htmlspecialchars_decode( $item ) . '</li>';
								}
								
								echo $output;
							?>
						</ul>
		                <a href="<?php echo $options['button_link'.$i]; ?>" class="but_signup"><?php echo $options['buttontext'.$i] ?></a>
		            </div>
		        </div><!-- end plan -->
		    <?php } ?>
		<?php } else { ?>
			<?php for($i=1; $i<4; $i++){ ?>
				<div class="one_third<?php if($i==3){ echo ' last'; } ?>">
		        	<div class="plan<?php if($options['highlights'.$i]==1){ echo ' active'; } ?>">
		            	<div class="title">
		                	<h4><?php echo $options['title'.$i]; ?></h4>
		                    <strong><?php echo $options['currency'.$i].$options['price'.$i]; ?> <em>/ <?php echo $options['price_per']; ?></em></strong>              
		                </div>
		                <ul>
		                    <?php 
								$content = stripcslashes( $options['content'.$i] );
								$items = preg_split( '/\r\n|\r|\n/', $content );

								$output = '';
								$dem    = 1;
								foreach($items as $item){
									$output .= '<li class="fa fa-check">' . htmlspecialchars_decode( $item ) . '</li>';
								}
								
								echo $output;
							?>
						</ul>
		                <a href="<?php echo $options['button_link'.$i]; ?>" class="but_signup"><?php echo $options['buttontext'.$i] ?></a>
		            </div>
		        </div><!-- end plan -->
		    <?php } ?>
		<?php } ?>
	</div>
	<div class="clearfix"></div>
	<?php
    	// REQUIRED
    	$this->module_end( $options );

    }
 
}